diff --git a/packages/google-cloud-support/.eslintignore b/packages/google-cloud-support/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-support/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-support/.eslintrc.json b/packages/google-cloud-support/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-support/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-support/README.md b/packages/google-cloud-support/README.md index 6ddbe43a7fb5..049b46a9bda0 100644 --- a/packages/google-cloud-support/README.md +++ b/packages/google-cloud-support/README.md @@ -58,6 +58,7 @@ Samples are in the [`samples/`][homepage_samples] directory. Each sample's `READ | Sample | Source Code | | --------------------------- | --------------------------------- | +| get attachment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_attachment_service.get_attachment.js) | | list attachments | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_attachment_service.list_attachments.js) | | close case | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_service.close_case.js) | | create case | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_service.create_case.js) | @@ -68,6 +69,7 @@ Samples are in the [`samples/`][homepage_samples] directory. Each sample's `READ | search cases | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_service.search_cases.js) | | update case | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/case_service.update_case.js) | | create comment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/comment_service.create_comment.js) | +| get comment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/comment_service.get_comment.js) | | list comments | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/comment_service.list_comments.js) | | cloud | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json) | | get attachment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/samples/generated/v2beta/case_attachment_service.get_attachment.js) | @@ -118,7 +120,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -128,7 +130,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-support/LICENSE) +See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [projects]: https://console.cloud.google.com/project diff --git a/packages/google-cloud-support/protos/google/cloud/support/v2/attachment_service.proto b/packages/google-cloud-support/protos/google/cloud/support/v2/attachment_service.proto index 5c63b8dc101f..b077b6b89f70 100644 --- a/packages/google-cloud-support/protos/google/cloud/support/v2/attachment_service.proto +++ b/packages/google-cloud-support/protos/google/cloud/support/v2/attachment_service.proto @@ -47,6 +47,44 @@ service CaseAttachmentService { }; option (google.api.method_signature) = "parent"; } + + // Retrieve an attachment associated with a support case. + // + // EXAMPLES: + // + // cURL: + // + // ```shell + // attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" + // curl \ + // --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + // "https://cloudsupport.googleapis.com/v2/$attachment" + // ``` + // + // Python: + // + // ```python + // import googleapiclient.discovery + // + // api_version = "v2" + // supportApiService = googleapiclient.discovery.build( + // serviceName="cloudsupport", + // version=api_version, + // discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + // ) + // request = ( + // supportApiService.cases() + // .attachments() + // .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") + // ) + // print(request.execute()) + // ``` + rpc GetAttachment(GetAttachmentRequest) returns (Attachment) { + option (google.api.http) = { + get: "/v2/{name=*/*/cases/*/attachments/*}" + }; + option (google.api.method_signature) = "name"; + } } // The request message for the ListAttachments endpoint. @@ -74,6 +112,17 @@ message ListAttachmentsRequest { string page_token = 3; } +// Request for getting an attachment. +message GetAttachmentRequest { + // Required. The name of the attachment to get. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudsupport.googleapis.com/Attachment" + } + ]; +} + // The response message for the ListAttachments endpoint. message ListAttachmentsResponse { // The list of attachments associated with a case. diff --git a/packages/google-cloud-support/protos/google/cloud/support/v2/comment_service.proto b/packages/google-cloud-support/protos/google/cloud/support/v2/comment_service.proto index 6321b52b620e..8c57a0869f2b 100644 --- a/packages/google-cloud-support/protos/google/cloud/support/v2/comment_service.proto +++ b/packages/google-cloud-support/protos/google/cloud/support/v2/comment_service.proto @@ -61,6 +61,43 @@ service CommentService { }; option (google.api.method_signature) = "parent,comment"; } + + // Retrieve a comment. + // + // EXAMPLES: + // + // cURL: + // + // ```shell + // comment="projects/some-project/cases/43595344/comments/234567890" + // curl \ + // --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + // "https://cloudsupport.googleapis.com/v2/$comment" + // ``` + // + // Python: + // + // ```python + // import googleapiclient.discovery + // + // api_version = "v2" + // supportApiService = googleapiclient.discovery.build( + // serviceName="cloudsupport", + // version=api_version, + // discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + // ) + // + // request = supportApiService.cases().comments().get( + // name="projects/some-project/cases/43595344/comments/234567890", + // ) + // print(request.execute()) + // ``` + rpc GetComment(GetCommentRequest) returns (Comment) { + option (google.api.http) = { + get: "/v2/{name=*/*/cases/*/comments/*}" + }; + option (google.api.method_signature) = "name"; + } } // The request message for the ListComments endpoint. @@ -105,3 +142,14 @@ message CreateCommentRequest { // Required. The comment to be added. Comment comment = 2 [(google.api.field_behavior) = REQUIRED]; } + +// The request message for the GetComment endpoint. +message GetCommentRequest { + // Required. The name of the comment to retrieve. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudsupport.googleapis.com/Comment" + } + ]; +} diff --git a/packages/google-cloud-support/protos/protos.d.ts b/packages/google-cloud-support/protos/protos.d.ts index bda14d751a73..7e47840c94ed 100644 --- a/packages/google-cloud-support/protos/protos.d.ts +++ b/packages/google-cloud-support/protos/protos.d.ts @@ -301,6 +301,20 @@ export namespace google { * @returns Promise */ public listAttachments(request: google.cloud.support.v2.IListAttachmentsRequest): Promise; + + /** + * Calls GetAttachment. + * @param request GetAttachmentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Attachment + */ + public getAttachment(request: google.cloud.support.v2.IGetAttachmentRequest, callback: google.cloud.support.v2.CaseAttachmentService.GetAttachmentCallback): void; + + /** + * Calls GetAttachment. + * @param request GetAttachmentRequest message or plain object + * @returns Promise + */ + public getAttachment(request: google.cloud.support.v2.IGetAttachmentRequest): Promise; } namespace CaseAttachmentService { @@ -311,6 +325,13 @@ export namespace google { * @param [response] ListAttachmentsResponse */ type ListAttachmentsCallback = (error: (Error|null), response?: google.cloud.support.v2.ListAttachmentsResponse) => void; + + /** + * Callback as used by {@link google.cloud.support.v2.CaseAttachmentService|getAttachment}. + * @param error Error, if any + * @param [response] Attachment + */ + type GetAttachmentCallback = (error: (Error|null), response?: google.cloud.support.v2.Attachment) => void; } /** Properties of a ListAttachmentsRequest. */ @@ -422,6 +443,103 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a GetAttachmentRequest. */ + interface IGetAttachmentRequest { + + /** GetAttachmentRequest name */ + name?: (string|null); + } + + /** Represents a GetAttachmentRequest. */ + class GetAttachmentRequest implements IGetAttachmentRequest { + + /** + * Constructs a new GetAttachmentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.support.v2.IGetAttachmentRequest); + + /** GetAttachmentRequest name. */ + public name: string; + + /** + * Creates a new GetAttachmentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetAttachmentRequest instance + */ + public static create(properties?: google.cloud.support.v2.IGetAttachmentRequest): google.cloud.support.v2.GetAttachmentRequest; + + /** + * Encodes the specified GetAttachmentRequest message. Does not implicitly {@link google.cloud.support.v2.GetAttachmentRequest.verify|verify} messages. + * @param message GetAttachmentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.support.v2.IGetAttachmentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetAttachmentRequest message, length delimited. Does not implicitly {@link google.cloud.support.v2.GetAttachmentRequest.verify|verify} messages. + * @param message GetAttachmentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.support.v2.IGetAttachmentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetAttachmentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetAttachmentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.support.v2.GetAttachmentRequest; + + /** + * Decodes a GetAttachmentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetAttachmentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.support.v2.GetAttachmentRequest; + + /** + * Verifies a GetAttachmentRequest 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 GetAttachmentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetAttachmentRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.support.v2.GetAttachmentRequest; + + /** + * Creates a plain object from a GetAttachmentRequest message. Also converts values to other types if specified. + * @param message GetAttachmentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.support.v2.GetAttachmentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetAttachmentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetAttachmentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a ListAttachmentsResponse. */ interface IListAttachmentsResponse { @@ -2457,6 +2575,20 @@ export namespace google { * @returns Promise */ public createComment(request: google.cloud.support.v2.ICreateCommentRequest): Promise; + + /** + * Calls GetComment. + * @param request GetCommentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Comment + */ + public getComment(request: google.cloud.support.v2.IGetCommentRequest, callback: google.cloud.support.v2.CommentService.GetCommentCallback): void; + + /** + * Calls GetComment. + * @param request GetCommentRequest message or plain object + * @returns Promise + */ + public getComment(request: google.cloud.support.v2.IGetCommentRequest): Promise; } namespace CommentService { @@ -2474,6 +2606,13 @@ export namespace google { * @param [response] Comment */ type CreateCommentCallback = (error: (Error|null), response?: google.cloud.support.v2.Comment) => void; + + /** + * Callback as used by {@link google.cloud.support.v2.CommentService|getComment}. + * @param error Error, if any + * @param [response] Comment + */ + type GetCommentCallback = (error: (Error|null), response?: google.cloud.support.v2.Comment) => void; } /** Properties of a ListCommentsRequest. */ @@ -2790,6 +2929,103 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a GetCommentRequest. */ + interface IGetCommentRequest { + + /** GetCommentRequest name */ + name?: (string|null); + } + + /** Represents a GetCommentRequest. */ + class GetCommentRequest implements IGetCommentRequest { + + /** + * Constructs a new GetCommentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.support.v2.IGetCommentRequest); + + /** GetCommentRequest name. */ + public name: string; + + /** + * Creates a new GetCommentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCommentRequest instance + */ + public static create(properties?: google.cloud.support.v2.IGetCommentRequest): google.cloud.support.v2.GetCommentRequest; + + /** + * Encodes the specified GetCommentRequest message. Does not implicitly {@link google.cloud.support.v2.GetCommentRequest.verify|verify} messages. + * @param message GetCommentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.support.v2.IGetCommentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCommentRequest message, length delimited. Does not implicitly {@link google.cloud.support.v2.GetCommentRequest.verify|verify} messages. + * @param message GetCommentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.support.v2.IGetCommentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCommentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCommentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.support.v2.GetCommentRequest; + + /** + * Decodes a GetCommentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCommentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.support.v2.GetCommentRequest; + + /** + * Verifies a GetCommentRequest 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 GetCommentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCommentRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.support.v2.GetCommentRequest; + + /** + * Creates a plain object from a GetCommentRequest message. Also converts values to other types if specified. + * @param message GetCommentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.support.v2.GetCommentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCommentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetCommentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Namespace v2beta. */ @@ -7174,6 +7410,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -7191,6 +7430,9 @@ export namespace google { /** CommonLanguageSettings destinations. */ public destinations: google.api.ClientLibraryDestination[]; + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @param [properties] Properties to set @@ -7891,6 +8133,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -7905,6 +8150,9 @@ export namespace google { /** PythonSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + /** * Creates a new PythonSettings instance using the specified properties. * @param [properties] Properties to set @@ -7983,6 +8231,118 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a NodeSettings. */ interface INodeSettings { @@ -8309,6 +8669,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -8323,6 +8686,9 @@ export namespace google { /** GoSettings common. */ public common?: (google.api.ICommonLanguageSettings|null); + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + /** * Creates a new GoSettings instance using the specified properties. * @param [properties] Properties to set @@ -8647,6 +9013,109 @@ export namespace google { PACKAGE_MANAGER = 20 } + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** LaunchStage enum. */ enum LaunchStage { LAUNCH_STAGE_UNSPECIFIED = 0, @@ -8763,6 +9232,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -8793,6 +9263,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -8842,6 +9315,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -8976,6 +9452,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -9017,6 +9496,9 @@ export namespace google { /** DescriptorProto reservedName. */ public reservedName: string[]; + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new DescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -9864,6 +10346,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -9890,6 +10375,9 @@ export namespace google { /** EnumDescriptorProto reservedName. */ public reservedName: string[]; + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @param [properties] Properties to set @@ -10824,6 +11312,9 @@ export namespace google { /** FieldOptions features */ features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); @@ -10879,6 +11370,9 @@ export namespace google { /** FieldOptions features. */ public features?: (google.protobuf.IFeatureSet|null); + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** FieldOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -11099,6 +11593,121 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } /** Properties of an OneofOptions. */ @@ -11337,6 +11946,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -11359,6 +11971,9 @@ export namespace google { /** EnumValueOptions debugRedact. */ public debugRedact: boolean; + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption. */ public uninterpretedOption: google.protobuf.IUninterpretedOption[]; @@ -11948,6 +12563,12 @@ export namespace google { /** FeatureSet jsonFormat */ jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); } /** Represents a FeatureSet. */ @@ -11977,6 +12598,12 @@ export namespace google { /** FeatureSet jsonFormat. */ public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + /** * Creates a new FeatureSet instance using the specified properties. * @param [properties] Properties to set @@ -12099,6 +12726,116 @@ export namespace google { ALLOW = 1, LEGACY_BEST_EFFORT = 2 } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } } /** Properties of a FeatureSetDefaults. */ @@ -12218,8 +12955,11 @@ export namespace google { /** FeatureSetEditionDefault edition */ edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); - /** FeatureSetEditionDefault features */ - features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); } /** Represents a FeatureSetEditionDefault. */ @@ -12234,8 +12974,11 @@ export namespace google { /** FeatureSetEditionDefault edition. */ public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); - /** FeatureSetEditionDefault features. */ - public features?: (google.protobuf.IFeatureSet|null); + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -12768,6 +13511,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Timestamp. */ interface ITimestamp { diff --git a/packages/google-cloud-support/protos/protos.js b/packages/google-cloud-support/protos/protos.js index 54c87cf8b68e..70d8490a5ead 100644 --- a/packages/google-cloud-support/protos/protos.js +++ b/packages/google-cloud-support/protos/protos.js @@ -751,6 +751,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.support.v2.CaseAttachmentService|getAttachment}. + * @memberof google.cloud.support.v2.CaseAttachmentService + * @typedef GetAttachmentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.support.v2.Attachment} [response] Attachment + */ + + /** + * Calls GetAttachment. + * @function getAttachment + * @memberof google.cloud.support.v2.CaseAttachmentService + * @instance + * @param {google.cloud.support.v2.IGetAttachmentRequest} request GetAttachmentRequest message or plain object + * @param {google.cloud.support.v2.CaseAttachmentService.GetAttachmentCallback} callback Node-style callback called with the error, if any, and Attachment + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CaseAttachmentService.prototype.getAttachment = function getAttachment(request, callback) { + return this.rpcCall(getAttachment, $root.google.cloud.support.v2.GetAttachmentRequest, $root.google.cloud.support.v2.Attachment, request, callback); + }, "name", { value: "GetAttachment" }); + + /** + * Calls GetAttachment. + * @function getAttachment + * @memberof google.cloud.support.v2.CaseAttachmentService + * @instance + * @param {google.cloud.support.v2.IGetAttachmentRequest} request GetAttachmentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return CaseAttachmentService; })(); @@ -1006,6 +1039,211 @@ return ListAttachmentsRequest; })(); + v2.GetAttachmentRequest = (function() { + + /** + * Properties of a GetAttachmentRequest. + * @memberof google.cloud.support.v2 + * @interface IGetAttachmentRequest + * @property {string|null} [name] GetAttachmentRequest name + */ + + /** + * Constructs a new GetAttachmentRequest. + * @memberof google.cloud.support.v2 + * @classdesc Represents a GetAttachmentRequest. + * @implements IGetAttachmentRequest + * @constructor + * @param {google.cloud.support.v2.IGetAttachmentRequest=} [properties] Properties to set + */ + function GetAttachmentRequest(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]]; + } + + /** + * GetAttachmentRequest name. + * @member {string} name + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @instance + */ + GetAttachmentRequest.prototype.name = ""; + + /** + * Creates a new GetAttachmentRequest instance using the specified properties. + * @function create + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {google.cloud.support.v2.IGetAttachmentRequest=} [properties] Properties to set + * @returns {google.cloud.support.v2.GetAttachmentRequest} GetAttachmentRequest instance + */ + GetAttachmentRequest.create = function create(properties) { + return new GetAttachmentRequest(properties); + }; + + /** + * Encodes the specified GetAttachmentRequest message. Does not implicitly {@link google.cloud.support.v2.GetAttachmentRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {google.cloud.support.v2.IGetAttachmentRequest} message GetAttachmentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttachmentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetAttachmentRequest message, length delimited. Does not implicitly {@link google.cloud.support.v2.GetAttachmentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {google.cloud.support.v2.IGetAttachmentRequest} message GetAttachmentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetAttachmentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetAttachmentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.support.v2.GetAttachmentRequest} GetAttachmentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttachmentRequest.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.cloud.support.v2.GetAttachmentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetAttachmentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.support.v2.GetAttachmentRequest} GetAttachmentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetAttachmentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetAttachmentRequest message. + * @function verify + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetAttachmentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetAttachmentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.support.v2.GetAttachmentRequest} GetAttachmentRequest + */ + GetAttachmentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.support.v2.GetAttachmentRequest) + return object; + var message = new $root.google.cloud.support.v2.GetAttachmentRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetAttachmentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {google.cloud.support.v2.GetAttachmentRequest} message GetAttachmentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetAttachmentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetAttachmentRequest to JSON. + * @function toJSON + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @instance + * @returns {Object.} JSON object + */ + GetAttachmentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetAttachmentRequest + * @function getTypeUrl + * @memberof google.cloud.support.v2.GetAttachmentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetAttachmentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.support.v2.GetAttachmentRequest"; + }; + + return GetAttachmentRequest; + })(); + v2.ListAttachmentsResponse = (function() { /** @@ -5822,6 +6060,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.support.v2.CommentService|getComment}. + * @memberof google.cloud.support.v2.CommentService + * @typedef GetCommentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.support.v2.Comment} [response] Comment + */ + + /** + * Calls GetComment. + * @function getComment + * @memberof google.cloud.support.v2.CommentService + * @instance + * @param {google.cloud.support.v2.IGetCommentRequest} request GetCommentRequest message or plain object + * @param {google.cloud.support.v2.CommentService.GetCommentCallback} callback Node-style callback called with the error, if any, and Comment + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CommentService.prototype.getComment = function getComment(request, callback) { + return this.rpcCall(getComment, $root.google.cloud.support.v2.GetCommentRequest, $root.google.cloud.support.v2.Comment, request, callback); + }, "name", { value: "GetComment" }); + + /** + * Calls GetComment. + * @function getComment + * @memberof google.cloud.support.v2.CommentService + * @instance + * @param {google.cloud.support.v2.IGetCommentRequest} request GetCommentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + return CommentService; })(); @@ -6561,6 +6832,211 @@ return CreateCommentRequest; })(); + v2.GetCommentRequest = (function() { + + /** + * Properties of a GetCommentRequest. + * @memberof google.cloud.support.v2 + * @interface IGetCommentRequest + * @property {string|null} [name] GetCommentRequest name + */ + + /** + * Constructs a new GetCommentRequest. + * @memberof google.cloud.support.v2 + * @classdesc Represents a GetCommentRequest. + * @implements IGetCommentRequest + * @constructor + * @param {google.cloud.support.v2.IGetCommentRequest=} [properties] Properties to set + */ + function GetCommentRequest(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]]; + } + + /** + * GetCommentRequest name. + * @member {string} name + * @memberof google.cloud.support.v2.GetCommentRequest + * @instance + */ + GetCommentRequest.prototype.name = ""; + + /** + * Creates a new GetCommentRequest instance using the specified properties. + * @function create + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {google.cloud.support.v2.IGetCommentRequest=} [properties] Properties to set + * @returns {google.cloud.support.v2.GetCommentRequest} GetCommentRequest instance + */ + GetCommentRequest.create = function create(properties) { + return new GetCommentRequest(properties); + }; + + /** + * Encodes the specified GetCommentRequest message. Does not implicitly {@link google.cloud.support.v2.GetCommentRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {google.cloud.support.v2.IGetCommentRequest} message GetCommentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCommentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetCommentRequest message, length delimited. Does not implicitly {@link google.cloud.support.v2.GetCommentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {google.cloud.support.v2.IGetCommentRequest} message GetCommentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCommentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCommentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.support.v2.GetCommentRequest} GetCommentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCommentRequest.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.cloud.support.v2.GetCommentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetCommentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.support.v2.GetCommentRequest} GetCommentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCommentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCommentRequest message. + * @function verify + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCommentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetCommentRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.support.v2.GetCommentRequest} GetCommentRequest + */ + GetCommentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.support.v2.GetCommentRequest) + return object; + var message = new $root.google.cloud.support.v2.GetCommentRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCommentRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {google.cloud.support.v2.GetCommentRequest} message GetCommentRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCommentRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetCommentRequest to JSON. + * @function toJSON + * @memberof google.cloud.support.v2.GetCommentRequest + * @instance + * @returns {Object.} JSON object + */ + GetCommentRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetCommentRequest + * @function getTypeUrl + * @memberof google.cloud.support.v2.GetCommentRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetCommentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.support.v2.GetCommentRequest"; + }; + + return GetCommentRequest; + })(); + return v2; })(); @@ -17171,6 +17647,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -17205,6 +17682,14 @@ */ CommonLanguageSettings.prototype.destinations = $util.emptyArray; + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + /** * Creates a new CommonLanguageSettings instance using the specified properties. * @function create @@ -17237,6 +17722,8 @@ writer.int32(message.destinations[i]); writer.ldelim(); } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -17288,6 +17775,10 @@ message.destinations.push(reader.int32()); break; } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -17339,6 +17830,11 @@ break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -17381,6 +17877,11 @@ break; } } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } return message; }; @@ -17399,8 +17900,10 @@ var object = {}; if (options.arrays || options.defaults) object.destinations = []; - if (options.defaults) + if (options.defaults) { object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) object.referenceDocsUri = message.referenceDocsUri; if (message.destinations && message.destinations.length) { @@ -17408,6 +17911,8 @@ for (var j = 0; j < message.destinations.length; ++j) object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); return object; }; @@ -19230,6 +19735,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -19255,6 +19761,14 @@ */ PythonSettings.prototype.common = null; + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + /** * Creates a new PythonSettings instance using the specified properties. * @function create @@ -19281,6 +19795,8 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -19321,6 +19837,10 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -19361,6 +19881,11 @@ if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -19381,6 +19906,11 @@ throw TypeError(".google.api.PythonSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } return message; }; @@ -19397,10 +19927,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.common = null; + object.experimentalFeatures = null; + } if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); return object; }; @@ -19430,6 +19964,258 @@ return typeUrlPrefix + "/google.api.PythonSettings"; }; + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + return PythonSettings; })(); @@ -20306,6 +21092,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -20317,6 +21104,7 @@ * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -20331,6 +21119,14 @@ */ GoSettings.prototype.common = null; + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + /** * Creates a new GoSettings instance using the specified properties. * @function create @@ -20357,6 +21153,9 @@ writer = $Writer.create(); if (message.common != null && Object.hasOwnProperty.call(message, "common")) $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); return writer; }; @@ -20387,7 +21186,7 @@ GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { var tag = reader.uint32(); if (tag === error) @@ -20397,6 +21196,29 @@ message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } default: reader.skipType(tag & 7); break; @@ -20437,6 +21259,14 @@ if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -20457,6 +21287,13 @@ throw TypeError(".google.api.GoSettings.common: object expected"); message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -20473,10 +21310,18 @@ if (!options) options = {}; var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; if (options.defaults) object.common = null; if (message.common != null && message.hasOwnProperty("common")) object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -21115,6 +21960,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 @@ -21384,6 +22474,7 @@ * @name google.protobuf.Edition * @enum {number} * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value * @property {number} EDITION_2023=1000 EDITION_2023 value @@ -21398,6 +22489,7 @@ protobuf.Edition = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; values[valuesById[998] = "EDITION_PROTO2"] = 998; values[valuesById[999] = "EDITION_PROTO3"] = 999; values[valuesById[1000] = "EDITION_2023"] = 1000; @@ -21422,6 +22514,7 @@ * @property {Array.|null} [dependency] FileDescriptorProto dependency * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency * @property {Array.|null} [messageType] FileDescriptorProto messageType * @property {Array.|null} [enumType] FileDescriptorProto enumType * @property {Array.|null} [service] FileDescriptorProto service @@ -21444,6 +22537,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -21494,6 +22588,14 @@ */ FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + /** * FileDescriptorProto messageType. * @member {Array.} messageType @@ -21615,6 +22717,9 @@ writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -21687,6 +22792,12 @@ message.weakDependency.push(reader.int32()); break; } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } case 4: { if (!(message.messageType && message.messageType.length)) message.messageType = []; @@ -21789,6 +22900,13 @@ if (!$util.isInteger(message.weakDependency[i])) return "weakDependency: integer[] expected"; } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } if (message.messageType != null && message.hasOwnProperty("messageType")) { if (!Array.isArray(message.messageType)) return "messageType: array expected"; @@ -21843,6 +22961,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21895,6 +23014,13 @@ for (var i = 0; i < object.weakDependency.length; ++i) message.weakDependency[i] = object.weakDependency[i] | 0; } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } if (object.messageType) { if (!Array.isArray(object.messageType)) throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); @@ -21958,6 +23084,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -22023,6 +23153,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -22079,6 +23210,11 @@ object.syntax = message.syntax; if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -22127,6 +23263,7 @@ * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options * @property {Array.|null} [reservedRange] DescriptorProto reservedRange * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility */ /** @@ -22232,6 +23369,14 @@ */ DescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + /** * Creates a new DescriptorProto instance using the specified properties. * @function create @@ -22284,6 +23429,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); return writer; }; @@ -22376,6 +23523,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -22489,6 +23640,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -22588,6 +23748,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -22617,6 +23797,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -22662,6 +23843,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -24706,6 +25889,7 @@ * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility */ /** @@ -24766,6 +25950,14 @@ */ EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + /** * Creates a new EnumDescriptorProto instance using the specified properties. * @function create @@ -24803,6 +25995,8 @@ if (message.reservedName != null && message.reservedName.length) for (var i = 0; i < message.reservedName.length; ++i) writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); return writer; }; @@ -24865,6 +26059,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -24933,6 +26131,15 @@ if (!$util.isString(message.reservedName[i])) return "reservedName: string[] expected"; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -24982,6 +26189,26 @@ for (var i = 0; i < object.reservedName.length; ++i) message.reservedName[i] = String(object.reservedName[i]); } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } return message; }; @@ -25006,6 +26233,7 @@ if (options.defaults) { object.name = ""; object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -25026,6 +26254,8 @@ for (var j = 0; j < message.reservedName.length; ++j) object.reservedName[j] = message.reservedName[j]; } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; return object; }; @@ -27344,6 +28574,7 @@ * @property {Array.|null} [targets] FieldOptions targets * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference @@ -27464,6 +28695,14 @@ */ FieldOptions.prototype.features = null; + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + /** * FieldOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -27538,6 +28777,8 @@ $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); if (message.features != null && Object.hasOwnProperty.call(message, "features")) $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -27639,6 +28880,10 @@ message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -27774,6 +29019,11 @@ if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -27962,6 +29212,11 @@ throw TypeError(".google.protobuf.FieldOptions.features: object expected"); message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); @@ -28059,6 +29314,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -28091,6 +29347,8 @@ } if (message.features != null && message.hasOwnProperty("features")) object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -28363,6 +29621,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -28404,6 +29663,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -28503,6 +29766,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; })(); @@ -29095,6 +30840,7 @@ * @property {boolean|null} [deprecated] EnumValueOptions deprecated * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption */ @@ -29138,6 +30884,14 @@ */ EnumValueOptions.prototype.debugRedact = false; + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + /** * EnumValueOptions uninterpretedOption. * @member {Array.} uninterpretedOption @@ -29176,6 +30930,8 @@ $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -29227,6 +30983,10 @@ message.debugRedact = reader.bool(); break; } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } case 999: { if (!(message.uninterpretedOption && message.uninterpretedOption.length)) message.uninterpretedOption = []; @@ -29279,6 +31039,11 @@ if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { if (!Array.isArray(message.uninterpretedOption)) return "uninterpretedOption: array expected"; @@ -29312,6 +31077,11 @@ } if (object.debugRedact != null) message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } if (object.uninterpretedOption) { if (!Array.isArray(object.uninterpretedOption)) throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); @@ -29344,6 +31114,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -29351,6 +31122,8 @@ object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) @@ -30790,6 +32563,8 @@ * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility */ /** @@ -30855,6 +32630,22 @@ */ FeatureSet.prototype.jsonFormat = 0; + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + /** * Creates a new FeatureSet instance using the specified properties. * @function create @@ -30891,6 +32682,10 @@ writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); return writer; }; @@ -30951,6 +32746,14 @@ message.jsonFormat = reader.int32(); break; } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -31041,6 +32844,26 @@ case 2: break; } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } return null; }; @@ -31180,6 +33003,54 @@ message.jsonFormat = 2; break; } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } return message; }; @@ -31203,6 +33074,8 @@ object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; } if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; @@ -31216,6 +33089,10 @@ object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; return object; }; @@ -31343,6 +33220,219 @@ return values; })(); + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + return FeatureSet; })(); @@ -31527,6 +33617,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31544,6 +33635,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31592,6 +33684,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -31644,6 +33740,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -31752,7 +33852,8 @@ * @memberof google.protobuf.FeatureSetDefaults * @interface IFeatureSetEditionDefault * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition - * @property {google.protobuf.IFeatureSet|null} [features] FeatureSetEditionDefault features + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures */ /** @@ -31779,12 +33880,20 @@ FeatureSetEditionDefault.prototype.edition = 0; /** - * FeatureSetEditionDefault features. - * @member {google.protobuf.IFeatureSet|null|undefined} features + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault * @instance */ - FeatureSetEditionDefault.prototype.features = null; + FeatureSetEditionDefault.prototype.fixedFeatures = null; /** * Creates a new FeatureSetEditionDefault instance using the specified properties. @@ -31810,10 +33919,12 @@ FeatureSetEditionDefault.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.features != null && Object.hasOwnProperty.call(message, "features")) - $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -31854,8 +33965,12 @@ message.edition = reader.int32(); break; } - case 2: { - message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); break; } default: @@ -31898,6 +34013,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31910,10 +34026,15 @@ case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -31941,6 +34062,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -31982,10 +34107,15 @@ message.edition = 2147483647; break; } - if (object.features != null) { - if (typeof object.features !== "object") - throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features: object expected"); - message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); } return message; }; @@ -32004,13 +34134,16 @@ options = {}; var object = {}; if (options.defaults) { - object.features = null; object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; } - if (message.features != null && message.hasOwnProperty("features")) - object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); if (message.edition != null && message.hasOwnProperty("edition")) object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); return object; }; @@ -33225,6 +35358,22 @@ return GeneratedCodeInfo; })(); + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + protobuf.Timestamp = (function() { /** diff --git a/packages/google-cloud-support/protos/protos.json b/packages/google-cloud-support/protos/protos.json index 461f1eefc45d..ee961698470d 100644 --- a/packages/google-cloud-support/protos/protos.json +++ b/packages/google-cloud-support/protos/protos.json @@ -120,6 +120,24 @@ "(google.api.method_signature)": "parent" } ] + }, + "GetAttachment": { + "requestType": "GetAttachmentRequest", + "responseType": "Attachment", + "options": { + "(google.api.http).get": "/v2/{name=*/*/cases/*/attachments/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=*/*/cases/*/attachments/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] } } }, @@ -143,6 +161,18 @@ } } }, + "GetAttachmentRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudsupport.googleapis.com/Attachment" + } + } + } + }, "ListAttachmentsResponse": { "fields": { "attachments": { @@ -746,6 +776,24 @@ "(google.api.method_signature)": "parent,comment" } ] + }, + "GetComment": { + "requestType": "GetCommentRequest", + "responseType": "Comment", + "options": { + "(google.api.http).get": "/v2/{name=*/*/cases/*/comments/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v2/{name=*/*/cases/*/comments/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] } } }, @@ -800,6 +848,18 @@ } } } + }, + "GetCommentRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "cloudsupport.googleapis.com/Comment" + } + } + } } } }, @@ -1904,8 +1964,7 @@ "java_multiple_files": true, "java_outer_classname": "LaunchStageProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -2128,6 +2187,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -2268,6 +2331,28 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } } } }, @@ -2325,6 +2410,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -2386,6 +2476,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -2419,12 +2522,19 @@ "type": "FileDescriptorProto", "id": 1 } - } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] }, "Edition": { "edition": "proto2", "values": { "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -2463,6 +2573,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -2551,6 +2666,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2776,6 +2895,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2826,7 +2949,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2990,6 +3120,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -3125,7 +3256,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -3153,6 +3285,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3222,6 +3358,26 @@ "id": 2 } } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } } } }, @@ -3310,6 +3466,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3452,6 +3612,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -3462,6 +3623,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -3472,6 +3634,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3482,6 +3645,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3492,7 +3656,8 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", - "edition_defaults.edition": "EDITION_PROTO2", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", "edition_defaults.value": "LENGTH_PREFIXED" } }, @@ -3502,27 +3667,38 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "ALLOW" } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } } }, "extensions": [ [ 1000, - 1000 - ], - [ - 1001, - 1001 - ], - [ - 1002, - 1002 - ], - [ - 9990, - 9990 + 9994 ], [ 9995, @@ -3567,7 +3743,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -3582,6 +3764,33 @@ "ALLOW": 1, "LEGACY_BEST_EFFORT": 2 } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } } } }, @@ -3609,11 +3818,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -3626,6 +3850,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3711,6 +3941,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { diff --git a/packages/google-cloud-support/samples/generated/v2/case_attachment_service.get_attachment.js b/packages/google-cloud-support/samples/generated/v2/case_attachment_service.get_attachment.js new file mode 100644 index 000000000000..b87179eea304 --- /dev/null +++ b/packages/google-cloud-support/samples/generated/v2/case_attachment_service.get_attachment.js @@ -0,0 +1,61 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the attachment to get. + */ + // const name = 'abc123' + + // Imports the Support library + const {CaseAttachmentServiceClient} = require('@google-cloud/support').v2; + + // Instantiates a client + const supportClient = new CaseAttachmentServiceClient(); + + async function callGetAttachment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await supportClient.getAttachment(request); + console.log(response); + } + + callGetAttachment(); + // [END cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-support/samples/generated/v2/comment_service.get_comment.js b/packages/google-cloud-support/samples/generated/v2/comment_service.get_comment.js new file mode 100644 index 000000000000..4d0ca7ff2c40 --- /dev/null +++ b/packages/google-cloud-support/samples/generated/v2/comment_service.get_comment.js @@ -0,0 +1,61 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudsupport_v2_generated_CommentService_GetComment_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the comment to retrieve. + */ + // const name = 'abc123' + + // Imports the Support library + const {CommentServiceClient} = require('@google-cloud/support').v2; + + // Instantiates a client + const supportClient = new CommentServiceClient(); + + async function callGetComment() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await supportClient.getComment(request); + console.log(response); + } + + callGetComment(); + // [END cloudsupport_v2_generated_CommentService_GetComment_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json b/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json index f6dec4abe7bc..52652e7e3ccd 100644 --- a/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json +++ b/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-support", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { @@ -59,6 +59,46 @@ } } }, + { + "regionTag": "cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_async", + "title": "CaseAttachmentService getAttachment Sample", + "origin": "API_DEFINITION", + "description": " Retrieve an attachment associated with a support case. EXAMPLES: cURL: ```shell attachment=\"projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB\" curl \\ --header \"Authorization: Bearer $(gcloud auth print-access-token)\" \\ \"https://cloudsupport.googleapis.com/v2/$attachment\" ``` Python: ```python import googleapiclient.discovery api_version = \"v2\" supportApiService = googleapiclient.discovery.build( serviceName=\"cloudsupport\", version=api_version, discoveryServiceUrl=f\"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}\", ) request = ( supportApiService.cases() .attachments() .get(name=\"projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB\") ) print(request.execute()) ```", + "canonical": true, + "file": "case_attachment_service.get_attachment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetAttachment", + "fullName": "google.cloud.support.v2.CaseAttachmentService.GetAttachment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.support.v2.Attachment", + "client": { + "shortName": "CaseAttachmentServiceClient", + "fullName": "google.cloud.support.v2.CaseAttachmentServiceClient" + }, + "method": { + "shortName": "GetAttachment", + "fullName": "google.cloud.support.v2.CaseAttachmentService.GetAttachment", + "service": { + "shortName": "CaseAttachmentService", + "fullName": "google.cloud.support.v2.CaseAttachmentService" + } + } + } + }, { "regionTag": "cloudsupport_v2_generated_CaseService_GetCase_async", "title": "CaseAttachmentService getCase Sample", @@ -514,6 +554,46 @@ } } } + }, + { + "regionTag": "cloudsupport_v2_generated_CommentService_GetComment_async", + "title": "CaseAttachmentService getComment Sample", + "origin": "API_DEFINITION", + "description": " Retrieve a comment. EXAMPLES: cURL: ```shell comment=\"projects/some-project/cases/43595344/comments/234567890\" curl \\ --header \"Authorization: Bearer $(gcloud auth print-access-token)\" \\ \"https://cloudsupport.googleapis.com/v2/$comment\" ``` Python: ```python import googleapiclient.discovery api_version = \"v2\" supportApiService = googleapiclient.discovery.build( serviceName=\"cloudsupport\", version=api_version, discoveryServiceUrl=f\"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}\", ) request = supportApiService.cases().comments().get( name=\"projects/some-project/cases/43595344/comments/234567890\", ) print(request.execute()) ```", + "canonical": true, + "file": "comment_service.get_comment.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 53, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetComment", + "fullName": "google.cloud.support.v2.CommentService.GetComment", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.support.v2.Comment", + "client": { + "shortName": "CommentServiceClient", + "fullName": "google.cloud.support.v2.CommentServiceClient" + }, + "method": { + "shortName": "GetComment", + "fullName": "google.cloud.support.v2.CommentService.GetComment", + "service": { + "shortName": "CommentService", + "fullName": "google.cloud.support.v2.CommentService" + } + } + } } ] } diff --git a/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json b/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json index 682beecf210c..b1a161618568 100644 --- a/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json +++ b/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-support", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-support/src/v2/case_attachment_service_client.ts b/packages/google-cloud-support/src/v2/case_attachment_service_client.ts index e1ed9634d722..9f56b398f890 100644 --- a/packages/google-cloud-support/src/v2/case_attachment_service_client.ts +++ b/packages/google-cloud-support/src/v2/case_attachment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CaseAttachmentServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CaseAttachmentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseAttachmentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseAttachmentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseAttachmentServiceClient. @@ -100,21 +107,43 @@ export class CaseAttachmentServiceClient { * const client = new CaseAttachmentServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CaseAttachmentServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof CaseAttachmentServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +168,7 @@ export class CaseAttachmentServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +182,7 @@ export class CaseAttachmentServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,22 +204,23 @@ export class CaseAttachmentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -201,14 +228,20 @@ export class CaseAttachmentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAttachments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attachments') + listAttachments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'attachments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CaseAttachmentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CaseAttachmentService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -239,37 +272,43 @@ export class CaseAttachmentServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CaseAttachmentService. this.caseAttachmentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CaseAttachmentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CaseAttachmentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CaseAttachmentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const caseAttachmentServiceStubMethods = - ['listAttachments']; + const caseAttachmentServiceStubMethods = [ + 'listAttachments', + 'getAttachment', + ]; for (const methodName of caseAttachmentServiceStubMethods) { const callPromise = this.caseAttachmentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -284,8 +323,14 @@ export class CaseAttachmentServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -296,8 +341,14 @@ export class CaseAttachmentServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -328,9 +379,7 @@ export class CaseAttachmentServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -339,8 +388,9 @@ export class CaseAttachmentServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -351,96 +401,279 @@ export class CaseAttachmentServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Retrieve an attachment associated with a support case. + * + * EXAMPLES: + * + * cURL: + * + * ```shell + * attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" + * curl \ + * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + * "https://cloudsupport.googleapis.com/v2/$attachment" + * ``` + * + * Python: + * + * ```python + * import googleapiclient.discovery + * + * api_version = "v2" + * supportApiService = googleapiclient.discovery.build( + * serviceName="cloudsupport", + * version=api_version, + * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + * ) + * request = ( + * supportApiService.cases() + * .attachments() + * .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") + * ) + * print(request.execute()) + * ``` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the attachment to get. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Attachment|Attachment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_attachment_service.get_attachment.js + * region_tag:cloudsupport_v2_generated_CaseAttachmentService_GetAttachment_async + */ + getAttachment( + request?: protos.google.cloud.support.v2.IGetAttachmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | undefined, + {} | undefined, + ] + >; + getAttachment( + request: protos.google.cloud.support.v2.IGetAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | null | undefined, + {} | null | undefined + >, + ): void; + getAttachment( + request: protos.google.cloud.support.v2.IGetAttachmentRequest, + callback: Callback< + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | null | undefined, + {} | null | undefined + >, + ): void; + getAttachment( + request?: protos.google.cloud.support.v2.IGetAttachmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.support.v2.IAttachment, + | protos.google.cloud.support.v2.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; + }); + this._log.info('getAttachment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.IAttachment, + | protos.google.cloud.support.v2.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getAttachment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getAttachment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.IAttachment, + protos.google.cloud.support.v2.IGetAttachmentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAttachment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); + } + throw error; + }); + } - /** - * List all the attachments associated with a support case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2.Attachment|Attachment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAttachmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List all the attachments associated with a support case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2.Attachment|Attachment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachments( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]>; + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ] + >; listAttachments( - request: protos.google.cloud.support.v2.IListAttachmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): void; + request: protos.google.cloud.support.v2.IListAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): void; listAttachments( - request: protos.google.cloud.support.v2.IListAttachmentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): void; + request: protos.google.cloud.support.v2.IListAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): void; listAttachments( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): - Promise<[ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]>|void { + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAttachments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -449,122 +682,126 @@ export class CaseAttachmentServiceClient { this._log.info('listAttachments request %j', request); return this.innerApiCalls .listAttachments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]) => { - this._log.info('listAttachments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ]) => { + this._log.info('listAttachments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAttachments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Attachment|Attachment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAttachmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAttachments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Attachment|Attachment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachmentsStream( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments stream %j', request); return this.descriptors.page.listAttachments.createStream( this.innerApiCalls.listAttachments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAttachments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2.Attachment|Attachment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_attachment_service.list_attachments.js - * region_tag:cloudsupport_v2_generated_CaseAttachmentService_ListAttachments_async - */ + /** + * Equivalent to `listAttachments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2.Attachment|Attachment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_attachment_service.list_attachments.js + * region_tag:cloudsupport_v2_generated_CaseAttachmentService_ListAttachments_async + */ listAttachmentsAsync( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments iterate %j', request); return this.descriptors.page.listAttachments.asyncIterate( this.innerApiCalls['listAttachments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -578,7 +815,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -593,7 +830,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -604,7 +843,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -615,7 +856,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -630,8 +875,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -641,8 +890,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -652,8 +905,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -664,7 +921,11 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -679,8 +940,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -690,8 +955,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -701,8 +970,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -712,7 +985,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -727,7 +1000,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -738,7 +1012,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -749,7 +1024,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -764,8 +1043,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -775,8 +1058,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -786,8 +1073,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -798,7 +1089,7 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -814,7 +1105,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -825,7 +1118,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -836,7 +1131,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -847,7 +1144,7 @@ export class CaseAttachmentServiceClient { */ close(): Promise { if (this.caseAttachmentServiceStub && !this._terminated) { - return this.caseAttachmentServiceStub.then(stub => { + return this.caseAttachmentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -855,4 +1152,4 @@ export class CaseAttachmentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/case_attachment_service_client_config.json b/packages/google-cloud-support/src/v2/case_attachment_service_client_config.json index cbbee7880fdc..36e77febe3e0 100644 --- a/packages/google-cloud-support/src/v2/case_attachment_service_client_config.json +++ b/packages/google-cloud-support/src/v2/case_attachment_service_client_config.json @@ -36,6 +36,10 @@ "timeout_millis": 60000, "retry_codes_name": "unavailable", "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, + "GetAttachment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/packages/google-cloud-support/src/v2/case_service_client.ts b/packages/google-cloud-support/src/v2/case_service_client.ts index 2906526ea18e..69e926b7dfc9 100644 --- a/packages/google-cloud-support/src/v2/case_service_client.ts +++ b/packages/google-cloud-support/src/v2/case_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CaseServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CaseServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseServiceClient. @@ -100,21 +107,42 @@ export class CaseServiceClient { * const client = new CaseServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CaseServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +167,7 @@ export class CaseServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +181,7 @@ export class CaseServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,25 +203,26 @@ export class CaseServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' + 'organizations/{organization}', ), organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -204,18 +230,30 @@ export class CaseServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCaseClassifications: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'caseClassifications') + listCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCaseClassifications: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'caseClassifications', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CaseService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CaseService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -246,37 +284,49 @@ export class CaseServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CaseService. this.caseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CaseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CaseService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CaseService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const caseServiceStubMethods = - ['getCase', 'listCases', 'searchCases', 'createCase', 'updateCase', 'escalateCase', 'closeCase', 'searchCaseClassifications']; + const caseServiceStubMethods = [ + 'getCase', + 'listCases', + 'searchCases', + 'createCase', + 'updateCase', + 'escalateCase', + 'closeCase', + 'searchCaseClassifications', + ]; for (const methodName of caseServiceStubMethods) { const callPromise = this.caseServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -291,8 +341,14 @@ export class CaseServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -303,8 +359,14 @@ export class CaseServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -335,9 +397,7 @@ export class CaseServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -346,8 +406,9 @@ export class CaseServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -358,606 +419,775 @@ export class CaseServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of a case to be retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.get_case.js - * region_tag:cloudsupport_v2_generated_CaseService_GetCase_async - */ + /** + * Retrieve a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of a case to be retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.get_case.js + * region_tag:cloudsupport_v2_generated_CaseService_GetCase_async + */ getCase( - request?: protos.google.cloud.support.v2.IGetCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IGetCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ] + >; getCase( - request: protos.google.cloud.support.v2.IGetCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IGetCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request: protos.google.cloud.support.v2.IGetCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IGetCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request?: protos.google.cloud.support.v2.IGetCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.IGetCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Create a new case and associate it with a parent. - * - * It must have the following fields set: `display_name`, `description`, - * `classification`, and `priority`. If you're just testing the API and don't - * want to route your case to an agent, set `testCase=true`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent under which the case should be created. - * @param {google.cloud.support.v2.Case} request.case - * Required. The case to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.create_case.js - * region_tag:cloudsupport_v2_generated_CaseService_CreateCase_async - */ + /** + * Create a new case and associate it with a parent. + * + * It must have the following fields set: `display_name`, `description`, + * `classification`, and `priority`. If you're just testing the API and don't + * want to route your case to an agent, set `testCase=true`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent under which the case should be created. + * @param {google.cloud.support.v2.Case} request.case + * Required. The case to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.create_case.js + * region_tag:cloudsupport_v2_generated_CaseService_CreateCase_async + */ createCase( - request?: protos.google.cloud.support.v2.ICreateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICreateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ] + >; createCase( - request: protos.google.cloud.support.v2.ICreateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request: protos.google.cloud.support.v2.ICreateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request?: protos.google.cloud.support.v2.ICreateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.ICreateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Update a case. Only some fields can be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.support.v2.Case} request.case - * Required. The case to update. - * @param {google.protobuf.FieldMask} request.updateMask - * A list of attributes of the case that should be updated. Supported values - * are `priority`, `display_name`, and `subscriber_email_addresses`. If no - * fields are specified, all supported fields are updated. - * - * Be careful - if you do not provide a field mask, then you might - * accidentally clear some fields. For example, if you leave the field mask - * empty and do not provide a value for `subscriber_email_addresses`, then - * `subscriber_email_addresses` is updated to empty. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.update_case.js - * region_tag:cloudsupport_v2_generated_CaseService_UpdateCase_async - */ + /** + * Update a case. Only some fields can be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.support.v2.Case} request.case + * Required. The case to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A list of attributes of the case that should be updated. Supported values + * are `priority`, `display_name`, and `subscriber_email_addresses`. If no + * fields are specified, all supported fields are updated. + * + * Be careful - if you do not provide a field mask, then you might + * accidentally clear some fields. For example, if you leave the field mask + * empty and do not provide a value for `subscriber_email_addresses`, then + * `subscriber_email_addresses` is updated to empty. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.update_case.js + * region_tag:cloudsupport_v2_generated_CaseService_UpdateCase_async + */ updateCase( - request?: protos.google.cloud.support.v2.IUpdateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IUpdateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ] + >; updateCase( - request: protos.google.cloud.support.v2.IUpdateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IUpdateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request: protos.google.cloud.support.v2.IUpdateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IUpdateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request?: protos.google.cloud.support.v2.IUpdateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2.IUpdateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'case.name': request.case!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'case.name': request.case!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Escalate a case, starting the Google Cloud Support escalation management - * process. - * - * This operation is only available for some support services. Go to - * https://cloud.google.com/support and look for 'Technical support - * escalations' in the feature list to find out which ones let you - * do that. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to be escalated. - * @param {google.cloud.support.v2.Escalation} request.escalation - * The escalation information to be sent with the escalation request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.escalate_case.js - * region_tag:cloudsupport_v2_generated_CaseService_EscalateCase_async - */ + /** + * Escalate a case, starting the Google Cloud Support escalation management + * process. + * + * This operation is only available for some support services. Go to + * https://cloud.google.com/support and look for 'Technical support + * escalations' in the feature list to find out which ones let you + * do that. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to be escalated. + * @param {google.cloud.support.v2.Escalation} request.escalation + * The escalation information to be sent with the escalation request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.escalate_case.js + * region_tag:cloudsupport_v2_generated_CaseService_EscalateCase_async + */ escalateCase( - request?: protos.google.cloud.support.v2.IEscalateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IEscalateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ] + >; escalateCase( - request: protos.google.cloud.support.v2.IEscalateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IEscalateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request: protos.google.cloud.support.v2.IEscalateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IEscalateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request?: protos.google.cloud.support.v2.IEscalateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.IEscalateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('escalateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + | protos.google.cloud.support.v2.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('escalateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.escalateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('escalateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .escalateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('escalateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Close a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to close. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.close_case.js - * region_tag:cloudsupport_v2_generated_CaseService_CloseCase_async - */ + /** + * Close a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to close. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.close_case.js + * region_tag:cloudsupport_v2_generated_CaseService_CloseCase_async + */ closeCase( - request?: protos.google.cloud.support.v2.ICloseCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICloseCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ] + >; closeCase( - request: protos.google.cloud.support.v2.ICloseCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICloseCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request: protos.google.cloud.support.v2.ICloseCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICloseCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request?: protos.google.cloud.support.v2.ICloseCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2.ICloseCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('closeCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('closeCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.closeCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('closeCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .closeCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('closeCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * Retrieve all cases under a parent, but not its children. - * - * For example, listing cases under an organization only returns the cases - * that are directly parented by that organization. To retrieve cases - * under an organization and its projects, use `cases.search`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2.Case|Case}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve all cases under a parent, but not its children. + * + * For example, listing cases under an organization only returns the cases + * that are directly parented by that organization. To retrieve cases + * under an organization and its projects, use `cases.search`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2.Case|Case}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCases( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]>; + request?: protos.google.cloud.support.v2.IListCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ] + >; listCases( - request: protos.google.cloud.support.v2.IListCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.IListCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; listCases( - request: protos.google.cloud.support.v2.IListCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.IListCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; listCases( - request?: protos.google.cloud.support.v2.IListCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]>|void { + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -966,266 +1196,289 @@ export class CaseServiceClient { this._log.info('listCases request %j', request); return this.innerApiCalls .listCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]) => { - this._log.info('listCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ]) => { + this._log.info('listCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Case|Case} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Case|Case} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCasesStream( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListCasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases stream %j', request); return this.descriptors.page.listCases.createStream( this.innerApiCalls.listCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2.Case|Case}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.list_cases.js - * region_tag:cloudsupport_v2_generated_CaseService_ListCases_async - */ + /** + * Equivalent to `listCases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2.Case|Case}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.list_cases.js + * region_tag:cloudsupport_v2_generated_CaseService_ListCases_async + */ listCasesAsync( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListCasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases iterate %j', request); return this.descriptors.page.listCases.asyncIterate( this.innerApiCalls['listCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Search for cases using a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2.Case|Case}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Search for cases using a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2.Case|Case}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCases( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]>; + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ] + >; searchCases( - request: protos.google.cloud.support.v2.ISearchCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.ISearchCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; searchCases( - request: protos.google.cloud.support.v2.ISearchCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.ISearchCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; searchCases( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]>|void { + | protos.google.cloud.support.v2.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + | protos.google.cloud.support.v2.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1234,267 +1487,297 @@ export class CaseServiceClient { this._log.info('searchCases request %j', request); return this.innerApiCalls .searchCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]) => { - this._log.info('searchCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ]) => { + this._log.info('searchCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Case|Case} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `searchCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Case|Case} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCasesStream( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases stream %j', request); return this.descriptors.page.searchCases.createStream( this.innerApiCalls.searchCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2.Case|Case}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.search_cases.js - * region_tag:cloudsupport_v2_generated_CaseService_SearchCases_async - */ + /** + * Equivalent to `searchCases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2.Case|Case}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.search_cases.js + * region_tag:cloudsupport_v2_generated_CaseService_SearchCases_async + */ searchCasesAsync( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases iterate %j', request); return this.descriptors.page.searchCases.asyncIterate( this.innerApiCalls['searchCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Retrieve valid classifications to use when creating a support case. - * - * Classifications are hierarchical. Each classification is a string - * containing all levels of the hierarchy separated by `" > "`. For example, - * `"Technical Issue > Compute > Compute Engine"`. - * - * Classification IDs returned by this endpoint are valid for at least six - * months. When a classification is deactivated, this endpoint immediately - * stops returning it. After six months, `case.create` requests using the - * classification will fail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve valid classifications to use when creating a support case. + * + * Classifications are hierarchical. Each classification is a string + * containing all levels of the hierarchy separated by `" > "`. For example, + * `"Technical Issue > Compute > Compute Engine"`. + * + * Classification IDs returned by this endpoint are valid for at least six + * months. When a classification is deactivated, this endpoint immediately + * stops returning it. After six months, `case.create` requests using the + * classification will fail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassifications( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]>; + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ] + >; searchCaseClassifications( - request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): void; + request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): void; searchCaseClassifications( - request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): void; + request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): void; searchCaseClassifications( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>, - callback?: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): - Promise<[ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]>|void { + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCaseClassifications values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1503,104 +1786,110 @@ export class CaseServiceClient { this._log.info('searchCaseClassifications request %j', request); return this.innerApiCalls .searchCaseClassifications(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]) => { - this._log.info('searchCaseClassifications values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ]) => { + this._log.info('searchCaseClassifications values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassificationsStream( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications stream %j', request); return this.descriptors.page.searchCaseClassifications.createStream( this.innerApiCalls.searchCaseClassifications as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCaseClassifications`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/case_service.search_case_classifications.js - * region_tag:cloudsupport_v2_generated_CaseService_SearchCaseClassifications_async - */ + /** + * Equivalent to `searchCaseClassifications`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2.CaseClassification|CaseClassification}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/case_service.search_case_classifications.js + * region_tag:cloudsupport_v2_generated_CaseService_SearchCaseClassifications_async + */ searchCaseClassificationsAsync( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications iterate %j', request); return this.descriptors.page.searchCaseClassifications.asyncIterate( this.innerApiCalls['searchCaseClassifications'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1613,7 +1902,7 @@ export class CaseServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationPath(organization:string) { + organizationPath(organization: string) { return this.pathTemplates.organizationPathTemplate.render({ organization: organization, }); @@ -1627,7 +1916,8 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + return this.pathTemplates.organizationPathTemplate.match(organizationName) + .organization; } /** @@ -1637,7 +1927,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -1652,7 +1942,9 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -1663,7 +1955,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -1674,7 +1968,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -1689,8 +1987,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -1700,8 +2002,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -1711,8 +2017,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -1723,7 +2033,11 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -1738,8 +2052,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -1749,8 +2067,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -1760,8 +2082,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -1771,7 +2097,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -1786,7 +2112,8 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -1797,7 +2124,8 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -1808,7 +2136,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -1823,8 +2155,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1834,8 +2170,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1845,8 +2185,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1857,7 +2201,7 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1873,7 +2217,9 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1884,7 +2230,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1895,7 +2243,9 @@ export class CaseServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1906,7 +2256,7 @@ export class CaseServiceClient { */ close(): Promise { if (this.caseServiceStub && !this._terminated) { - return this.caseServiceStub.then(stub => { + return this.caseServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1914,4 +2264,4 @@ export class CaseServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/comment_service_client.ts b/packages/google-cloud-support/src/v2/comment_service_client.ts index b4c4c5842144..2ea0105bf114 100644 --- a/packages/google-cloud-support/src/v2/comment_service_client.ts +++ b/packages/google-cloud-support/src/v2/comment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CommentServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CommentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - commentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + commentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CommentServiceClient. @@ -100,21 +107,42 @@ export class CommentServiceClient { * const client = new CommentServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CommentServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +167,7 @@ export class CommentServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +181,7 @@ export class CommentServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,22 +203,23 @@ export class CommentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -201,14 +227,20 @@ export class CommentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listComments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'comments') + listComments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'comments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CommentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CommentService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -239,37 +271,44 @@ export class CommentServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CommentService. this.commentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CommentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CommentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CommentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const commentServiceStubMethods = - ['listComments', 'createComment']; + const commentServiceStubMethods = [ + 'listComments', + 'createComment', + 'getComment', + ]; for (const methodName of commentServiceStubMethods) { const callPromise = this.commentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -284,8 +323,14 @@ export class CommentServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -296,8 +341,14 @@ export class CommentServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -328,9 +379,7 @@ export class CommentServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -339,8 +388,9 @@ export class CommentServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -351,187 +401,393 @@ export class CommentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Add a new comment to a case. - * - * The comment must have the following fields set: `body`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case to which the comment should be added. - * @param {google.cloud.support.v2.Comment} request.comment - * Required. The comment to be added. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Comment|Comment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2/comment_service.create_comment.js - * region_tag:cloudsupport_v2_generated_CommentService_CreateComment_async - */ + /** + * Add a new comment to a case. + * + * The comment must have the following fields set: `body`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case to which the comment should be added. + * @param {google.cloud.support.v2.Comment} request.comment + * Required. The comment to be added. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/comment_service.create_comment.js + * region_tag:cloudsupport_v2_generated_CommentService_CreateComment_async + */ createComment( - request?: protos.google.cloud.support.v2.ICreateCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICreateCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ] + >; createComment( - request: protos.google.cloud.support.v2.ICreateCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; createComment( - request: protos.google.cloud.support.v2.ICreateCommentRequest, - callback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCommentRequest, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; createComment( - request?: protos.google.cloud.support.v2.ICreateCommentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.ICreateCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.IComment, + | protos.google.cloud.support.v2.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('createComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); + } + throw error; + }); + } + /** + * Retrieve a comment. + * + * EXAMPLES: + * + * cURL: + * + * ```shell + * comment="projects/some-project/cases/43595344/comments/234567890" + * curl \ + * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ + * "https://cloudsupport.googleapis.com/v2/$comment" + * ``` + * + * Python: + * + * ```python + * import googleapiclient.discovery + * + * api_version = "v2" + * supportApiService = googleapiclient.discovery.build( + * serviceName="cloudsupport", + * version=api_version, + * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", + * ) + * + * request = supportApiService.cases().comments().get( + * name="projects/some-project/cases/43595344/comments/234567890", + * ) + * print(request.execute()) + * ``` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the comment to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2/comment_service.get_comment.js + * region_tag:cloudsupport_v2_generated_CommentService_GetComment_async + */ + getComment( + request?: protos.google.cloud.support.v2.IGetCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | undefined, + {} | undefined, + ] + >; + getComment( + request: protos.google.cloud.support.v2.IGetCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; + getComment( + request: protos.google.cloud.support.v2.IGetCommentRequest, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; + getComment( + request?: protos.google.cloud.support.v2.IGetCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; + }); + this._log.info('getComment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getComment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.IGetCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * List all the comments associated with a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2.Comment|Comment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCommentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List all the comments associated with a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2.Comment|Comment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listComments( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]>; + request?: protos.google.cloud.support.v2.IListCommentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ] + >; listComments( - request: protos.google.cloud.support.v2.IListCommentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): void; + request: protos.google.cloud.support.v2.IListCommentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): void; listComments( - request: protos.google.cloud.support.v2.IListCommentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): void; + request: protos.google.cloud.support.v2.IListCommentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): void; listComments( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListCommentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): - Promise<[ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]>|void { + | protos.google.cloud.support.v2.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IComment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): Promise< + [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + | protos.google.cloud.support.v2.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IComment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listComments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -540,108 +796,112 @@ export class CommentServiceClient { this._log.info('listComments request %j', request); return this.innerApiCalls .listComments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]) => { - this._log.info('listComments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ]) => { + this._log.info('listComments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listComments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Comment|Comment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCommentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listComments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2.Comment|Comment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCommentsStream( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListCommentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments stream %j', request); return this.descriptors.page.listComments.createStream( this.innerApiCalls.listComments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listComments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2.Comment|Comment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2/comment_service.list_comments.js - * region_tag:cloudsupport_v2_generated_CommentService_ListComments_async - */ + /** + * Equivalent to `listComments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2.Comment|Comment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2/comment_service.list_comments.js + * region_tag:cloudsupport_v2_generated_CommentService_ListComments_async + */ listCommentsAsync( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListCommentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments iterate %j', request); return this.descriptors.page.listComments.asyncIterate( this.innerApiCalls['listComments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -655,7 +915,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -670,7 +930,9 @@ export class CommentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -681,7 +943,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -692,7 +956,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -707,8 +975,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -718,8 +990,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -729,8 +1005,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -741,7 +1021,11 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -756,8 +1040,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -767,8 +1055,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -778,8 +1070,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -789,7 +1085,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -804,7 +1100,8 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -815,7 +1112,8 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -826,7 +1124,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -841,8 +1143,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -852,8 +1158,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -863,8 +1173,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -875,7 +1189,7 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -891,7 +1205,9 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -902,7 +1218,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -913,7 +1231,9 @@ export class CommentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -924,7 +1244,7 @@ export class CommentServiceClient { */ close(): Promise { if (this.commentServiceStub && !this._terminated) { - return this.commentServiceStub.then(stub => { + return this.commentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -932,4 +1252,4 @@ export class CommentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/comment_service_client_config.json b/packages/google-cloud-support/src/v2/comment_service_client_config.json index addf5b5e654d..46b5baec1ba5 100644 --- a/packages/google-cloud-support/src/v2/comment_service_client_config.json +++ b/packages/google-cloud-support/src/v2/comment_service_client_config.json @@ -41,6 +41,10 @@ "timeout_millis": 60000, "retry_codes_name": "non_idempotent", "retry_params_name": "default" + }, + "GetComment": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" } } } diff --git a/packages/google-cloud-support/src/v2/gapic_metadata.json b/packages/google-cloud-support/src/v2/gapic_metadata.json index 7bb73a8fbd4e..55f6d2f6051a 100644 --- a/packages/google-cloud-support/src/v2/gapic_metadata.json +++ b/packages/google-cloud-support/src/v2/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "CaseAttachmentServiceClient", "rpcs": { + "GetAttachment": { + "methods": [ + "getAttachment" + ] + }, "ListAttachments": { "methods": [ "listAttachments", @@ -22,6 +27,11 @@ "grpc-fallback": { "libraryClient": "CaseAttachmentServiceClient", "rpcs": { + "GetAttachment": { + "methods": [ + "getAttachment" + ] + }, "ListAttachments": { "methods": [ "listAttachments", @@ -149,6 +159,11 @@ "createComment" ] }, + "GetComment": { + "methods": [ + "getComment" + ] + }, "ListComments": { "methods": [ "listComments", @@ -166,6 +181,11 @@ "createComment" ] }, + "GetComment": { + "methods": [ + "getComment" + ] + }, "ListComments": { "methods": [ "listComments", diff --git a/packages/google-cloud-support/src/v2/index.ts b/packages/google-cloud-support/src/v2/index.ts index adc3d2e7e29f..20adebd968ff 100644 --- a/packages/google-cloud-support/src/v2/index.ts +++ b/packages/google-cloud-support/src/v2/index.ts @@ -16,6 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CaseAttachmentServiceClient} from './case_attachment_service_client'; -export {CaseServiceClient} from './case_service_client'; -export {CommentServiceClient} from './comment_service_client'; +export { CaseAttachmentServiceClient } from './case_attachment_service_client'; +export { CaseServiceClient } from './case_service_client'; +export { CommentServiceClient } from './comment_service_client'; diff --git a/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts b/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts index c26d85e72bcd..5dfa564cd187 100644 --- a/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CaseAttachmentServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CaseAttachmentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseAttachmentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseAttachmentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseAttachmentServiceClient. @@ -100,21 +107,43 @@ export class CaseAttachmentServiceClient { * const client = new CaseAttachmentServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof CaseAttachmentServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + const staticMembers = this + .constructor as typeof CaseAttachmentServiceClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +168,7 @@ export class CaseAttachmentServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +182,7 @@ export class CaseAttachmentServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,28 +204,30 @@ export class CaseAttachmentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +235,20 @@ export class CaseAttachmentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAttachments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attachments') + listAttachments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'attachments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CaseAttachmentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CaseAttachmentService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -245,37 +279,44 @@ export class CaseAttachmentServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CaseAttachmentService. this.caseAttachmentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CaseAttachmentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.support.v2beta.CaseAttachmentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CaseAttachmentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.support.v2beta + .CaseAttachmentService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const caseAttachmentServiceStubMethods = - ['listAttachments', 'getAttachment']; + const caseAttachmentServiceStubMethods = [ + 'listAttachments', + 'getAttachment', + ]; for (const methodName of caseAttachmentServiceStubMethods) { const callPromise = this.caseAttachmentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -290,8 +331,14 @@ export class CaseAttachmentServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -302,8 +349,14 @@ export class CaseAttachmentServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -334,9 +387,7 @@ export class CaseAttachmentServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -345,8 +396,9 @@ export class CaseAttachmentServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -357,190 +409,255 @@ export class CaseAttachmentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve an attachment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the attachment to get. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_attachment_service.get_attachment.js - * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_GetAttachment_async - */ + /** + * Retrieve an attachment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the attachment to get. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_attachment_service.get_attachment.js + * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_GetAttachment_async + */ getAttachment( - request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ] + >; getAttachment( - request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachment( - request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachment( - request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getAttachment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAttachment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAttachment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAttachment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAttachment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAttachment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * List all the attachments associated with a support case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAttachmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List all the attachments associated with a support case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachments( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ] + >; listAttachments( - request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): void; + request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): void; listAttachments( - request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): void; + request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): void; listAttachments( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAttachments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -549,122 +666,126 @@ export class CaseAttachmentServiceClient { this._log.info('listAttachments request %j', request); return this.innerApiCalls .listAttachments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]) => { - this._log.info('listAttachments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ]) => { + this._log.info('listAttachments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAttachments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Attachment|Attachment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAttachmentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listAttachments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Attachment|Attachment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachmentsStream( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments stream %j', request); return this.descriptors.page.listAttachments.createStream( this.innerApiCalls.listAttachments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAttachments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_attachment_service.list_attachments.js - * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_ListAttachments_async - */ + /** + * Equivalent to `listAttachments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.Attachment|Attachment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_attachment_service.list_attachments.js + * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_ListAttachments_async + */ listAttachmentsAsync( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments iterate %j', request); return this.descriptors.page.listAttachments.asyncIterate( this.innerApiCalls['listAttachments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -678,7 +799,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -693,7 +814,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -704,7 +827,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -715,7 +840,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -730,8 +859,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -741,8 +874,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -752,8 +889,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -764,7 +905,11 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -779,8 +924,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -790,8 +939,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -801,8 +954,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -813,7 +970,11 @@ export class CaseAttachmentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -828,8 +989,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -839,8 +1004,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -850,8 +1019,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -861,7 +1034,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -876,7 +1049,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -887,7 +1061,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -898,7 +1073,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -913,8 +1092,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -924,8 +1107,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -935,8 +1122,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -947,7 +1138,7 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -963,7 +1154,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -974,7 +1167,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -985,7 +1180,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -996,7 +1193,11 @@ export class CaseAttachmentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1011,8 +1212,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -1022,8 +1227,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -1033,8 +1242,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -1045,7 +1258,7 @@ export class CaseAttachmentServiceClient { */ close(): Promise { if (this.caseAttachmentServiceStub && !this._terminated) { - return this.caseAttachmentServiceStub.then(stub => { + return this.caseAttachmentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1053,4 +1266,4 @@ export class CaseAttachmentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/case_service_client.ts b/packages/google-cloud-support/src/v2beta/case_service_client.ts index 7e0db96918ed..bd2ce828d186 100644 --- a/packages/google-cloud-support/src/v2beta/case_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/case_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CaseServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CaseServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseServiceClient. @@ -100,21 +107,42 @@ export class CaseServiceClient { * const client = new CaseServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CaseServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +167,7 @@ export class CaseServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +181,7 @@ export class CaseServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,31 +203,33 @@ export class CaseServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' + 'organizations/{organization}', ), organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -210,18 +237,30 @@ export class CaseServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCaseClassifications: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'caseClassifications') + listCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCaseClassifications: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'caseClassifications', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CaseService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CaseService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -252,37 +291,49 @@ export class CaseServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CaseService. this.caseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CaseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CaseService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.CaseService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const caseServiceStubMethods = - ['getCase', 'listCases', 'searchCases', 'createCase', 'updateCase', 'escalateCase', 'closeCase', 'searchCaseClassifications']; + const caseServiceStubMethods = [ + 'getCase', + 'listCases', + 'searchCases', + 'createCase', + 'updateCase', + 'escalateCase', + 'closeCase', + 'searchCaseClassifications', + ]; for (const methodName of caseServiceStubMethods) { const callPromise = this.caseServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -297,8 +348,14 @@ export class CaseServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -309,8 +366,14 @@ export class CaseServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -341,9 +404,7 @@ export class CaseServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -352,8 +413,9 @@ export class CaseServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -364,609 +426,800 @@ export class CaseServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of a case to be retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.get_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_GetCase_async - */ + /** + * Retrieve a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of a case to be retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.get_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_GetCase_async + */ getCase( - request?: protos.google.cloud.support.v2beta.IGetCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ] + >; getCase( - request: protos.google.cloud.support.v2beta.IGetCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request: protos.google.cloud.support.v2beta.IGetCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request?: protos.google.cloud.support.v2beta.IGetCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Create a new case and associate it with a parent. - * - * It must have the following fields set: `display_name`, `description`, - * `classification`, and `priority`. If you're just testing the API and don't - * want to route your case to an agent, set `testCase=true`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent under which the case should be created. - * @param {google.cloud.support.v2beta.Case} request.case - * Required. The case to be created. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.create_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_CreateCase_async - */ + /** + * Create a new case and associate it with a parent. + * + * It must have the following fields set: `display_name`, `description`, + * `classification`, and `priority`. If you're just testing the API and don't + * want to route your case to an agent, set `testCase=true`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent under which the case should be created. + * @param {google.cloud.support.v2beta.Case} request.case + * Required. The case to be created. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.create_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_CreateCase_async + */ createCase( - request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ] + >; createCase( - request: protos.google.cloud.support.v2beta.ICreateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request: protos.google.cloud.support.v2beta.ICreateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICreateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.ICreateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Update a case. Only some fields can be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.support.v2beta.Case} request.case - * Required. The case to update. - * @param {google.protobuf.FieldMask} request.updateMask - * A list of attributes of the case that should be updated. Supported values - * are `priority`, `display_name`, and `subscriber_email_addresses`. If no - * fields are specified, all supported fields are updated. - * - * Be careful - if you do not provide a field mask, then you might - * accidentally clear some fields. For example, if you leave the field mask - * empty and do not provide a value for `subscriber_email_addresses`, then - * `subscriber_email_addresses` is updated to empty. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.update_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_UpdateCase_async - */ + /** + * Update a case. Only some fields can be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.support.v2beta.Case} request.case + * Required. The case to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A list of attributes of the case that should be updated. Supported values + * are `priority`, `display_name`, and `subscriber_email_addresses`. If no + * fields are specified, all supported fields are updated. + * + * Be careful - if you do not provide a field mask, then you might + * accidentally clear some fields. For example, if you leave the field mask + * empty and do not provide a value for `subscriber_email_addresses`, then + * `subscriber_email_addresses` is updated to empty. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.update_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_UpdateCase_async + */ updateCase( - request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ] + >; updateCase( - request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IUpdateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'case.name': request.case!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'case.name': request.case!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IUpdateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Escalate a case, starting the Google Cloud Support escalation management - * process. - * - * This operation is only available for some support services. Go to - * https://cloud.google.com/support and look for 'Technical support - * escalations' in the feature list to find out which ones let you - * do that. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to be escalated. - * @param {google.cloud.support.v2beta.Escalation} request.escalation - * The escalation information to be sent with the escalation request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.escalate_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_EscalateCase_async - */ + /** + * Escalate a case, starting the Google Cloud Support escalation management + * process. + * + * This operation is only available for some support services. Go to + * https://cloud.google.com/support and look for 'Technical support + * escalations' in the feature list to find out which ones let you + * do that. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to be escalated. + * @param {google.cloud.support.v2beta.Escalation} request.escalation + * The escalation information to be sent with the escalation request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.escalate_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_EscalateCase_async + */ escalateCase( - request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ] + >; escalateCase( - request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('escalateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('escalateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.escalateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('escalateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .escalateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('escalateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Close a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to close. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.close_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_CloseCase_async - */ + /** + * Close a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to close. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.close_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_CloseCase_async + */ closeCase( - request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ] + >; closeCase( - request: protos.google.cloud.support.v2beta.ICloseCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICloseCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request: protos.google.cloud.support.v2beta.ICloseCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICloseCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICloseCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('closeCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.ICloseCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('closeCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.closeCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('closeCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .closeCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('closeCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * Retrieve all cases under a parent, but not its children. - * - * For example, listing cases under an organization only returns the cases - * that are directly parented by that organization. To retrieve cases - * under an organization and its projects, use `cases.search`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases will be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Case|Case}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve all cases under a parent, but not its children. + * + * For example, listing cases under an organization only returns the cases + * that are directly parented by that organization. To retrieve cases + * under an organization and its projects, use `cases.search`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases will be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Case|Case}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCases( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ] + >; listCases( - request: protos.google.cloud.support.v2beta.IListCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.IListCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; listCases( - request: protos.google.cloud.support.v2beta.IListCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.IListCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; listCases( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + | protos.google.cloud.support.v2beta.IListCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -975,272 +1228,301 @@ export class CaseServiceClient { this._log.info('listCases request %j', request); return this.innerApiCalls .listCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]) => { - this._log.info('listCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ]) => { + this._log.info('listCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases will be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Case|Case} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases will be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Case|Case} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCasesStream( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases stream %j', request); return this.descriptors.page.listCases.createStream( this.innerApiCalls.listCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases will be returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.Case|Case}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.list_cases.js - * region_tag:cloudsupport_v2beta_generated_CaseService_ListCases_async - */ + /** + * Equivalent to `listCases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases will be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.Case|Case}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.list_cases.js + * region_tag:cloudsupport_v2beta_generated_CaseService_ListCases_async + */ listCasesAsync( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases iterate %j', request); return this.descriptors.page.listCases.asyncIterate( this.innerApiCalls['listCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Search for cases using a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Case|Case}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Search for cases using a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Case|Case}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCases( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]>; + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ] + >; searchCases( - request: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; searchCases( - request: protos.google.cloud.support.v2beta.ISearchCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.ISearchCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; searchCases( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]>|void { + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1249,269 +1531,299 @@ export class CaseServiceClient { this._log.info('searchCases request %j', request); return this.innerApiCalls .searchCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]) => { - this._log.info('searchCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ]) => { + this._log.info('searchCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Case|Case} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `searchCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Case|Case} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCasesStream( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases stream %j', request); return this.descriptors.page.searchCases.createStream( this.innerApiCalls.searchCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCases`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.Case|Case}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.search_cases.js - * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCases_async - */ + /** + * Equivalent to `searchCases`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.Case|Case}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.search_cases.js + * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCases_async + */ searchCasesAsync( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases iterate %j', request); return this.descriptors.page.searchCases.asyncIterate( this.innerApiCalls['searchCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Retrieve valid classifications to use when creating a support case. - * - * Classifications are hierarchical. Each classification is a string - * containing all levels of the hierarchy separated by `" > "`. For example, - * `"Technical Issue > Compute > Compute Engine"`. - * - * Classification IDs returned by this endpoint are valid for at least six - * months. When a classification is deactivated, this endpoint immediately - * stops returning it. After six months, `case.create` requests using the - * classification will fail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve valid classifications to use when creating a support case. + * + * Classifications are hierarchical. Each classification is a string + * containing all levels of the hierarchy separated by `" > "`. For example, + * `"Technical Issue > Compute > Compute Engine"`. + * + * Classification IDs returned by this endpoint are valid for at least six + * months. When a classification is deactivated, this endpoint immediately + * stops returning it. After six months, `case.create` requests using the + * classification will fail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassifications( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]>; + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ] + >; searchCaseClassifications( - request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): void; + request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): void; searchCaseClassifications( - request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): void; + request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): void; searchCaseClassifications( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): - Promise<[ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]>|void { + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCaseClassifications values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1520,108 +1832,114 @@ export class CaseServiceClient { this._log.info('searchCaseClassifications request %j', request); return this.innerApiCalls .searchCaseClassifications(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]) => { - this._log.info('searchCaseClassifications values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ]) => { + this._log.info('searchCaseClassifications values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassificationsStream( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications stream %j', request); return this.descriptors.page.searchCaseClassifications.createStream( this.innerApiCalls.searchCaseClassifications as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCaseClassifications`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.search_case_classifications.js - * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCaseClassifications_async - */ + /** + * Equivalent to `searchCaseClassifications`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.CaseClassification|CaseClassification}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.search_case_classifications.js + * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCaseClassifications_async + */ searchCaseClassificationsAsync( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications iterate %j', request); return this.descriptors.page.searchCaseClassifications.asyncIterate( this.innerApiCalls['searchCaseClassifications'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1634,7 +1952,7 @@ export class CaseServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationPath(organization:string) { + organizationPath(organization: string) { return this.pathTemplates.organizationPathTemplate.render({ organization: organization, }); @@ -1648,7 +1966,8 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + return this.pathTemplates.organizationPathTemplate.match(organizationName) + .organization; } /** @@ -1658,7 +1977,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -1673,7 +1992,9 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -1684,7 +2005,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -1695,7 +2018,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -1710,8 +2037,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -1721,8 +2052,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -1732,8 +2067,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -1744,7 +2083,11 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -1759,8 +2102,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -1770,8 +2117,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -1781,8 +2132,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -1793,7 +2148,11 @@ export class CaseServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -1808,8 +2167,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -1819,8 +2182,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -1830,8 +2197,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -1841,7 +2212,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -1856,7 +2227,8 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -1867,7 +2239,8 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -1878,7 +2251,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -1893,8 +2270,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1904,8 +2285,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1915,8 +2300,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1927,7 +2316,7 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1943,7 +2332,9 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1954,7 +2345,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1965,7 +2358,9 @@ export class CaseServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1976,7 +2371,11 @@ export class CaseServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1991,8 +2390,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -2002,8 +2405,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -2013,8 +2420,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -2025,7 +2436,7 @@ export class CaseServiceClient { */ close(): Promise { if (this.caseServiceStub && !this._terminated) { - return this.caseServiceStub.then(stub => { + return this.caseServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2033,4 +2444,4 @@ export class CaseServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/comment_service_client.ts b/packages/google-cloud-support/src/v2beta/comment_service_client.ts index f7c02630c2ca..72c309a57154 100644 --- a/packages/google-cloud-support/src/v2beta/comment_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/comment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class CommentServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class CommentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - commentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + commentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CommentServiceClient. @@ -100,21 +107,42 @@ export class CommentServiceClient { * const client = new CommentServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof CommentServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +167,7 @@ export class CommentServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +181,7 @@ export class CommentServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,28 +203,30 @@ export class CommentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +234,20 @@ export class CommentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listComments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'comments') + listComments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'comments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CommentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CommentService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -245,37 +278,44 @@ export class CommentServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CommentService. this.commentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CommentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CommentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.CommentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const commentServiceStubMethods = - ['listComments', 'createComment', 'getComment']; + const commentServiceStubMethods = [ + 'listComments', + 'createComment', + 'getComment', + ]; for (const methodName of commentServiceStubMethods) { const callPromise = this.commentServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -290,8 +330,14 @@ export class CommentServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -302,8 +348,14 @@ export class CommentServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -334,9 +386,7 @@ export class CommentServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -345,8 +395,9 @@ export class CommentServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -357,281 +408,380 @@ export class CommentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Add a new comment to a case. - * - * The comment must have the following fields set: `body`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case to which the comment should be added. - * @param {google.cloud.support.v2beta.Comment} request.comment - * Required. The comment to be added. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/comment_service.create_comment.js - * region_tag:cloudsupport_v2beta_generated_CommentService_CreateComment_async - */ + /** + * Add a new comment to a case. + * + * The comment must have the following fields set: `body`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case to which the comment should be added. + * @param {google.cloud.support.v2beta.Comment} request.comment + * Required. The comment to be added. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/comment_service.create_comment.js + * region_tag:cloudsupport_v2beta_generated_CommentService_CreateComment_async + */ createComment( - request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ] + >; createComment( - request: protos.google.cloud.support.v2beta.ICreateCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createComment( - request: protos.google.cloud.support.v2beta.ICreateCommentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCommentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createComment( - request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('createComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Retrieve a comment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the comment to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/comment_service.get_comment.js - * region_tag:cloudsupport_v2beta_generated_CommentService_GetComment_async - */ + /** + * Retrieve a comment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the comment to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/comment_service.get_comment.js + * region_tag:cloudsupport_v2beta_generated_CommentService_GetComment_async + */ getComment( - request?: protos.google.cloud.support.v2beta.IGetCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ] + >; getComment( - request: protos.google.cloud.support.v2beta.IGetCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; getComment( - request: protos.google.cloud.support.v2beta.IGetCommentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCommentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; getComment( - request?: protos.google.cloud.support.v2beta.IGetCommentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IGetCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.IGetCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * List all the comments associated with a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Comment|Comment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCommentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * List all the comments associated with a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.Comment|Comment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listComments( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ] + >; listComments( - request: protos.google.cloud.support.v2beta.IListCommentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): void; + request: protos.google.cloud.support.v2beta.IListCommentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): void; listComments( - request: protos.google.cloud.support.v2beta.IListCommentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): void; + request: protos.google.cloud.support.v2beta.IListCommentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): void; listComments( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): - Promise<[ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listComments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -640,108 +790,112 @@ export class CommentServiceClient { this._log.info('listComments request %j', request); return this.innerApiCalls .listComments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]) => { - this._log.info('listComments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ]) => { + this._log.info('listComments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listComments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCommentsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listComments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCommentsStream( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments stream %j', request); return this.descriptors.page.listComments.createStream( this.innerApiCalls.listComments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listComments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is returned. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.Comment|Comment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/comment_service.list_comments.js - * region_tag:cloudsupport_v2beta_generated_CommentService_ListComments_async - */ + /** + * Equivalent to `listComments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.Comment|Comment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/comment_service.list_comments.js + * region_tag:cloudsupport_v2beta_generated_CommentService_ListComments_async + */ listCommentsAsync( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments iterate %j', request); return this.descriptors.page.listComments.asyncIterate( this.innerApiCalls['listComments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -755,7 +909,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -770,7 +924,9 @@ export class CommentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -781,7 +937,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -792,7 +950,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -807,8 +969,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -818,8 +984,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -829,8 +999,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -841,7 +1015,11 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -856,8 +1034,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -867,8 +1049,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -878,8 +1064,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -890,7 +1080,11 @@ export class CommentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -905,8 +1099,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -916,8 +1114,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -927,8 +1129,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -938,7 +1144,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -953,7 +1159,8 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -964,7 +1171,8 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -975,7 +1183,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -990,8 +1202,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1001,8 +1217,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1012,8 +1232,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1024,7 +1248,7 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1040,7 +1264,9 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1051,7 +1277,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1062,7 +1290,9 @@ export class CommentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1073,7 +1303,11 @@ export class CommentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1088,8 +1322,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -1099,8 +1337,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -1110,8 +1352,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -1122,7 +1368,7 @@ export class CommentServiceClient { */ close(): Promise { if (this.commentServiceStub && !this._terminated) { - return this.commentServiceStub.then(stub => { + return this.commentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1130,4 +1376,4 @@ export class CommentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/feed_service_client.ts b/packages/google-cloud-support/src/v2beta/feed_service_client.ts index 94bcb6de26dc..5853c96a8ce7 100644 --- a/packages/google-cloud-support/src/v2beta/feed_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/feed_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -44,7 +51,7 @@ export class FeedServiceClient { private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; + private _defaults: { [method: string]: gax.CallSettings }; private _universeDomain: string; private _servicePath: string; private _log = logging.log('support'); @@ -57,9 +64,9 @@ export class FeedServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - feedServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + feedServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of FeedServiceClient. @@ -100,21 +107,42 @@ export class FeedServiceClient { * const client = new FeedServiceClient({fallback: true}, gax); * ``` */ - constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback, + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof FeedServiceClient; - if (opts?.universe_domain && opts?.universeDomain && opts?.universe_domain !== opts?.universeDomain) { - throw new Error('Please set either universe_domain or universeDomain, but not both.'); + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); } - const universeDomainEnvVar = (typeof process === 'object' && typeof process.env === 'object') ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] : undefined; - this._universeDomain = opts?.universeDomain ?? opts?.universe_domain ?? universeDomainEnvVar ?? 'googleapis.com'; + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; this._servicePath = 'cloudsupport.' + this._universeDomain; - const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts); // Request numeric enum values if REST transport is used. opts.numericEnums = true; @@ -139,7 +167,7 @@ export class FeedServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -153,10 +181,7 @@ export class FeedServiceClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -178,28 +203,30 @@ export class FeedServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +234,20 @@ export class FeedServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - showFeed: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'feedItems') + showFeed: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'feedItems', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.FeedService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.FeedService', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -245,37 +278,40 @@ export class FeedServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.FeedService. this.feedServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.FeedService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.FeedService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.FeedService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const feedServiceStubMethods = - ['showFeed']; + const feedServiceStubMethods = ['showFeed']; for (const methodName of feedServiceStubMethods) { const callPromise = this.feedServiceStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); - const descriptor = - this.descriptors.page[methodName] || - undefined; + const descriptor = this.descriptors.page[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -290,8 +326,14 @@ export class FeedServiceClient { * @returns {string} The DNS address for this service. */ static get servicePath() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -302,8 +344,14 @@ export class FeedServiceClient { * @returns {string} The DNS address for this service. */ static get apiEndpoint() { - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); } return 'cloudsupport.googleapis.com'; } @@ -334,9 +382,7 @@ export class FeedServiceClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -345,8 +391,9 @@ export class FeedServiceClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -358,97 +405,116 @@ export class FeedServiceClient { // -- Service calls -- // ------------------- - /** - * Show items in the feed of this case, including case emails, - * attachments, and comments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `showFeedAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Show items in the feed of this case, including case emails, + * attachments, and comments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `showFeedAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showFeed( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]>; + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ] + >; showFeed( - request: protos.google.cloud.support.v2beta.IShowFeedRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): void; + request: protos.google.cloud.support.v2beta.IShowFeedRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): void; showFeed( - request: protos.google.cloud.support.v2beta.IShowFeedRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): void; + request: protos.google.cloud.support.v2beta.IShowFeedRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): void; showFeed( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): - Promise<[ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]>|void { + | protos.google.cloud.support.v2beta.IShowFeedResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + | protos.google.cloud.support.v2beta.IShowFeedResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IFeedItem + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('showFeed values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -457,124 +523,128 @@ export class FeedServiceClient { this._log.info('showFeed request %j', request); return this.innerApiCalls .showFeed(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]) => { - this._log.info('showFeed values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ]) => { + this._log.info('showFeed values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `showFeed`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `showFeedAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `showFeed`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `showFeedAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showFeedStream( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showFeed']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showFeed stream %j', request); return this.descriptors.page.showFeed.createStream( this.innerApiCalls.showFeed as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `showFeed`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/feed_service.show_feed.js - * region_tag:cloudsupport_v2beta_generated_FeedService_ShowFeed_async - */ + /** + * Equivalent to `showFeed`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.support.v2beta.FeedItem|FeedItem}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/feed_service.show_feed.js + * region_tag:cloudsupport_v2beta_generated_FeedService_ShowFeed_async + */ showFeedAsync( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['showFeed']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showFeed iterate %j', request); return this.descriptors.page.showFeed.asyncIterate( this.innerApiCalls['showFeed'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -588,7 +658,7 @@ export class FeedServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -603,7 +673,9 @@ export class FeedServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -614,7 +686,9 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -625,7 +699,11 @@ export class FeedServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -640,8 +718,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -651,8 +733,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -662,8 +748,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -674,7 +764,11 @@ export class FeedServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -689,8 +783,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -700,8 +798,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -711,8 +813,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -723,7 +829,11 @@ export class FeedServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -738,8 +848,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -749,8 +863,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -760,8 +878,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -771,7 +893,7 @@ export class FeedServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -786,7 +908,8 @@ export class FeedServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -797,7 +920,8 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -808,7 +932,11 @@ export class FeedServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -823,8 +951,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -834,8 +966,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -845,8 +981,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -857,7 +997,7 @@ export class FeedServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -873,7 +1013,9 @@ export class FeedServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -884,7 +1026,9 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -895,7 +1039,9 @@ export class FeedServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -906,7 +1052,11 @@ export class FeedServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -921,8 +1071,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -932,8 +1086,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -943,8 +1101,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -955,7 +1117,7 @@ export class FeedServiceClient { */ close(): Promise { if (this.feedServiceStub && !this._terminated) { - return this.feedServiceStub.then(stub => { + return this.feedServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -963,4 +1125,4 @@ export class FeedServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/index.ts b/packages/google-cloud-support/src/v2beta/index.ts index 987b0997e1a2..c9b650585797 100644 --- a/packages/google-cloud-support/src/v2beta/index.ts +++ b/packages/google-cloud-support/src/v2beta/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CaseAttachmentServiceClient} from './case_attachment_service_client'; -export {CaseServiceClient} from './case_service_client'; -export {CommentServiceClient} from './comment_service_client'; -export {FeedServiceClient} from './feed_service_client'; +export { CaseAttachmentServiceClient } from './case_attachment_service_client'; +export { CaseServiceClient } from './case_service_client'; +export { CommentServiceClient } from './comment_service_client'; +export { FeedServiceClient } from './feed_service_client'; diff --git a/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts index f3b5a06d0b38..5cfb2a310df6 100644 --- a/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,16 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CaseAttachmentServiceClient, CaseServiceClient, CommentServiceClient} from '@google-cloud/support'; +import { + CaseAttachmentServiceClient, + CaseServiceClient, + CommentServiceClient, +} from '@google-cloud/support'; // check that the client class type name can be used -function doStuffWithCaseAttachmentServiceClient(client: CaseAttachmentServiceClient) { +function doStuffWithCaseAttachmentServiceClient( + client: CaseAttachmentServiceClient, +) { client.close(); } function doStuffWithCaseServiceClient(client: CaseServiceClient) { diff --git a/packages/google-cloud-support/system-test/install.ts b/packages/google-cloud-support/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-support/system-test/install.ts +++ b/packages/google-cloud-support/system-test/install.ts @@ -16,34 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { + it('TypeScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }; await packNTest(options); }); - it('JavaScript code', async function() { + it('JavaScript code', async function () { this.timeout(300000); const options = { packageDir: process.cwd(), sample: { description: 'JavaScript user can use the library', - cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } + cjs: readFileSync( + './system-test/fixtures/sample/src/index.js', + ).toString(), + }, }; await packNTest(options); }); - }); diff --git a/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts b/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts index 8950d03df9ee..8b375062ba94 100644 --- a/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts @@ -19,751 +19,1192 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as caseattachmentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2.CaseAttachmentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient + .servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('has port', () => { - const port = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('should create a client with no option', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('should create a client with gRPC fallback', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universeDomain: 'configured.example.com', }); - assert(client); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - await client.initialize(); - assert(client.caseAttachmentServiceStub); + it('has port', () => { + const port = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseAttachmentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + await client.initialize(); + assert(client.caseAttachmentServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseAttachmentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); + + it('has close method for the non-initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); + }); - describe('listAttachments', () => { - it('invokes listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); - const [response] = await client.listAttachments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments without error using callback', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttachments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IAttachment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttachments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttachments(request), expectedError); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachmentsStream without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAttachmentsStream with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.IAttachment[] = []; - const iterable = client.listAttachmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + describe('getAttachment', () => { + it('invokes getAttachment without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Attachment(), + ); + client.innerApiCalls.getAttachment = stubSimpleCall(expectedResponse); + const [response] = await client.getAttachment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getAttachment without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Attachment(), + ); + client.innerApiCalls.getAttachment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttachment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IAttachment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttachmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.IAttachment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttachment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAttachment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment with closed client', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAttachment(request), expectedError); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('listAttachments', () => { + it('invokes listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); + const [response] = await client.listAttachments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachments without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.innerApiCalls.listAttachments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttachments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IAttachment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttachments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAttachments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachmentsStream without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listAttachmentsStream with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.IAttachment[] = []; + const iterable = client.listAttachmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttachmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.IAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts b/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts index cdb95eee4b21..4c25fa98a18f 100644 --- a/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts @@ -19,951 +19,1378 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as caseattachmentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2beta.CaseAttachmentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); - - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); - - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient + .servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('should create a client with no option', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - fallback: true, - }); - assert(client); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - await client.initialize(); - assert(client.caseAttachmentServiceStub); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has close method for the initialized client', done => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseAttachmentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('should create a client with no option', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('should create a client with gRPC fallback', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + fallback: true, }); + assert(client); }); - describe('getAttachment', () => { - it('invokes getAttachment without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Attachment() - ); - client.innerApiCalls.getAttachment = stubSimpleCall(expectedResponse); - const [response] = await client.getAttachment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment without error using callback', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Attachment() - ); - client.innerApiCalls.getAttachment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttachment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IAttachment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttachment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttachment(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment with closed client', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAttachment(request), expectedError); - }); - }); - - describe('listAttachments', () => { - it('invokes listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); - const [response] = await client.listAttachments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments without error using callback', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttachments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IAttachment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttachments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttachments(request), expectedError); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachmentsStream without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAttachmentsStream with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; - const iterable = client.listAttachmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttachmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + await client.initialize(); + assert(client.caseAttachmentServiceStub); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has close method for the initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseAttachmentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('has close method for the non-initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getAttachment', () => { + it('invokes getAttachment without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ); + client.innerApiCalls.getAttachment = stubSimpleCall(expectedResponse); + const [response] = await client.getAttachment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ); + client.innerApiCalls.getAttachment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttachment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IAttachment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getAttachment with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttachment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAttachment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment with closed client', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAttachment(request), expectedError); + }); + }); + + describe('listAttachments', () => { + it('invokes listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); + const [response] = await client.listAttachments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachments without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.innerApiCalls.listAttachments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttachments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IAttachment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttachments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAttachments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachmentsStream without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachmentsStream with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; + const iterable = client.listAttachmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttachmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_service_v2.ts b/packages/google-cloud-support/test/gapic_case_service_v2.ts index 791bd38a3921..a8199a7487ff 100644 --- a/packages/google-cloud-support/test/gapic_case_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_case_service_v2.ts @@ -19,1745 +19,2262 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as caseserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2.CaseServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = caseserviceModule.v2.CaseServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseserviceModule.v2.CaseServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseserviceModule.v2.CaseServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = caseserviceModule.v2.CaseServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = caseserviceModule.v2.CaseServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseserviceModule.v2.CaseServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseserviceModule.v2.CaseServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseserviceModule.v2.CaseServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new caseserviceModule.v2.CaseServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new caseserviceModule.v2.CaseServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = caseserviceModule.v2.CaseServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new caseserviceModule.v2.CaseServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('should create a client with no option', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseserviceModule.v2.CaseServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = caseserviceModule.v2.CaseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - await client.initialize(); - assert(client.caseServiceStub); - }); + it('should create a client with no option', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + await client.initialize(); + assert(client.caseServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the initialized client', (done) => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the non-initialized client', (done) => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCase', () => { - it('invokes getCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); - const [response] = await client.getCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.getCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getCase', () => { + it('invokes getCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); + const [response] = await client.getCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCase(request), expectedError); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.getCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCase(request), expectedError); - }); + it('invokes getCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCase(request), expectedError); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCase', () => { - it('invokes createCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); - const [response] = await client.createCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCase(request), expectedError); + }); + }); + + describe('createCase', () => { + it('invokes createCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); + const [response] = await client.createCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.createCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.createCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCase(request), expectedError); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCase(request), expectedError); - }); + it('invokes createCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCase(request), expectedError); + }); + }); + + describe('updateCase', () => { + it('invokes updateCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); + const [response] = await client.updateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCase', () => { - it('invokes updateCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); - const [response] = await client.updateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.updateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCase(request), expectedError); + }); + }); + + describe('escalateCase', () => { + it('invokes escalateCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); + const [response] = await client.escalateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCase(request), expectedError); - }); + it('invokes escalateCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.escalateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.escalateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('escalateCase', () => { - it('invokes escalateCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); - const [response] = await client.escalateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.escalateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.escalateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.escalateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.escalateCase(request), expectedError); + }); + }); + + describe('closeCase', () => { + it('invokes closeCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); + const [response] = await client.closeCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.escalateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.escalateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.closeCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.closeCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.escalateCase(request), expectedError); - }); + it('invokes closeCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.closeCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('closeCase', () => { - it('invokes closeCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); - const [response] = await client.closeCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.closeCase(request), expectedError); + }); + }); + + describe('listCases', () => { + it('invokes listCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); + const [response] = await client.listCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.closeCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.listCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.closeCase(request), expectedError); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.closeCase(request), expectedError); + it('invokes listCasesStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.listCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listCases', () => { - it('invokes listCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); - const [response] = await client.listCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes listCases without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCases(request), expectedError); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.listCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.listCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICase[] = []; + const iterable = client.listCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCases', () => { + it('invokes searchCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); + const [response] = await client.searchCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICase[] = []; - const iterable = client.listCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes searchCases without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.searchCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes searchCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchCases', () => { - it('invokes searchCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); - const [response] = await client.searchCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes searchCasesStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.searchCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes searchCases without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCases(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCasesStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes searchCasesStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes searchCasesStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICase[] = []; - const iterable = client.searchCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.searchCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICase[] = []; + const iterable = client.searchCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('searchCaseClassifications', () => { - it('invokes searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(expectedResponse); - const [response] = await client.searchCaseClassifications(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('uses async iteration with searchCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.searchCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCaseClassifications', () => { + it('invokes searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCall(expectedResponse); + const [response] = await client.searchCaseClassifications(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCaseClassifications( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICaseClassification[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCaseClassifications( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.support.v2.ICaseClassification[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCaseClassifications(request), expectedError); - }); + it('invokes searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchCaseClassifications = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.searchCaseClassifications(request), + expectedError, + ); + }); - it('invokes searchCaseClassificationsStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + it('invokes searchCaseClassificationsStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCaseClassificationsStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('uses async iteration with searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICaseClassification[] = []; - const iterable = client.searchCaseClassificationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('invokes searchCaseClassificationsStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCaseClassificationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICaseClassification[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); }); - describe('Path templates', () => { - - describe('organization', async () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICaseClassification[] = + []; + const iterable = client.searchCaseClassificationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCaseClassificationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICaseClassification[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('organization', async () => { + const fakePath = '/rendered/path/organization'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath('organizationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_service_v2beta.ts b/packages/google-cloud-support/test/gapic_case_service_v2beta.ts index 3ebffb51fb85..393f115a34dd 100644 --- a/packages/google-cloud-support/test/gapic_case_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_case_service_v2beta.ts @@ -19,1837 +19,2436 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as caseserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2beta.CaseServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = caseserviceModule.v2beta.CaseServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseserviceModule.v2beta.CaseServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('has universeDomain', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + caseserviceModule.v2beta.CaseServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseserviceModule.v2beta.CaseServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseserviceModule.v2beta.CaseServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new caseserviceModule.v2beta.CaseServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new caseserviceModule.v2beta.CaseServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('has port', () => { - const port = caseserviceModule.v2beta.CaseServiceClient.port; - assert(port); - assert(typeof port === 'number'); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new caseserviceModule.v2beta.CaseServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('should create a client with no option', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - assert(client); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('should create a client with gRPC fallback', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseserviceModule.v2beta.CaseServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - await client.initialize(); - assert(client.caseServiceStub); - }); + it('has port', () => { + const port = caseserviceModule.v2beta.CaseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + await client.initialize(); + assert(client.caseServiceStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the initialized client', (done) => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCase', () => { - it('invokes getCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); - const [response] = await client.getCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.getCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes getCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCase(request), expectedError); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('getCase', () => { + it('invokes getCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); + const [response] = await client.getCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCase(request), expectedError); - }); + it('invokes getCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.getCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCase', () => { - it('invokes createCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); - const [response] = await client.createCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCase(request), expectedError); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.createCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCase(request), expectedError); + }); + }); + + describe('createCase', () => { + it('invokes createCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); + const [response] = await client.createCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCase(request), expectedError); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.createCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCase(request), expectedError); - }); + it('invokes createCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCase', () => { - it('invokes updateCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); - const [response] = await client.updateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCase(request), expectedError); + }); + }); + + describe('updateCase', () => { + it('invokes updateCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); + const [response] = await client.updateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.updateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCase(request), expectedError); - }); + it('invokes updateCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCase(request), expectedError); + }); + }); + + describe('escalateCase', () => { + it('invokes escalateCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); + const [response] = await client.escalateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('escalateCase', () => { - it('invokes escalateCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); - const [response] = await client.escalateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.escalateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.escalateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.escalateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.escalateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.escalateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.escalateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.escalateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.escalateCase(request), expectedError); + }); + }); + + describe('closeCase', () => { + it('invokes closeCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); + const [response] = await client.closeCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.escalateCase(request), expectedError); - }); + it('invokes closeCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.closeCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.closeCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('closeCase', () => { - it('invokes closeCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); - const [response] = await client.closeCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.closeCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.closeCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.closeCase(request), expectedError); + }); + }); + + describe('listCases', () => { + it('invokes listCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); + const [response] = await client.listCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.closeCase(request), expectedError); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.listCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.closeCase(request), expectedError); - }); + it('invokes listCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCases', () => { - it('invokes listCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); - const [response] = await client.listCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.listCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCases without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCases(request), expectedError); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCasesStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.listCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.listCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + const iterable = client.listCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - const iterable = client.listCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCases', () => { + it('invokes searchCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); + const [response] = await client.searchCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes searchCases without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.searchCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchCases', () => { - it('invokes searchCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); - const [response] = await client.searchCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchCases without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes searchCasesStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.searchCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCases(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCasesStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes searchCasesStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCasesStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - const iterable = client.searchCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.searchCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + const iterable = client.searchCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.searchCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCaseClassifications', () => { + it('invokes searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCall(expectedResponse); + const [response] = await client.searchCaseClassifications(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('searchCaseClassifications', () => { - it('invokes searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(expectedResponse); - const [response] = await client.searchCaseClassifications(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCaseClassifications( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.support.v2beta.ICaseClassification[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCaseClassifications( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICaseClassification[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchCaseClassifications = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.searchCaseClassifications(request), + expectedError, + ); + }); - it('invokes searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCaseClassifications(request), expectedError); + it('invokes searchCaseClassificationsStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCaseClassificationsStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('invokes searchCaseClassificationsStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + it('invokes searchCaseClassificationsStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = []; - const iterable = client.searchCaseClassificationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('uses async iteration with searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCaseClassificationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + it('uses async iteration with searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = + []; + const iterable = client.searchCaseClassificationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); }); - describe('Path templates', () => { - - describe('organization', async () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCaseClassificationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('organization', async () => { + const fakePath = '/rendered/path/organization'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath('organizationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_comment_service_v2.ts b/packages/google-cloud-support/test/gapic_comment_service_v2.ts index b686f324981c..43800914a207 100644 --- a/packages/google-cloud-support/test/gapic_comment_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_comment_service_v2.ts @@ -19,859 +19,1293 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as commentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2.CommentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = commentserviceModule.v2.CommentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = commentserviceModule.v2.CommentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new commentserviceModule.v2.CommentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('has universeDomain', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new commentserviceModule.v2.CommentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + commentserviceModule.v2.CommentServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + commentserviceModule.v2.CommentServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new commentserviceModule.v2.CommentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new commentserviceModule.v2.CommentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new commentserviceModule.v2.CommentServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('has port', () => { - const port = commentserviceModule.v2.CommentServiceClient.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 commentserviceModule.v2.CommentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('should create a client with no option', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - 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 commentserviceModule.v2.CommentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('should create a client with gRPC fallback', () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new commentserviceModule.v2.CommentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - await client.initialize(); - assert(client.commentServiceStub); - }); + it('has port', () => { + const port = commentserviceModule.v2.CommentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.commentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + await client.initialize(); + assert(client.commentServiceStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the initialized client', (done) => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.commentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createComment', () => { - it('invokes createComment without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); - const [response] = await client.createComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createComment without error using callback', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createComment with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createComment(request), expectedError); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('createComment', () => { + it('invokes createComment without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); + const [response] = await client.createComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with closed client', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createComment(request), expectedError); - }); + it('invokes createComment without error using callback', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.createComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listComments', () => { - it('invokes listComments without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); - const [response] = await client.listComments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments without error using callback', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listComments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IComment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment with closed client', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createComment(request), expectedError); + }); + }); + + describe('getComment', () => { + it('invokes getComment without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.getComment = stubSimpleCall(expectedResponse); + const [response] = await client.getComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listComments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listComments(request), expectedError); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getComment without error using callback', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.getComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCommentsStream without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.descriptors.page.listComments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes getComment with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCommentsStream with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes getComment with closed client', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getComment(request), expectedError); + }); + }); + + describe('listComments', () => { + it('invokes listComments without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); + const [response] = await client.listComments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listComments without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.IComment[] = []; - const iterable = client.listCommentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listComments without error using callback', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.innerApiCalls.listComments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listComments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IComment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listComments with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCommentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.IComment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listComments with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listComments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listComments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCommentsStream without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.descriptors.page.listComments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCommentsStream with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.IComment[] = []; + const iterable = client.listCommentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCommentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.IComment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts b/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts index 448533a0f6ef..828a9a75b96e 100644 --- a/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts @@ -19,1059 +19,1453 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as commentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2beta.CommentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = commentserviceModule.v2beta.CommentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = commentserviceModule.v2beta.CommentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + commentserviceModule.v2beta.CommentServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + commentserviceModule.v2beta.CommentServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new commentserviceModule.v2beta.CommentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new commentserviceModule.v2beta.CommentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new commentserviceModule.v2beta.CommentServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new commentserviceModule.v2beta.CommentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = commentserviceModule.v2beta.CommentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('should create a client with no option', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new commentserviceModule.v2beta.CommentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = commentserviceModule.v2beta.CommentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - await client.initialize(); - assert(client.commentServiceStub); - }); + it('should create a client with no option', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.commentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + await client.initialize(); + assert(client.commentServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the initialized client', (done) => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.commentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the non-initialized client', (done) => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createComment', () => { - it('invokes createComment without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); - const [response] = await client.createComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes createComment without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('createComment', () => { + it('invokes createComment without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); + const [response] = await client.createComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createComment(request), expectedError); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.createComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with closed client', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createComment(request), expectedError); - }); + it('invokes createComment with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getComment', () => { - it('invokes getComment without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.getComment = stubSimpleCall(expectedResponse); - const [response] = await client.getComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment with closed client', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createComment(request), expectedError); + }); + }); + + describe('getComment', () => { + it('invokes getComment without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.getComment = stubSimpleCall(expectedResponse); + const [response] = await client.getComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.getComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getComment without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.getComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getComment(request), expectedError); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getComment with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment with closed client', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getComment(request), expectedError); - }); + it('invokes getComment with closed client', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getComment(request), expectedError); + }); + }); + + describe('listComments', () => { + it('invokes listComments without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); + const [response] = await client.listComments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listComments', () => { - it('invokes listComments without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); - const [response] = await client.listComments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.innerApiCalls.listComments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listComments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listComments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listComments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listComments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listComments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listComments(request), expectedError); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCommentsStream without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.descriptors.page.listComments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCommentsStream without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.descriptors.page.listComments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCommentsStream with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCommentsStream with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listComments without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IComment[] = []; - const iterable = client.listCommentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listComments with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCommentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IComment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listComments without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IComment[] = []; + const iterable = client.listCommentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCommentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IComment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts b/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts index dbb55ffde01b..b05785c02beb 100644 --- a/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts @@ -19,843 +19,1210 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { SinonStub } from 'sinon'; +import { describe, it } from 'mocha'; import * as feedserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v2beta.FeedServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - if (typeof process === 'object' && typeof process.emitWarning === 'function') { - it('throws DeprecationWarning if static servicePath is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const servicePath = feedserviceModule.v2beta.FeedServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = feedserviceModule.v2beta.FeedServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + feedserviceModule.v2beta.FeedServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + feedserviceModule.v2beta.FeedServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - if (typeof process === 'object' && 'env' in process) { - describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { - it('sets apiEndpoint from environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new feedserviceModule.v2beta.FeedServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - - it('value configured in code has priority over environment variable', () => { - const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; - const client = new feedserviceModule.v2beta.FeedServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.configured.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); - }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new feedserviceModule.v2beta.FeedServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new feedserviceModule.v2beta.FeedServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = feedserviceModule.v2beta.FeedServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('should create a client with no option', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new feedserviceModule.v2beta.FeedServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = feedserviceModule.v2beta.FeedServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.feedServiceStub, undefined); - await client.initialize(); - assert(client.feedServiceStub); - }); + it('should create a client with no option', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.feedServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.feedServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.feedServiceStub, undefined); + await client.initialize(); + assert(client.feedServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('has close method for the initialized client', (done) => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.feedServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has close method for the non-initialized client', (done) => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.feedServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('showFeed', () => { - it('invokes showFeed without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.innerApiCalls.showFeed = stubSimpleCall(expectedResponse); - const [response] = await client.showFeed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); - it('invokes showFeed without error using callback', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.innerApiCalls.showFeed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.showFeed( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IFeedItem[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + }); + + describe('showFeed', () => { + it('invokes showFeed without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.innerApiCalls.showFeed = stubSimpleCall(expectedResponse); + const [response] = await client.showFeed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeed with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.showFeed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.showFeed(request), expectedError); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes showFeed without error using callback', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.innerApiCalls.showFeed = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.showFeed( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IFeedItem[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeedStream without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.descriptors.page.showFeed.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.showFeedStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.FeedItem) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showFeed, request)); - assert( - (client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes showFeed with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.showFeed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.showFeed(request), expectedError); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeedStream with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showFeed.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.showFeedStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.FeedItem) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showFeed, request)); - assert( - (client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes showFeedStream without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.descriptors.page.showFeed.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.showFeedStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.FeedItem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with showFeed without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; - const iterable = client.showFeedAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.showFeed, request), + ); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with showFeed with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.showFeedAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes showFeedStream with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showFeed.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.showFeedStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.FeedItem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.showFeed, request), + ); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with showFeed without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.descriptors.page.showFeed.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; + const iterable = client.showFeedAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.showFeed.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.showFeed.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with showFeed with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.showFeedAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.showFeed.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.showFeed.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/webpack.config.js b/packages/google-cloud-support/webpack.config.js index 2251de740ea8..1fab5f9e2370 100644 --- a/packages/google-cloud-support/webpack.config.js +++ b/packages/google-cloud-support/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.