diff --git a/packages/google-chat/.gitattributes b/packages/google-chat/.gitattributes new file mode 100644 index 000000000000..33739cb74e44 --- /dev/null +++ b/packages/google-chat/.gitattributes @@ -0,0 +1,4 @@ +*.ts text eol=lf +*.js text eol=lf +protos/* linguist-generated +**/api-extractor.json linguist-language=JSON-with-Comments diff --git a/packages/google-chat/CODE_OF_CONDUCT.md b/packages/google-chat/CODE_OF_CONDUCT.md new file mode 100644 index 000000000000..2add2547a812 --- /dev/null +++ b/packages/google-chat/CODE_OF_CONDUCT.md @@ -0,0 +1,94 @@ + +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/packages/google-chat/CONTRIBUTING.md b/packages/google-chat/CONTRIBUTING.md new file mode 100644 index 000000000000..4de12b7f4335 --- /dev/null +++ b/packages/google-chat/CONTRIBUTING.md @@ -0,0 +1,76 @@ +# How to become a contributor and submit your own code + +**Table of contents** + +* [Contributor License Agreements](#contributor-license-agreements) +* [Contributing a patch](#contributing-a-patch) +* [Running the tests](#running-the-tests) +* [Releasing the library](#releasing-the-library) + +## Contributor License Agreements + +We'd love to accept your sample apps and patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the code to which + you are contributing. +1. Ensure that your code has an appropriate set of tests which all pass. +1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. +1. Submit a pull request. + +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable billing for your project][billing]. +1. [Enable the Chat API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + + +## Running the tests + +1. [Prepare your environment for Node.js setup][setup]. + +1. Install dependencies: + + npm install + +1. Run the tests: + + # Run unit tests. + npm test + + # Run sample integration tests. + npm run samples-test + + # Run all system tests. + npm run system-test + +1. Lint (and maybe fix) any changes: + + npm run fix + +[setup]: https://cloud.google.com/nodejs/docs/setup +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=chat.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/packages/google-chat/LICENSE b/packages/google-chat/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/packages/google-chat/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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 + + http://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. diff --git a/packages/google-chat/README.md b/packages/google-chat/README.md index 80c39879dc5d..bab68ec0eb1b 100644 --- a/packages/google-chat/README.md +++ b/packages/google-chat/README.md @@ -71,6 +71,7 @@ Samples are in the [`samples/`][homepage_samples] directory. Each sample's `READ | delete section | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.delete_section.js) | | delete space | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.delete_space.js) | | find direct message | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.find_direct_message.js) | +| find group chats | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.find_group_chats.js) | | get attachment | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_attachment.js) | | get custom emoji | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_custom_emoji.js) | | get membership | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-chat/samples/generated/v1/chat_service.get_membership.js) | diff --git a/packages/google-chat/protos/google/chat/v1/chat_service.proto b/packages/google-chat/protos/google/chat/v1/chat_service.proto index afc37c0bbced..8aea14861df7 100644 --- a/packages/google-chat/protos/google/chat/v1/chat_service.proto +++ b/packages/google-chat/protos/google/chat/v1/chat_service.proto @@ -717,6 +717,32 @@ service ChatService { }; } + // Returns all spaces with `spaceType == GROUP_CHAT`, whose + // human memberships contain exactly the calling user, and the users specified + // in `FindGroupChatsRequest.users`. Only members that have joined the + // conversation are supported. For an example, see [Find group + // chats](https://developers.google.com/workspace/chat/find-group-chats). + // + // If the calling user blocks, or is blocked by, some users, and no spaces + // with the entire specified set of users are found, this method returns + // spaces that don't include the blocked or blocking users. + // + // The specified set of users must contain only human (non-app) memberships. + // A request that contains non-human users doesn't return any spaces. + // + // Requires [user + // authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + // with one of the following [authorization + // scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + // + // - `https://www.googleapis.com/auth/chat.memberships.readonly` + // - `https://www.googleapis.com/auth/chat.memberships` + rpc FindGroupChats(FindGroupChatsRequest) returns (FindGroupChatsResponse) { + option (google.api.http) = { + get: "/v1/spaces:findGroupChats" + }; + } + // Creates a membership for the calling Chat app, a user, or a Google Group. // Creating memberships for other Chat apps isn't supported. // When creating a membership, if the specified member has their auto-accept diff --git a/packages/google-chat/protos/google/chat/v1/space.proto b/packages/google-chat/protos/google/chat/v1/space.proto index 01873a3f99c8..3bd587bdbeb3 100644 --- a/packages/google-chat/protos/google/chat/v1/space.proto +++ b/packages/google-chat/protos/google/chat/v1/space.proto @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -552,6 +552,65 @@ message FindDirectMessageRequest { string name = 1 [(google.api.field_behavior) = REQUIRED]; } +// A request to get group chat spaces based on user resources. +message FindGroupChatsRequest { + // Optional. Resource names of all human users in group chat with the calling + // user. Chat apps can't be included in the request. + // + // The maximum number of users that can be specified in a single request is + // `49`. + // + // Format: `users/{user}`, where `{user}` is either the `id` for the + // [person](https://developers.google.com/people/api/rest/v1/people) from the + // People API, or the `id` for the + // [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) + // in the Directory API. For example, to find all group chats with the calling + // user and two other users, with People API profile IDs `123456789` and + // `987654321`, you can use `users/123456789` and `users/987654321`. + // You can also use the email as an alias for `{user}`. For example, + // `users/example@gmail.com` where `example@gmail.com` is the email of the + // Google Chat user. + repeated string users = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of spaces to return. The service might return + // fewer than this value. + // + // If unspecified, at most 10 spaces are returned. + // + // The maximum value is 30. If you use a value more than 30, it's + // automatically changed to 30. + // + // Negative values return an `INVALID_ARGUMENT` error. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous call to find group chats. + // Provide this parameter to retrieve the subsequent page. + // + // When paginating, all other parameters provided should match the call that + // provided the token. Passing different values may lead to unexpected + // results. + string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Requested space view type. If unset, defaults to + // `SPACE_VIEW_RESOURCE_NAME_ONLY`. Requests that specify + // `SPACE_VIEW_EXPANDED` must include scopes that allow reading space data, + // for example, + // https://www.googleapis.com/auth/chat.spaces or + // https://www.googleapis.com/auth/chat.spaces.readonly. + SpaceView space_view = 4; +} + +// A response containing group chat spaces with exactly the calling user and the +// requested users. +message FindGroupChatsResponse { + // List of spaces in the requested (or first) page. + repeated Space spaces = 1; + + // A token that you can send as `pageToken` to retrieve the next page of + // results. If empty, there are no subsequent pages. + string next_page_token = 2; +} + // A request to update a single space. message UpdateSpaceRequest { // Required. Space with fields to be updated. `Space.name` must be @@ -822,3 +881,24 @@ message CompleteImportSpaceResponse { // The import mode space. Space space = 1; } + +// A view that specifies which fields should be populated on the +// [`Space`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces) +// resource. +// To ensure compatibility with future releases, we recommend that your code +// account for additional values. +enum SpaceView { + // The default / unset value. + SPACE_VIEW_UNSPECIFIED = 0; + + // Populates only the Space resource name. + SPACE_VIEW_RESOURCE_NAME_ONLY = 3; + + // Populates Space resource fields. Note: the `permissionSettings` field + // will not be populated. + // Requests that specify SPACE_VIEW_EXPANDED must include scopes that allow + // reading space data, for example, + // https://www.googleapis.com/auth/chat.spaces or + // https://www.googleapis.com/auth/chat.spaces.readonly. + SPACE_VIEW_EXPANDED = 4; +} diff --git a/packages/google-chat/protos/protos.d.ts b/packages/google-chat/protos/protos.d.ts index 960c8a88bf65..dc9266a54755 100644 --- a/packages/google-chat/protos/protos.d.ts +++ b/packages/google-chat/protos/protos.d.ts @@ -14501,6 +14501,20 @@ export namespace google { */ public findDirectMessage(request: google.chat.v1.IFindDirectMessageRequest): Promise; + /** + * Calls FindGroupChats. + * @param request FindGroupChatsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and FindGroupChatsResponse + */ + public findGroupChats(request: google.chat.v1.IFindGroupChatsRequest, callback: google.chat.v1.ChatService.FindGroupChatsCallback): void; + + /** + * Calls FindGroupChats. + * @param request FindGroupChatsRequest message or plain object + * @returns Promise + */ + public findGroupChats(request: google.chat.v1.IFindGroupChatsRequest): Promise; + /** * Calls CreateMembership. * @param request CreateMembershipRequest message or plain object @@ -14966,6 +14980,13 @@ export namespace google { */ type FindDirectMessageCallback = (error: (Error|null), response?: google.chat.v1.Space) => void; + /** + * Callback as used by {@link google.chat.v1.ChatService|findGroupChats}. + * @param error Error, if any + * @param [response] FindGroupChatsResponse + */ + type FindGroupChatsCallback = (error: (Error|null), response?: google.chat.v1.FindGroupChatsResponse) => void; + /** * Callback as used by {@link google.chat.v1.ChatService|createMembership}. * @param error Error, if any @@ -21692,6 +21713,224 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a FindGroupChatsRequest. */ + interface IFindGroupChatsRequest { + + /** FindGroupChatsRequest users */ + users?: (string[]|null); + + /** FindGroupChatsRequest pageSize */ + pageSize?: (number|null); + + /** FindGroupChatsRequest pageToken */ + pageToken?: (string|null); + + /** FindGroupChatsRequest spaceView */ + spaceView?: (google.chat.v1.SpaceView|keyof typeof google.chat.v1.SpaceView|null); + } + + /** Represents a FindGroupChatsRequest. */ + class FindGroupChatsRequest implements IFindGroupChatsRequest { + + /** + * Constructs a new FindGroupChatsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.chat.v1.IFindGroupChatsRequest); + + /** FindGroupChatsRequest users. */ + public users: string[]; + + /** FindGroupChatsRequest pageSize. */ + public pageSize: number; + + /** FindGroupChatsRequest pageToken. */ + public pageToken: string; + + /** FindGroupChatsRequest spaceView. */ + public spaceView: (google.chat.v1.SpaceView|keyof typeof google.chat.v1.SpaceView); + + /** + * Creates a new FindGroupChatsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns FindGroupChatsRequest instance + */ + public static create(properties?: google.chat.v1.IFindGroupChatsRequest): google.chat.v1.FindGroupChatsRequest; + + /** + * Encodes the specified FindGroupChatsRequest message. Does not implicitly {@link google.chat.v1.FindGroupChatsRequest.verify|verify} messages. + * @param message FindGroupChatsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.chat.v1.IFindGroupChatsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FindGroupChatsRequest message, length delimited. Does not implicitly {@link google.chat.v1.FindGroupChatsRequest.verify|verify} messages. + * @param message FindGroupChatsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.chat.v1.IFindGroupChatsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FindGroupChatsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FindGroupChatsRequest + * @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.chat.v1.FindGroupChatsRequest; + + /** + * Decodes a FindGroupChatsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FindGroupChatsRequest + * @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.chat.v1.FindGroupChatsRequest; + + /** + * Verifies a FindGroupChatsRequest 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 FindGroupChatsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FindGroupChatsRequest + */ + public static fromObject(object: { [k: string]: any }): google.chat.v1.FindGroupChatsRequest; + + /** + * Creates a plain object from a FindGroupChatsRequest message. Also converts values to other types if specified. + * @param message FindGroupChatsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.chat.v1.FindGroupChatsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FindGroupChatsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FindGroupChatsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FindGroupChatsResponse. */ + interface IFindGroupChatsResponse { + + /** FindGroupChatsResponse spaces */ + spaces?: (google.chat.v1.ISpace[]|null); + + /** FindGroupChatsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a FindGroupChatsResponse. */ + class FindGroupChatsResponse implements IFindGroupChatsResponse { + + /** + * Constructs a new FindGroupChatsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.chat.v1.IFindGroupChatsResponse); + + /** FindGroupChatsResponse spaces. */ + public spaces: google.chat.v1.ISpace[]; + + /** FindGroupChatsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new FindGroupChatsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns FindGroupChatsResponse instance + */ + public static create(properties?: google.chat.v1.IFindGroupChatsResponse): google.chat.v1.FindGroupChatsResponse; + + /** + * Encodes the specified FindGroupChatsResponse message. Does not implicitly {@link google.chat.v1.FindGroupChatsResponse.verify|verify} messages. + * @param message FindGroupChatsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.chat.v1.IFindGroupChatsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FindGroupChatsResponse message, length delimited. Does not implicitly {@link google.chat.v1.FindGroupChatsResponse.verify|verify} messages. + * @param message FindGroupChatsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.chat.v1.IFindGroupChatsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FindGroupChatsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FindGroupChatsResponse + * @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.chat.v1.FindGroupChatsResponse; + + /** + * Decodes a FindGroupChatsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FindGroupChatsResponse + * @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.chat.v1.FindGroupChatsResponse; + + /** + * Verifies a FindGroupChatsResponse 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 FindGroupChatsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FindGroupChatsResponse + */ + public static fromObject(object: { [k: string]: any }): google.chat.v1.FindGroupChatsResponse; + + /** + * Creates a plain object from a FindGroupChatsResponse message. Also converts values to other types if specified. + * @param message FindGroupChatsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.chat.v1.FindGroupChatsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FindGroupChatsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FindGroupChatsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an UpdateSpaceRequest. */ interface IUpdateSpaceRequest { @@ -22328,6 +22567,13 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** SpaceView enum. */ + enum SpaceView { + SPACE_VIEW_UNSPECIFIED = 0, + SPACE_VIEW_RESOURCE_NAME_ONLY = 3, + SPACE_VIEW_EXPANDED = 4 + } + /** HistoryState enum. */ enum HistoryState { HISTORY_STATE_UNSPECIFIED = 0, diff --git a/packages/google-chat/protos/protos.js b/packages/google-chat/protos/protos.js index 0fbfcd375dfd..32188119463c 100644 --- a/packages/google-chat/protos/protos.js +++ b/packages/google-chat/protos/protos.js @@ -38482,6 +38482,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.chat.v1.ChatService|findGroupChats}. + * @memberof google.chat.v1.ChatService + * @typedef FindGroupChatsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.chat.v1.FindGroupChatsResponse} [response] FindGroupChatsResponse + */ + + /** + * Calls FindGroupChats. + * @function findGroupChats + * @memberof google.chat.v1.ChatService + * @instance + * @param {google.chat.v1.IFindGroupChatsRequest} request FindGroupChatsRequest message or plain object + * @param {google.chat.v1.ChatService.FindGroupChatsCallback} callback Node-style callback called with the error, if any, and FindGroupChatsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ChatService.prototype.findGroupChats = function findGroupChats(request, callback) { + return this.rpcCall(findGroupChats, $root.google.chat.v1.FindGroupChatsRequest, $root.google.chat.v1.FindGroupChatsResponse, request, callback); + }, "name", { value: "FindGroupChats" }); + + /** + * Calls FindGroupChats. + * @function findGroupChats + * @memberof google.chat.v1.ChatService + * @instance + * @param {google.chat.v1.IFindGroupChatsRequest} request FindGroupChatsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.chat.v1.ChatService|createMembership}. * @memberof google.chat.v1.ChatService @@ -56249,6 +56282,572 @@ return FindDirectMessageRequest; })(); + v1.FindGroupChatsRequest = (function() { + + /** + * Properties of a FindGroupChatsRequest. + * @memberof google.chat.v1 + * @interface IFindGroupChatsRequest + * @property {Array.|null} [users] FindGroupChatsRequest users + * @property {number|null} [pageSize] FindGroupChatsRequest pageSize + * @property {string|null} [pageToken] FindGroupChatsRequest pageToken + * @property {google.chat.v1.SpaceView|null} [spaceView] FindGroupChatsRequest spaceView + */ + + /** + * Constructs a new FindGroupChatsRequest. + * @memberof google.chat.v1 + * @classdesc Represents a FindGroupChatsRequest. + * @implements IFindGroupChatsRequest + * @constructor + * @param {google.chat.v1.IFindGroupChatsRequest=} [properties] Properties to set + */ + function FindGroupChatsRequest(properties) { + this.users = []; + 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]]; + } + + /** + * FindGroupChatsRequest users. + * @member {Array.} users + * @memberof google.chat.v1.FindGroupChatsRequest + * @instance + */ + FindGroupChatsRequest.prototype.users = $util.emptyArray; + + /** + * FindGroupChatsRequest pageSize. + * @member {number} pageSize + * @memberof google.chat.v1.FindGroupChatsRequest + * @instance + */ + FindGroupChatsRequest.prototype.pageSize = 0; + + /** + * FindGroupChatsRequest pageToken. + * @member {string} pageToken + * @memberof google.chat.v1.FindGroupChatsRequest + * @instance + */ + FindGroupChatsRequest.prototype.pageToken = ""; + + /** + * FindGroupChatsRequest spaceView. + * @member {google.chat.v1.SpaceView} spaceView + * @memberof google.chat.v1.FindGroupChatsRequest + * @instance + */ + FindGroupChatsRequest.prototype.spaceView = 0; + + /** + * Creates a new FindGroupChatsRequest instance using the specified properties. + * @function create + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {google.chat.v1.IFindGroupChatsRequest=} [properties] Properties to set + * @returns {google.chat.v1.FindGroupChatsRequest} FindGroupChatsRequest instance + */ + FindGroupChatsRequest.create = function create(properties) { + return new FindGroupChatsRequest(properties); + }; + + /** + * Encodes the specified FindGroupChatsRequest message. Does not implicitly {@link google.chat.v1.FindGroupChatsRequest.verify|verify} messages. + * @function encode + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {google.chat.v1.IFindGroupChatsRequest} message FindGroupChatsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindGroupChatsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.spaceView != null && Object.hasOwnProperty.call(message, "spaceView")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.spaceView); + if (message.users != null && message.users.length) + for (var i = 0; i < message.users.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.users[i]); + return writer; + }; + + /** + * Encodes the specified FindGroupChatsRequest message, length delimited. Does not implicitly {@link google.chat.v1.FindGroupChatsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {google.chat.v1.IFindGroupChatsRequest} message FindGroupChatsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindGroupChatsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FindGroupChatsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.chat.v1.FindGroupChatsRequest} FindGroupChatsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindGroupChatsRequest.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.chat.v1.FindGroupChatsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 5: { + if (!(message.users && message.users.length)) + message.users = []; + message.users.push(reader.string()); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + case 4: { + message.spaceView = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FindGroupChatsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.chat.v1.FindGroupChatsRequest} FindGroupChatsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindGroupChatsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FindGroupChatsRequest message. + * @function verify + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FindGroupChatsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.users != null && message.hasOwnProperty("users")) { + if (!Array.isArray(message.users)) + return "users: array expected"; + for (var i = 0; i < message.users.length; ++i) + if (!$util.isString(message.users[i])) + return "users: string[] expected"; + } + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + if (message.spaceView != null && message.hasOwnProperty("spaceView")) + switch (message.spaceView) { + default: + return "spaceView: enum value expected"; + case 0: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a FindGroupChatsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.chat.v1.FindGroupChatsRequest} FindGroupChatsRequest + */ + FindGroupChatsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.chat.v1.FindGroupChatsRequest) + return object; + var message = new $root.google.chat.v1.FindGroupChatsRequest(); + if (object.users) { + if (!Array.isArray(object.users)) + throw TypeError(".google.chat.v1.FindGroupChatsRequest.users: array expected"); + message.users = []; + for (var i = 0; i < object.users.length; ++i) + message.users[i] = String(object.users[i]); + } + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + switch (object.spaceView) { + default: + if (typeof object.spaceView === "number") { + message.spaceView = object.spaceView; + break; + } + break; + case "SPACE_VIEW_UNSPECIFIED": + case 0: + message.spaceView = 0; + break; + case "SPACE_VIEW_RESOURCE_NAME_ONLY": + case 3: + message.spaceView = 3; + break; + case "SPACE_VIEW_EXPANDED": + case 4: + message.spaceView = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a FindGroupChatsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {google.chat.v1.FindGroupChatsRequest} message FindGroupChatsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FindGroupChatsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.users = []; + if (options.defaults) { + object.pageSize = 0; + object.pageToken = ""; + object.spaceView = options.enums === String ? "SPACE_VIEW_UNSPECIFIED" : 0; + } + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.spaceView != null && message.hasOwnProperty("spaceView")) + object.spaceView = options.enums === String ? $root.google.chat.v1.SpaceView[message.spaceView] === undefined ? message.spaceView : $root.google.chat.v1.SpaceView[message.spaceView] : message.spaceView; + if (message.users && message.users.length) { + object.users = []; + for (var j = 0; j < message.users.length; ++j) + object.users[j] = message.users[j]; + } + return object; + }; + + /** + * Converts this FindGroupChatsRequest to JSON. + * @function toJSON + * @memberof google.chat.v1.FindGroupChatsRequest + * @instance + * @returns {Object.} JSON object + */ + FindGroupChatsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FindGroupChatsRequest + * @function getTypeUrl + * @memberof google.chat.v1.FindGroupChatsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FindGroupChatsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.chat.v1.FindGroupChatsRequest"; + }; + + return FindGroupChatsRequest; + })(); + + v1.FindGroupChatsResponse = (function() { + + /** + * Properties of a FindGroupChatsResponse. + * @memberof google.chat.v1 + * @interface IFindGroupChatsResponse + * @property {Array.|null} [spaces] FindGroupChatsResponse spaces + * @property {string|null} [nextPageToken] FindGroupChatsResponse nextPageToken + */ + + /** + * Constructs a new FindGroupChatsResponse. + * @memberof google.chat.v1 + * @classdesc Represents a FindGroupChatsResponse. + * @implements IFindGroupChatsResponse + * @constructor + * @param {google.chat.v1.IFindGroupChatsResponse=} [properties] Properties to set + */ + function FindGroupChatsResponse(properties) { + this.spaces = []; + 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]]; + } + + /** + * FindGroupChatsResponse spaces. + * @member {Array.} spaces + * @memberof google.chat.v1.FindGroupChatsResponse + * @instance + */ + FindGroupChatsResponse.prototype.spaces = $util.emptyArray; + + /** + * FindGroupChatsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.chat.v1.FindGroupChatsResponse + * @instance + */ + FindGroupChatsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new FindGroupChatsResponse instance using the specified properties. + * @function create + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {google.chat.v1.IFindGroupChatsResponse=} [properties] Properties to set + * @returns {google.chat.v1.FindGroupChatsResponse} FindGroupChatsResponse instance + */ + FindGroupChatsResponse.create = function create(properties) { + return new FindGroupChatsResponse(properties); + }; + + /** + * Encodes the specified FindGroupChatsResponse message. Does not implicitly {@link google.chat.v1.FindGroupChatsResponse.verify|verify} messages. + * @function encode + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {google.chat.v1.IFindGroupChatsResponse} message FindGroupChatsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindGroupChatsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.spaces != null && message.spaces.length) + for (var i = 0; i < message.spaces.length; ++i) + $root.google.chat.v1.Space.encode(message.spaces[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified FindGroupChatsResponse message, length delimited. Does not implicitly {@link google.chat.v1.FindGroupChatsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {google.chat.v1.IFindGroupChatsResponse} message FindGroupChatsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindGroupChatsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FindGroupChatsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.chat.v1.FindGroupChatsResponse} FindGroupChatsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindGroupChatsResponse.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.chat.v1.FindGroupChatsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + if (!(message.spaces && message.spaces.length)) + message.spaces = []; + message.spaces.push($root.google.chat.v1.Space.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FindGroupChatsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.chat.v1.FindGroupChatsResponse} FindGroupChatsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindGroupChatsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FindGroupChatsResponse message. + * @function verify + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FindGroupChatsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.spaces != null && message.hasOwnProperty("spaces")) { + if (!Array.isArray(message.spaces)) + return "spaces: array expected"; + for (var i = 0; i < message.spaces.length; ++i) { + var error = $root.google.chat.v1.Space.verify(message.spaces[i]); + if (error) + return "spaces." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a FindGroupChatsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.chat.v1.FindGroupChatsResponse} FindGroupChatsResponse + */ + FindGroupChatsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.chat.v1.FindGroupChatsResponse) + return object; + var message = new $root.google.chat.v1.FindGroupChatsResponse(); + if (object.spaces) { + if (!Array.isArray(object.spaces)) + throw TypeError(".google.chat.v1.FindGroupChatsResponse.spaces: array expected"); + message.spaces = []; + for (var i = 0; i < object.spaces.length; ++i) { + if (typeof object.spaces[i] !== "object") + throw TypeError(".google.chat.v1.FindGroupChatsResponse.spaces: object expected"); + message.spaces[i] = $root.google.chat.v1.Space.fromObject(object.spaces[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a FindGroupChatsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {google.chat.v1.FindGroupChatsResponse} message FindGroupChatsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FindGroupChatsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.spaces = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.spaces && message.spaces.length) { + object.spaces = []; + for (var j = 0; j < message.spaces.length; ++j) + object.spaces[j] = $root.google.chat.v1.Space.toObject(message.spaces[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this FindGroupChatsResponse to JSON. + * @function toJSON + * @memberof google.chat.v1.FindGroupChatsResponse + * @instance + * @returns {Object.} JSON object + */ + FindGroupChatsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FindGroupChatsResponse + * @function getTypeUrl + * @memberof google.chat.v1.FindGroupChatsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FindGroupChatsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.chat.v1.FindGroupChatsResponse"; + }; + + return FindGroupChatsResponse; + })(); + v1.UpdateSpaceRequest = (function() { /** @@ -57727,6 +58326,22 @@ return CompleteImportSpaceResponse; })(); + /** + * SpaceView enum. + * @name google.chat.v1.SpaceView + * @enum {number} + * @property {number} SPACE_VIEW_UNSPECIFIED=0 SPACE_VIEW_UNSPECIFIED value + * @property {number} SPACE_VIEW_RESOURCE_NAME_ONLY=3 SPACE_VIEW_RESOURCE_NAME_ONLY value + * @property {number} SPACE_VIEW_EXPANDED=4 SPACE_VIEW_EXPANDED value + */ + v1.SpaceView = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SPACE_VIEW_UNSPECIFIED"] = 0; + values[valuesById[3] = "SPACE_VIEW_RESOURCE_NAME_ONLY"] = 3; + values[valuesById[4] = "SPACE_VIEW_EXPANDED"] = 4; + return values; + })(); + /** * HistoryState enum. * @name google.chat.v1.HistoryState diff --git a/packages/google-chat/protos/protos.json b/packages/google-chat/protos/protos.json index 70b80dbb2071..583ddbec2db8 100644 --- a/packages/google-chat/protos/protos.json +++ b/packages/google-chat/protos/protos.json @@ -3830,6 +3830,20 @@ } ] }, + "FindGroupChats": { + "requestType": "FindGroupChatsRequest", + "responseType": "FindGroupChatsResponse", + "options": { + "(google.api.http).get": "/v1/spaces:findGroupChats" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/spaces:findGroupChats" + } + } + ] + }, "CreateMembership": { "requestType": "CreateMembershipRequest", "responseType": "Membership", @@ -6052,6 +6066,49 @@ } } }, + "FindGroupChatsRequest": { + "fields": { + "users": { + "rule": "repeated", + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageSize": { + "type": "int32", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "pageToken": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "spaceView": { + "type": "SpaceView", + "id": 4 + } + } + }, + "FindGroupChatsResponse": { + "fields": { + "spaces": { + "rule": "repeated", + "type": "Space", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, "UpdateSpaceRequest": { "fields": { "space": { @@ -6163,6 +6220,13 @@ } } }, + "SpaceView": { + "values": { + "SPACE_VIEW_UNSPECIFIED": 0, + "SPACE_VIEW_RESOURCE_NAME_ONLY": 3, + "SPACE_VIEW_EXPANDED": 4 + } + }, "HistoryState": { "values": { "HISTORY_STATE_UNSPECIFIED": 0, diff --git a/packages/google-chat/samples/generated/v1/chat_service.find_group_chats.js b/packages/google-chat/samples/generated/v1/chat_service.find_group_chats.js new file mode 100644 index 000000000000..a1c7d16530a9 --- /dev/null +++ b/packages/google-chat/samples/generated/v1/chat_service.find_group_chats.js @@ -0,0 +1,101 @@ +// 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() { + // [START chat_v1_generated_ChatService_FindGroupChats_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. + */ + /** + * Optional. Resource names of all human users in group chat with the calling + * user. Chat apps can't be included in the request. + * The maximum number of users that can be specified in a single request is + * `49`. + * Format: `users/{user}`, where `{user}` is either the `id` for the + * person (https://developers.google.com/people/api/rest/v1/people) from the + * People API, or the `id` for the + * user (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) + * in the Directory API. For example, to find all group chats with the calling + * user and two other users, with People API profile IDs `123456789` and + * `987654321`, you can use `users/123456789` and `users/987654321`. + * You can also use the email as an alias for `{user}`. For example, + * `users/example@gmail.com` where `example@gmail.com` is the email of the + * Google Chat user. + */ + // const users = ['abc','def'] + /** + * Optional. The maximum number of spaces to return. The service might return + * fewer than this value. + * If unspecified, at most 10 spaces are returned. + * The maximum value is 30. If you use a value more than 30, it's + * automatically changed to 30. + * Negative values return an `INVALID_ARGUMENT` error. + */ + // const pageSize = 1234 + /** + * Optional. A page token, received from a previous call to find group chats. + * Provide this parameter to retrieve the subsequent page. + * When paginating, all other parameters provided should match the call that + * provided the token. Passing different values may lead to unexpected + * results. + */ + // const pageToken = 'abc123' + /** + * Requested space view type. If unset, defaults to + * `SPACE_VIEW_RESOURCE_NAME_ONLY`. Requests that specify + * `SPACE_VIEW_EXPANDED` must include scopes that allow reading space data, + * for example, + * https://www.googleapis.com/auth/chat.spaces or + * https://www.googleapis.com/auth/chat.spaces.readonly. + */ + // const spaceView = {} + + // Imports the Chat library + const {ChatServiceClient} = require('@google-apps/chat').v1; + + // Instantiates a client + const chatClient = new ChatServiceClient(); + + async function callFindGroupChats() { + // Construct request + const request = { + }; + + // Run request + const iterable = chatClient.findGroupChatsAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callFindGroupChats(); + // [END chat_v1_generated_ChatService_FindGroupChats_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json b/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json index d8a8bb4e231b..826540bce49b 100644 --- a/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json +++ b/packages/google-chat/samples/generated/v1/snippet_metadata_google.chat.v1.json @@ -867,6 +867,58 @@ } } }, + { + "regionTag": "chat_v1_generated_ChatService_FindGroupChats_async", + "title": "ChatService findGroupChats Sample", + "origin": "API_DEFINITION", + "description": " Returns all spaces with `spaceType == GROUP_CHAT`, whose human memberships contain exactly the calling user, and the users specified in `FindGroupChatsRequest.users`. Only members that have joined the conversation are supported. For an example, see [Find group chats](https://developers.google.com/workspace/chat/find-group-chats). If the calling user blocks, or is blocked by, some users, and no spaces with the entire specified set of users are found, this method returns spaces that don't include the blocked or blocking users. The specified set of users must contain only human (non-app) memberships. A request that contains non-human users doesn't return any spaces. Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following [authorization scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): - `https://www.googleapis.com/auth/chat.memberships.readonly` - `https://www.googleapis.com/auth/chat.memberships`", + "canonical": true, + "file": "chat_service.find_group_chats.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 93, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "FindGroupChats", + "fullName": "google.chat.v1.ChatService.FindGroupChats", + "async": true, + "parameters": [ + { + "name": "users", + "type": "TYPE_STRING[]" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + }, + { + "name": "space_view", + "type": ".google.chat.v1.SpaceView" + } + ], + "resultType": ".google.chat.v1.FindGroupChatsResponse", + "client": { + "shortName": "ChatServiceClient", + "fullName": "google.chat.v1.ChatServiceClient" + }, + "method": { + "shortName": "FindGroupChats", + "fullName": "google.chat.v1.ChatService.FindGroupChats", + "service": { + "shortName": "ChatService", + "fullName": "google.chat.v1.ChatService" + } + } + } + }, { "regionTag": "chat_v1_generated_ChatService_CreateMembership_async", "title": "ChatService createMembership Sample", diff --git a/packages/google-chat/src/v1/chat_service_client.ts b/packages/google-chat/src/v1/chat_service_client.ts index 63b4427ab932..0bf6215a9a76 100644 --- a/packages/google-chat/src/v1/chat_service_client.ts +++ b/packages/google-chat/src/v1/chat_service_client.ts @@ -234,6 +234,8 @@ export class ChatServiceClient { new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaces'), searchSpaces: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaces'), + findGroupChats: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'spaces'), listReactions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reactions'), listCustomEmojis: @@ -289,7 +291,7 @@ export class ChatServiceClient { // Iterate over each of the methods that the service provides // and create an API call method for each. const chatServiceStubMethods = - ['createMessage', 'listMessages', 'listMemberships', 'getMembership', 'getMessage', 'updateMessage', 'deleteMessage', 'getAttachment', 'uploadAttachment', 'listSpaces', 'searchSpaces', 'getSpace', 'createSpace', 'setUpSpace', 'updateSpace', 'deleteSpace', 'completeImportSpace', 'findDirectMessage', 'createMembership', 'updateMembership', 'deleteMembership', 'createReaction', 'listReactions', 'deleteReaction', 'createCustomEmoji', 'getCustomEmoji', 'listCustomEmojis', 'deleteCustomEmoji', 'getSpaceReadState', 'updateSpaceReadState', 'getThreadReadState', 'getSpaceEvent', 'listSpaceEvents', 'getSpaceNotificationSetting', 'updateSpaceNotificationSetting', 'createSection', 'deleteSection', 'updateSection', 'listSections', 'positionSection', 'listSectionItems', 'moveSectionItem']; + ['createMessage', 'listMessages', 'listMemberships', 'getMembership', 'getMessage', 'updateMessage', 'deleteMessage', 'getAttachment', 'uploadAttachment', 'listSpaces', 'searchSpaces', 'getSpace', 'createSpace', 'setUpSpace', 'updateSpace', 'deleteSpace', 'completeImportSpace', 'findDirectMessage', 'findGroupChats', 'createMembership', 'updateMembership', 'deleteMembership', 'createReaction', 'listReactions', 'deleteReaction', 'createCustomEmoji', 'getCustomEmoji', 'listCustomEmojis', 'deleteCustomEmoji', 'getSpaceReadState', 'updateSpaceReadState', 'getThreadReadState', 'getSpaceEvent', 'listSpaceEvents', 'getSpaceNotificationSetting', 'updateSpaceNotificationSetting', 'createSection', 'deleteSection', 'updateSection', 'listSections', 'positionSection', 'listSectionItems', 'moveSectionItem']; for (const methodName of chatServiceStubMethods) { const callPromise = this.chatServiceStub.then( stub => (...args: Array<{}>) => { @@ -6458,6 +6460,306 @@ export class ChatServiceClient { ) as AsyncIterable; } /** + * Returns all spaces with `spaceType == GROUP_CHAT`, whose + * human memberships contain exactly the calling user, and the users specified + * in `FindGroupChatsRequest.users`. Only members that have joined the + * conversation are supported. For an example, see [Find group + * chats](https://developers.google.com/workspace/chat/find-group-chats). + * + * If the calling user blocks, or is blocked by, some users, and no spaces + * with the entire specified set of users are found, this method returns + * spaces that don't include the blocked or blocking users. + * + * The specified set of users must contain only human (non-app) memberships. + * A request that contains non-human users doesn't return any spaces. + * + * Requires [user + * authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) + * with one of the following [authorization + * scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes): + * + * - `https://www.googleapis.com/auth/chat.memberships.readonly` + * - `https://www.googleapis.com/auth/chat.memberships` + * + * @param {Object} request + * The request object that will be sent. + * @param {string[]} [request.users] + * Optional. Resource names of all human users in group chat with the calling + * user. Chat apps can't be included in the request. + * + * The maximum number of users that can be specified in a single request is + * `49`. + * + * Format: `users/{user}`, where `{user}` is either the `id` for the + * [person](https://developers.google.com/people/api/rest/v1/people) from the + * People API, or the `id` for the + * [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) + * in the Directory API. For example, to find all group chats with the calling + * user and two other users, with People API profile IDs `123456789` and + * `987654321`, you can use `users/123456789` and `users/987654321`. + * You can also use the email as an alias for `{user}`. For example, + * `users/example@gmail.com` where `example@gmail.com` is the email of the + * Google Chat user. + * @param {number} [request.pageSize] + * Optional. The maximum number of spaces to return. The service might return + * fewer than this value. + * + * If unspecified, at most 10 spaces are returned. + * + * The maximum value is 30. If you use a value more than 30, it's + * automatically changed to 30. + * + * Negative values return an `INVALID_ARGUMENT` error. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous call to find group chats. + * Provide this parameter to retrieve the subsequent page. + * + * When paginating, all other parameters provided should match the call that + * provided the token. Passing different values may lead to unexpected + * results. + * @param {google.chat.v1.SpaceView} request.spaceView + * Requested space view type. If unset, defaults to + * `SPACE_VIEW_RESOURCE_NAME_ONLY`. Requests that specify + * `SPACE_VIEW_EXPANDED` must include scopes that allow reading space data, + * for example, + * https://www.googleapis.com/auth/chat.spaces or + * https://www.googleapis.com/auth/chat.spaces.readonly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.chat.v1.Space|Space}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `findGroupChatsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + findGroupChats( + request?: protos.google.chat.v1.IFindGroupChatsRequest, + options?: CallOptions): + Promise<[ + protos.google.chat.v1.ISpace[], + protos.google.chat.v1.IFindGroupChatsRequest|null, + protos.google.chat.v1.IFindGroupChatsResponse + ]>; + findGroupChats( + request: protos.google.chat.v1.IFindGroupChatsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.chat.v1.IFindGroupChatsRequest, + protos.google.chat.v1.IFindGroupChatsResponse|null|undefined, + protos.google.chat.v1.ISpace>): void; + findGroupChats( + request: protos.google.chat.v1.IFindGroupChatsRequest, + callback: PaginationCallback< + protos.google.chat.v1.IFindGroupChatsRequest, + protos.google.chat.v1.IFindGroupChatsResponse|null|undefined, + protos.google.chat.v1.ISpace>): void; + findGroupChats( + request?: protos.google.chat.v1.IFindGroupChatsRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.chat.v1.IFindGroupChatsRequest, + protos.google.chat.v1.IFindGroupChatsResponse|null|undefined, + protos.google.chat.v1.ISpace>, + callback?: PaginationCallback< + protos.google.chat.v1.IFindGroupChatsRequest, + protos.google.chat.v1.IFindGroupChatsResponse|null|undefined, + protos.google.chat.v1.ISpace>): + Promise<[ + protos.google.chat.v1.ISpace[], + protos.google.chat.v1.IFindGroupChatsRequest|null, + protos.google.chat.v1.IFindGroupChatsResponse + ]>|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 || {}; + this.initialize().catch(err => {throw err}); + const wrappedCallback: PaginationCallback< + protos.google.chat.v1.IFindGroupChatsRequest, + protos.google.chat.v1.IFindGroupChatsResponse|null|undefined, + protos.google.chat.v1.ISpace>|undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('findGroupChats values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('findGroupChats request %j', request); + return this.innerApiCalls + .findGroupChats(request, options, wrappedCallback) + ?.then(([response, input, output]: [ + protos.google.chat.v1.ISpace[], + protos.google.chat.v1.IFindGroupChatsRequest|null, + protos.google.chat.v1.IFindGroupChatsResponse + ]) => { + this._log.info('findGroupChats values %j', response); + return [response, input, output]; + }); + } + +/** + * Equivalent to `findGroupChats`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string[]} [request.users] + * Optional. Resource names of all human users in group chat with the calling + * user. Chat apps can't be included in the request. + * + * The maximum number of users that can be specified in a single request is + * `49`. + * + * Format: `users/{user}`, where `{user}` is either the `id` for the + * [person](https://developers.google.com/people/api/rest/v1/people) from the + * People API, or the `id` for the + * [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) + * in the Directory API. For example, to find all group chats with the calling + * user and two other users, with People API profile IDs `123456789` and + * `987654321`, you can use `users/123456789` and `users/987654321`. + * You can also use the email as an alias for `{user}`. For example, + * `users/example@gmail.com` where `example@gmail.com` is the email of the + * Google Chat user. + * @param {number} [request.pageSize] + * Optional. The maximum number of spaces to return. The service might return + * fewer than this value. + * + * If unspecified, at most 10 spaces are returned. + * + * The maximum value is 30. If you use a value more than 30, it's + * automatically changed to 30. + * + * Negative values return an `INVALID_ARGUMENT` error. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous call to find group chats. + * Provide this parameter to retrieve the subsequent page. + * + * When paginating, all other parameters provided should match the call that + * provided the token. Passing different values may lead to unexpected + * results. + * @param {google.chat.v1.SpaceView} request.spaceView + * Requested space view type. If unset, defaults to + * `SPACE_VIEW_RESOURCE_NAME_ONLY`. Requests that specify + * `SPACE_VIEW_EXPANDED` must include scopes that allow reading space data, + * for example, + * https://www.googleapis.com/auth/chat.spaces or + * https://www.googleapis.com/auth/chat.spaces.readonly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.chat.v1.Space|Space} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `findGroupChatsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ + findGroupChatsStream( + request?: protos.google.chat.v1.IFindGroupChatsRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['findGroupChats']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('findGroupChats stream %j', request); + return this.descriptors.page.findGroupChats.createStream( + this.innerApiCalls.findGroupChats as GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `findGroupChats`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string[]} [request.users] + * Optional. Resource names of all human users in group chat with the calling + * user. Chat apps can't be included in the request. + * + * The maximum number of users that can be specified in a single request is + * `49`. + * + * Format: `users/{user}`, where `{user}` is either the `id` for the + * [person](https://developers.google.com/people/api/rest/v1/people) from the + * People API, or the `id` for the + * [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users) + * in the Directory API. For example, to find all group chats with the calling + * user and two other users, with People API profile IDs `123456789` and + * `987654321`, you can use `users/123456789` and `users/987654321`. + * You can also use the email as an alias for `{user}`. For example, + * `users/example@gmail.com` where `example@gmail.com` is the email of the + * Google Chat user. + * @param {number} [request.pageSize] + * Optional. The maximum number of spaces to return. The service might return + * fewer than this value. + * + * If unspecified, at most 10 spaces are returned. + * + * The maximum value is 30. If you use a value more than 30, it's + * automatically changed to 30. + * + * Negative values return an `INVALID_ARGUMENT` error. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous call to find group chats. + * Provide this parameter to retrieve the subsequent page. + * + * When paginating, all other parameters provided should match the call that + * provided the token. Passing different values may lead to unexpected + * results. + * @param {google.chat.v1.SpaceView} request.spaceView + * Requested space view type. If unset, defaults to + * `SPACE_VIEW_RESOURCE_NAME_ONLY`. Requests that specify + * `SPACE_VIEW_EXPANDED` must include scopes that allow reading space data, + * for example, + * https://www.googleapis.com/auth/chat.spaces or + * https://www.googleapis.com/auth/chat.spaces.readonly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.chat.v1.Space|Space}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/chat_service.find_group_chats.js + * region_tag:chat_v1_generated_ChatService_FindGroupChats_async + */ + findGroupChatsAsync( + request?: protos.google.chat.v1.IFindGroupChatsRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + const defaultCallSettings = this._defaults['findGroupChats']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => {throw err}); + this._log.info('findGroupChats iterate %j', request); + return this.descriptors.page.findGroupChats.asyncIterate( + this.innerApiCalls['findGroupChats'] as GaxCall, + request as {}, + callSettings + ) as AsyncIterable; + } + /** * Lists reactions to a message. For an example, see * [List reactions for a * message](https://developers.google.com/workspace/chat/list-reactions). diff --git a/packages/google-chat/src/v1/chat_service_client_config.json b/packages/google-chat/src/v1/chat_service_client_config.json index 515728f70d98..4ba98fad738a 100644 --- a/packages/google-chat/src/v1/chat_service_client_config.json +++ b/packages/google-chat/src/v1/chat_service_client_config.json @@ -122,6 +122,11 @@ "retry_codes_name": "unavailable", "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" }, + "FindGroupChats": { + "timeout_millis": 30000, + "retry_codes_name": "unavailable", + "retry_params_name": "ce5b960a6ed052e690863808e4f0deff3dc7d49f" + }, "CreateMembership": { "timeout_millis": 30000, "retry_codes_name": "unavailable", diff --git a/packages/google-chat/src/v1/gapic_metadata.json b/packages/google-chat/src/v1/gapic_metadata.json index 47c640fc0be6..c3f1cb3dffe8 100644 --- a/packages/google-chat/src/v1/gapic_metadata.json +++ b/packages/google-chat/src/v1/gapic_metadata.json @@ -203,6 +203,13 @@ "searchSpacesAsync" ] }, + "FindGroupChats": { + "methods": [ + "findGroupChats", + "findGroupChatsStream", + "findGroupChatsAsync" + ] + }, "ListReactions": { "methods": [ "listReactions", @@ -436,6 +443,13 @@ "searchSpacesAsync" ] }, + "FindGroupChats": { + "methods": [ + "findGroupChats", + "findGroupChatsStream", + "findGroupChatsAsync" + ] + }, "ListReactions": { "methods": [ "listReactions", diff --git a/packages/google-chat/test/gapic_chat_service_v1.ts b/packages/google-chat/test/gapic_chat_service_v1.ts index d338c3a28760..3917b0aca588 100644 --- a/packages/google-chat/test/gapic_chat_service_v1.ts +++ b/packages/google-chat/test/gapic_chat_service_v1.ts @@ -4555,6 +4555,181 @@ describe('v1.ChatServiceClient', () => { }); }); + describe('findGroupChats', () => { + it('invokes findGroupChats without error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + ]; + client.innerApiCalls.findGroupChats = stubSimpleCall(expectedResponse); + const [response] = await client.findGroupChats(request); + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes findGroupChats without error using callback', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + );const expectedResponse = [ + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + ]; + client.innerApiCalls.findGroupChats = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.findGroupChats( + request, + (err?: Error|null, result?: protos.google.chat.v1.ISpace[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + + it('invokes findGroupChats with error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.findGroupChats = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.findGroupChats(request), expectedError); + }); + + it('invokes findGroupChatsStream without error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + ]; + client.descriptors.page.findGroupChats.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.findGroupChatsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.chat.v1.Space[] = []; + stream.on('data', (response: protos.google.chat.v1.Space) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.findGroupChats.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.findGroupChats, request)); + }); + + it('invokes findGroupChatsStream with error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.findGroupChats.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.findGroupChatsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.chat.v1.Space[] = []; + stream.on('data', (response: protos.google.chat.v1.Space) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.findGroupChats.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.findGroupChats, request)); + }); + + it('uses async iteration with findGroupChats without error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + ); + const expectedResponse = [ + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + generateSampleMessage(new protos.google.chat.v1.Space()), + ]; + client.descriptors.page.findGroupChats.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.chat.v1.ISpace[] = []; + const iterable = client.findGroupChatsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.findGroupChats.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with findGroupChats with error', async () => { + const client = new chatserviceModule.v1.ChatServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.chat.v1.FindGroupChatsRequest() + ); + const expectedError = new Error('expected'); + client.descriptors.page.findGroupChats.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.findGroupChatsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.chat.v1.ISpace[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.findGroupChats.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + }); + describe('listReactions', () => { it('invokes listReactions without error', async () => { const client = new chatserviceModule.v1.ChatServiceClient({