google_chat_v1/client.rs
1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16#![allow(rustdoc::bare_urls)]
17#![allow(rustdoc::broken_intra_doc_links)]
18#![allow(rustdoc::invalid_html_tags)]
19#![allow(rustdoc::redundant_explicit_links)]
20
21/// Implements a client for the Google Chat API.
22///
23/// # Example
24/// ```
25/// # use google_chat_v1::client::ChatService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// space_id: &str,
29/// ) -> anyhow::Result<()> {
30/// let client = ChatService::builder().build().await?;
31/// let mut list = client.list_messages()
32/// .set_parent(format!("spaces/{space_id}"))
33/// .by_item();
34/// while let Some(item) = list.next().await.transpose()? {
35/// println!("{:?}", item);
36/// }
37/// Ok(())
38/// }
39/// ```
40///
41/// # Service Description
42///
43/// Enables developers to build Chat apps and
44/// integrations on Google Chat Platform.
45///
46/// # Configuration
47///
48/// To configure `ChatService` use the `with_*` methods in the type returned
49/// by [builder()][ChatService::builder]. The default configuration should
50/// work for most applications. Common configuration changes include
51///
52/// * [with_endpoint()]: by default this client uses the global default endpoint
53/// (`https://chat.googleapis.com`). Applications using regional
54/// endpoints or running in restricted networks (e.g. a network configured
55/// with [Private Google Access with VPC Service Controls]) may want to
56/// override this default.
57/// * [with_credentials()]: by default this client uses
58/// [Application Default Credentials]. Applications using custom
59/// authentication may need to override this default.
60///
61/// [with_endpoint()]: super::builder::chat_service::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::chat_service::ClientBuilder::with_credentials
63/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
64/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
65///
66/// # Pooling and Cloning
67///
68/// `ChatService` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `ChatService` in
70/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
71/// already uses an `Arc` internally.
72#[derive(Clone, Debug)]
73pub struct ChatService {
74 inner: std::sync::Arc<dyn super::stub::dynamic::ChatService>,
75}
76
77impl ChatService {
78 /// Returns a builder for [ChatService].
79 ///
80 /// ```
81 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82 /// # use google_chat_v1::client::ChatService;
83 /// let client = ChatService::builder().build().await?;
84 /// # Ok(()) }
85 /// ```
86 pub fn builder() -> super::builder::chat_service::ClientBuilder {
87 crate::new_client_builder(super::builder::chat_service::client::Factory)
88 }
89
90 /// Creates a new client from the provided stub.
91 ///
92 /// The most common case for calling this function is in tests mocking the
93 /// client's behavior.
94 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
95 where
96 T: super::stub::ChatService + 'static,
97 {
98 Self { inner: stub.into() }
99 }
100
101 pub(crate) async fn new(
102 config: gaxi::options::ClientConfig,
103 ) -> crate::ClientBuilderResult<Self> {
104 let inner = Self::build_inner(config).await?;
105 Ok(Self { inner })
106 }
107
108 async fn build_inner(
109 conf: gaxi::options::ClientConfig,
110 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::ChatService>> {
111 if gaxi::options::tracing_enabled(&conf) {
112 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
113 }
114 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
115 }
116
117 async fn build_transport(
118 conf: gaxi::options::ClientConfig,
119 ) -> crate::ClientBuilderResult<impl super::stub::ChatService> {
120 super::transport::ChatService::new(conf).await
121 }
122
123 async fn build_with_tracing(
124 conf: gaxi::options::ClientConfig,
125 ) -> crate::ClientBuilderResult<impl super::stub::ChatService> {
126 Self::build_transport(conf)
127 .await
128 .map(super::tracing::ChatService::new)
129 }
130
131 /// Creates a message in a Google Chat space. For an example, see [Send a
132 /// message](https://developers.google.com/workspace/chat/create-messages).
133 ///
134 /// Supports the following types of
135 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
136 ///
137 /// - [App
138 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
139 /// with the authorization scope:
140 /// - `<https://www.googleapis.com/auth/chat.bot>`
141 /// - [User
142 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
143 /// with one of the following authorization scopes:
144 /// - `<https://www.googleapis.com/auth/chat.messages.create>`
145 /// - `<https://www.googleapis.com/auth/chat.messages>`
146 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
147 /// only)
148 ///
149 /// Chat attributes the message sender differently depending on the type of
150 /// authentication that you use in your request.
151 ///
152 /// The following image shows how Chat attributes a message when you use app
153 /// authentication. Chat displays the Chat app as the message
154 /// sender. The content of the message can contain text (`text`), cards
155 /// (`cardsV2`), and accessory widgets (`accessoryWidgets`).
156 ///
157 /// 
159 ///
160 /// The following image shows how Chat attributes a message when you use user
161 /// authentication. Chat displays the user as the message sender and attributes
162 /// the Chat app to the message by displaying its name. The content of message
163 /// can only contain text (`text`).
164 ///
165 /// 
167 ///
168 /// The maximum message size, including the message contents, is 32,000 bytes.
169 ///
170 /// For
171 /// [webhook](https://developers.google.com/workspace/chat/quickstart/webhooks)
172 /// requests, the response doesn't contain the full message. The response only
173 /// populates the `name` and `thread.name` fields in addition to the
174 /// information that was in the request.
175 ///
176 /// # Example
177 /// ```
178 /// # use google_chat_v1::client::ChatService;
179 /// use google_chat_v1::model::Message;
180 /// use google_chat_v1::Result;
181 /// async fn sample(
182 /// client: &ChatService, space_id: &str
183 /// ) -> Result<()> {
184 /// let response = client.create_message()
185 /// .set_parent(format!("spaces/{space_id}"))
186 /// .set_message_id("message_id_value")
187 /// .set_message(
188 /// Message::new()/* set fields */
189 /// )
190 /// .send().await?;
191 /// println!("response {:?}", response);
192 /// Ok(())
193 /// }
194 /// ```
195 pub fn create_message(&self) -> super::builder::chat_service::CreateMessage {
196 super::builder::chat_service::CreateMessage::new(self.inner.clone())
197 }
198
199 /// Lists messages in a space that the caller is a member of, including
200 /// messages from blocked members and spaces. System messages, like those
201 /// announcing new space members, aren't included. If you list messages from a
202 /// space with no messages, the response is an empty object. When using a
203 /// REST/HTTP interface, the response contains an empty JSON object, `{}`.
204 /// For an example, see
205 /// [List
206 /// messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/list).
207 ///
208 /// Supports the following types of
209 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
210 ///
211 /// - [App
212 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
213 /// with [administrator
214 /// approval](https://support.google.com/a?p=chat-app-auth)
215 /// with the authorization scope:
216 ///
217 /// - `<https://www.googleapis.com/auth/chat.app.messages.readonly>`. When
218 /// using this authentication scope, this method only returns public
219 /// messages in a space. It doesn't include private messages.
220 /// - [User
221 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
222 /// with one of the following authorization scopes:
223 ///
224 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
225 /// - `<https://www.googleapis.com/auth/chat.messages>`
226 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
227 /// only)
228 ///
229 /// # Example
230 /// ```
231 /// # use google_chat_v1::client::ChatService;
232 /// use google_cloud_gax::paginator::ItemPaginator as _;
233 /// use google_chat_v1::Result;
234 /// async fn sample(
235 /// client: &ChatService, space_id: &str
236 /// ) -> Result<()> {
237 /// let mut list = client.list_messages()
238 /// .set_parent(format!("spaces/{space_id}"))
239 /// .by_item();
240 /// while let Some(item) = list.next().await.transpose()? {
241 /// println!("{:?}", item);
242 /// }
243 /// Ok(())
244 /// }
245 /// ```
246 pub fn list_messages(&self) -> super::builder::chat_service::ListMessages {
247 super::builder::chat_service::ListMessages::new(self.inner.clone())
248 }
249
250 /// Lists memberships in a space. For an example, see [List users and Google
251 /// Chat apps in a
252 /// space](https://developers.google.com/workspace/chat/list-members). Listing
253 /// memberships with [app
254 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
255 /// lists memberships in spaces that the Chat app has
256 /// access to, but excludes Chat app memberships,
257 /// including its own. Listing memberships with
258 /// [User
259 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
260 /// lists memberships in spaces that the authenticated user has access to.
261 ///
262 /// Supports the following types of
263 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
264 ///
265 /// - [App
266 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
267 /// with one of the following authorization scopes:
268 ///
269 /// - `<https://www.googleapis.com/auth/chat.bot>`
270 /// - `<https://www.googleapis.com/auth/chat.app.memberships>` (requires
271 /// [administrator approval](https://support.google.com/a?p=chat-app-auth))
272 /// - [User
273 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
274 /// with one of the following authorization scopes:
275 ///
276 /// - `<https://www.googleapis.com/auth/chat.memberships.readonly>`
277 /// - `<https://www.googleapis.com/auth/chat.memberships>`
278 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
279 /// only)
280 /// - User authentication grants administrator privileges when an
281 /// administrator account authenticates, `use_admin_access` is `true`, and
282 /// one of the following authorization scopes is used:
283 /// - `<https://www.googleapis.com/auth/chat.admin.memberships.readonly>`
284 /// - `<https://www.googleapis.com/auth/chat.admin.memberships>`
285 ///
286 /// # Example
287 /// ```
288 /// # use google_chat_v1::client::ChatService;
289 /// use google_cloud_gax::paginator::ItemPaginator as _;
290 /// use google_chat_v1::Result;
291 /// async fn sample(
292 /// client: &ChatService, space_id: &str
293 /// ) -> Result<()> {
294 /// let mut list = client.list_memberships()
295 /// .set_parent(format!("spaces/{space_id}"))
296 /// .by_item();
297 /// while let Some(item) = list.next().await.transpose()? {
298 /// println!("{:?}", item);
299 /// }
300 /// Ok(())
301 /// }
302 /// ```
303 pub fn list_memberships(&self) -> super::builder::chat_service::ListMemberships {
304 super::builder::chat_service::ListMemberships::new(self.inner.clone())
305 }
306
307 /// Returns details about a membership. For an example, see
308 /// [Get details about a user's or Google Chat app's
309 /// membership](https://developers.google.com/workspace/chat/get-members).
310 ///
311 /// Supports the following types of
312 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
313 ///
314 /// - [App
315 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
316 /// with one of the following authorization scopes:
317 ///
318 /// - `<https://www.googleapis.com/auth/chat.bot>`
319 /// - `<https://www.googleapis.com/auth/chat.app.memberships>` (requires
320 /// [administrator approval](https://support.google.com/a?p=chat-app-auth))
321 /// - [User
322 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
323 /// with one of the following authorization scopes:
324 ///
325 /// - `<https://www.googleapis.com/auth/chat.memberships.readonly>`
326 /// - `<https://www.googleapis.com/auth/chat.memberships>`
327 /// - User authentication grants administrator privileges when an
328 /// administrator account authenticates, `use_admin_access` is `true`, and
329 /// one of the following authorization scopes is used:
330 /// - `<https://www.googleapis.com/auth/chat.admin.memberships.readonly>`
331 /// - `<https://www.googleapis.com/auth/chat.admin.memberships>`
332 ///
333 /// # Example
334 /// ```
335 /// # use google_chat_v1::client::ChatService;
336 /// use google_chat_v1::Result;
337 /// async fn sample(
338 /// client: &ChatService, space_id: &str, member_id: &str
339 /// ) -> Result<()> {
340 /// let response = client.get_membership()
341 /// .set_name(format!("spaces/{space_id}/members/{member_id}"))
342 /// .send().await?;
343 /// println!("response {:?}", response);
344 /// Ok(())
345 /// }
346 /// ```
347 pub fn get_membership(&self) -> super::builder::chat_service::GetMembership {
348 super::builder::chat_service::GetMembership::new(self.inner.clone())
349 }
350
351 /// Returns details about a message.
352 /// For an example, see [Get details about a
353 /// message](https://developers.google.com/workspace/chat/get-messages).
354 ///
355 /// Supports the following types of
356 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
357 ///
358 /// - [App
359 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
360 /// with one of the following authorization scopes:
361 ///
362 /// - `<https://www.googleapis.com/auth/chat.bot>`: When using this
363 /// authorization scope, this method returns details about a message the
364 /// Chat app has access to, like direct messages and [slash
365 /// commands](https://developers.google.com/workspace/chat/slash-commands)
366 /// that invoke the Chat app.
367 /// - `<https://www.googleapis.com/auth/chat.app.messages.readonly>`
368 /// with [administrator
369 /// approval](https://support.google.com/a?p=chat-app-auth).
370 /// When using this authentication scope,
371 /// this method returns details about a public message in a space.
372 /// - [User
373 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
374 /// with one of the following authorization scopes:
375 ///
376 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
377 /// - `<https://www.googleapis.com/auth/chat.messages>`
378 ///
379 /// Note: Might return a message from a blocked member or space.
380 ///
381 /// # Example
382 /// ```
383 /// # use google_chat_v1::client::ChatService;
384 /// use google_chat_v1::Result;
385 /// async fn sample(
386 /// client: &ChatService, space_id: &str, message_id: &str
387 /// ) -> Result<()> {
388 /// let response = client.get_message()
389 /// .set_name(format!("spaces/{space_id}/messages/{message_id}"))
390 /// .send().await?;
391 /// println!("response {:?}", response);
392 /// Ok(())
393 /// }
394 /// ```
395 pub fn get_message(&self) -> super::builder::chat_service::GetMessage {
396 super::builder::chat_service::GetMessage::new(self.inner.clone())
397 }
398
399 /// Updates a message. There's a difference between the `patch` and `update`
400 /// methods. The `patch`
401 /// method uses a `patch` request while the `update` method uses a `put`
402 /// request. We recommend using the `patch` method. For an example, see
403 /// [Update a
404 /// message](https://developers.google.com/workspace/chat/update-messages).
405 ///
406 /// Supports the following types of
407 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
408 ///
409 /// - [App
410 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
411 /// with the authorization scope:
412 ///
413 /// - `<https://www.googleapis.com/auth/chat.bot>`
414 /// - [User
415 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
416 /// with one of the following authorization scopes:
417 ///
418 /// - `<https://www.googleapis.com/auth/chat.messages>`
419 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
420 /// only)
421 ///
422 /// When using app authentication, requests can only update messages
423 /// created by the calling Chat app.
424 ///
425 /// # Example
426 /// ```
427 /// # use google_chat_v1::client::ChatService;
428 /// # extern crate wkt as google_cloud_wkt;
429 /// use google_cloud_wkt::FieldMask;
430 /// use google_chat_v1::model::Message;
431 /// use google_chat_v1::Result;
432 /// async fn sample(
433 /// client: &ChatService, space_id: &str, message_id: &str
434 /// ) -> Result<()> {
435 /// let response = client.update_message()
436 /// .set_message(
437 /// Message::new().set_name(format!("spaces/{space_id}/messages/{message_id}"))/* set fields */
438 /// )
439 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
440 /// .send().await?;
441 /// println!("response {:?}", response);
442 /// Ok(())
443 /// }
444 /// ```
445 pub fn update_message(&self) -> super::builder::chat_service::UpdateMessage {
446 super::builder::chat_service::UpdateMessage::new(self.inner.clone())
447 }
448
449 /// Deletes a message.
450 /// For an example, see [Delete a
451 /// message](https://developers.google.com/workspace/chat/delete-messages).
452 ///
453 /// Supports the following types of
454 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
455 ///
456 /// - [App
457 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
458 /// with the authorization scope:
459 ///
460 /// - `<https://www.googleapis.com/auth/chat.bot>`
461 /// - [User
462 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
463 /// with one of the following authorization scopes:
464 ///
465 /// - `<https://www.googleapis.com/auth/chat.messages>`
466 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
467 /// only)
468 ///
469 /// When using app authentication, requests can only delete messages
470 /// created by the calling Chat app.
471 ///
472 /// # Example
473 /// ```
474 /// # use google_chat_v1::client::ChatService;
475 /// use google_chat_v1::Result;
476 /// async fn sample(
477 /// client: &ChatService, space_id: &str, message_id: &str
478 /// ) -> Result<()> {
479 /// client.delete_message()
480 /// .set_name(format!("spaces/{space_id}/messages/{message_id}"))
481 /// .send().await?;
482 /// Ok(())
483 /// }
484 /// ```
485 pub fn delete_message(&self) -> super::builder::chat_service::DeleteMessage {
486 super::builder::chat_service::DeleteMessage::new(self.inner.clone())
487 }
488
489 /// Searches for messages in Google Chat that the calling user has access to.
490 /// Returns a list of messages matching the search criteria.
491 ///
492 /// To search across all spaces the user has access to, set `parent` to
493 /// `spaces/-`. Using any other value for `parent` results in an
494 /// `INVALID_ARGUMENT` error. The returned messages have their `name` field
495 /// populated with the full resource name, which includes the specific `space`
496 /// in which the message resides.
497 ///
498 /// This API doesn't return all message types. The types of messages listed
499 /// below aren't included in the response. Use
500 /// [ListMessages][google.chat.v1.ChatService.ListMessages] to list all
501 /// messages.
502 ///
503 /// - Private Messages that are visible to the authenticated user.
504 /// - Messages posted by Chat apps in spaces or group chats.
505 /// - Messages in a Chat app DM.
506 /// - Messages from blocked users.
507 /// - Messages in spaces that the caller has muted.
508 ///
509 /// Requires [user
510 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
511 /// with one of the following [authorization
512 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
513 ///
514 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
515 /// - `<https://www.googleapis.com/auth/chat.messages>`
516 ///
517 /// [google.chat.v1.ChatService.ListMessages]: crate::client::ChatService::list_messages
518 ///
519 /// # Example
520 /// ```
521 /// # use google_chat_v1::client::ChatService;
522 /// use google_cloud_gax::paginator::ItemPaginator as _;
523 /// use google_chat_v1::Result;
524 /// async fn sample(
525 /// client: &ChatService
526 /// ) -> Result<()> {
527 /// let mut list = client.search_messages()
528 /// /* set fields */
529 /// .by_item();
530 /// while let Some(item) = list.next().await.transpose()? {
531 /// println!("{:?}", item);
532 /// }
533 /// Ok(())
534 /// }
535 /// ```
536 pub fn search_messages(&self) -> super::builder::chat_service::SearchMessages {
537 super::builder::chat_service::SearchMessages::new(self.inner.clone())
538 }
539
540 /// Gets the metadata of a message attachment. The attachment data is fetched
541 /// using the [media
542 /// API](https://developers.google.com/workspace/chat/api/reference/rest/v1/media/download).
543 /// For an example, see
544 /// [Get metadata about a message
545 /// attachment](https://developers.google.com/workspace/chat/get-media-attachments).
546 ///
547 /// Requires [app
548 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
549 /// with the [authorization
550 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
551 ///
552 /// - `<https://www.googleapis.com/auth/chat.bot>`
553 ///
554 /// # Example
555 /// ```
556 /// # use google_chat_v1::client::ChatService;
557 /// use google_chat_v1::Result;
558 /// async fn sample(
559 /// client: &ChatService, space_id: &str, message_id: &str, attachment_id: &str
560 /// ) -> Result<()> {
561 /// let response = client.get_attachment()
562 /// .set_name(format!("spaces/{space_id}/messages/{message_id}/attachments/{attachment_id}"))
563 /// .send().await?;
564 /// println!("response {:?}", response);
565 /// Ok(())
566 /// }
567 /// ```
568 pub fn get_attachment(&self) -> super::builder::chat_service::GetAttachment {
569 super::builder::chat_service::GetAttachment::new(self.inner.clone())
570 }
571
572 /// Uploads an attachment. For an example, see
573 /// [Upload media as a file
574 /// attachment](https://developers.google.com/workspace/chat/upload-media-attachments).
575 ///
576 /// Requires user
577 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
578 /// with one of the following [authorization
579 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
580 ///
581 /// - `<https://www.googleapis.com/auth/chat.messages.create>`
582 /// - `<https://www.googleapis.com/auth/chat.messages>`
583 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces only)
584 ///
585 /// You can upload attachments up to 200 MB. Certain file types aren't
586 /// supported. For details, see [File types blocked by Google
587 /// Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat).
588 ///
589 /// # Example
590 /// ```
591 /// # use google_chat_v1::client::ChatService;
592 /// use google_chat_v1::Result;
593 /// async fn sample(
594 /// client: &ChatService
595 /// ) -> Result<()> {
596 /// let response = client.upload_attachment()
597 /// /* set fields */
598 /// .send().await?;
599 /// println!("response {:?}", response);
600 /// Ok(())
601 /// }
602 /// ```
603 pub fn upload_attachment(&self) -> super::builder::chat_service::UploadAttachment {
604 super::builder::chat_service::UploadAttachment::new(self.inner.clone())
605 }
606
607 /// Lists spaces the caller is a member of. Group chats and DMs aren't listed
608 /// until the first message is sent. For an example, see
609 /// [List
610 /// spaces](https://developers.google.com/workspace/chat/list-spaces).
611 ///
612 /// Supports the following types of
613 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
614 ///
615 /// - [App
616 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
617 /// with the authorization scope:
618 ///
619 /// - `<https://www.googleapis.com/auth/chat.bot>`
620 /// - [User
621 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
622 /// with one of the following authorization scopes:
623 ///
624 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
625 /// - `<https://www.googleapis.com/auth/chat.spaces>`
626 ///
627 /// To list all named spaces by Google Workspace organization, use the
628 /// [`spaces.search()`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search)
629 /// method using Workspace administrator privileges instead.
630 ///
631 /// # Example
632 /// ```
633 /// # use google_chat_v1::client::ChatService;
634 /// use google_cloud_gax::paginator::ItemPaginator as _;
635 /// use google_chat_v1::Result;
636 /// async fn sample(
637 /// client: &ChatService
638 /// ) -> Result<()> {
639 /// let mut list = client.list_spaces()
640 /// /* set fields */
641 /// .by_item();
642 /// while let Some(item) = list.next().await.transpose()? {
643 /// println!("{:?}", item);
644 /// }
645 /// Ok(())
646 /// }
647 /// ```
648 pub fn list_spaces(&self) -> super::builder::chat_service::ListSpaces {
649 super::builder::chat_service::ListSpaces::new(self.inner.clone())
650 }
651
652 /// Returns a list of spaces in a Google Workspace organization. For an
653 /// example, see [Search for and manage
654 /// spaces](https://developers.google.com/workspace/chat/search-manage-admin).
655 ///
656 /// When `use_admin_access` is set to `false`, the results are limited to
657 /// spaces where the calling user is a joined member. To search with
658 /// administrator privileges, set `use_admin_access` to `true`.
659 ///
660 /// Supports the following types of
661 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
662 ///
663 /// - [User
664 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
665 /// with one of the following authorization scopes:
666 ///
667 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
668 /// - `<https://www.googleapis.com/auth/chat.spaces>`
669 /// - [User
670 /// authentication with administrator
671 /// privileges](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user#admin-privileges)
672 /// and one of the following [authorization
673 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
674 ///
675 /// - `<https://www.googleapis.com/auth/chat.admin.spaces.readonly>`
676 /// - `<https://www.googleapis.com/auth/chat.admin.spaces>`
677 ///
678 /// # Example
679 /// ```
680 /// # use google_chat_v1::client::ChatService;
681 /// use google_cloud_gax::paginator::ItemPaginator as _;
682 /// use google_chat_v1::Result;
683 /// async fn sample(
684 /// client: &ChatService
685 /// ) -> Result<()> {
686 /// let mut list = client.search_spaces()
687 /// /* set fields */
688 /// .by_item();
689 /// while let Some(item) = list.next().await.transpose()? {
690 /// println!("{:?}", item);
691 /// }
692 /// Ok(())
693 /// }
694 /// ```
695 pub fn search_spaces(&self) -> super::builder::chat_service::SearchSpaces {
696 super::builder::chat_service::SearchSpaces::new(self.inner.clone())
697 }
698
699 /// Returns details about a space. For an example, see
700 /// [Get details about a
701 /// space](https://developers.google.com/workspace/chat/get-spaces).
702 ///
703 /// Supports the following types of
704 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
705 ///
706 /// - [App
707 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
708 /// with one of the following authorization scopes:
709 ///
710 /// - `<https://www.googleapis.com/auth/chat.bot>`
711 /// - `<https://www.googleapis.com/auth/chat.app.spaces>` with [administrator
712 /// approval](https://support.google.com/a?p=chat-app-auth)
713 /// - [User
714 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
715 /// with one of the following authorization scopes:
716 ///
717 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
718 /// - `<https://www.googleapis.com/auth/chat.spaces>`
719 /// - User authentication grants administrator privileges when an
720 /// administrator account authenticates, `use_admin_access` is `true`, and
721 /// one of the following authorization scopes is used:
722 /// - `<https://www.googleapis.com/auth/chat.admin.spaces.readonly>`
723 /// - `<https://www.googleapis.com/auth/chat.admin.spaces>`
724 ///
725 /// App authentication has the following limitations:
726 ///
727 /// - `space.access_settings` is only populated when using the
728 /// `chat.app.spaces` scope.
729 /// - `space.predefind_permission_settings` and `space.permission_settings` are
730 /// only populated when using the `chat.app.spaces` scope, and only for
731 /// spaces the app created.
732 ///
733 /// # Example
734 /// ```
735 /// # use google_chat_v1::client::ChatService;
736 /// use google_chat_v1::Result;
737 /// async fn sample(
738 /// client: &ChatService, space_id: &str
739 /// ) -> Result<()> {
740 /// let response = client.get_space()
741 /// .set_name(format!("spaces/{space_id}"))
742 /// .send().await?;
743 /// println!("response {:?}", response);
744 /// Ok(())
745 /// }
746 /// ```
747 pub fn get_space(&self) -> super::builder::chat_service::GetSpace {
748 super::builder::chat_service::GetSpace::new(self.inner.clone())
749 }
750
751 /// Creates a space. Can be used to create a named space, or a
752 /// group chat in `Import mode`. For an example, see [Create a
753 /// space](https://developers.google.com/workspace/chat/create-spaces).
754 ///
755 /// Supports the following types of
756 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
757 ///
758 /// - [App
759 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
760 /// with [administrator approval](https://support.google.com/a?p=chat-app-auth)
761 /// and one of the following authorization scopes:
762 ///
763 /// - `<https://www.googleapis.com/auth/chat.app.spaces.create>`
764 /// - `<https://www.googleapis.com/auth/chat.app.spaces>`
765 /// - [User
766 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
767 /// with one of the following authorization scopes:
768 ///
769 /// - `<https://www.googleapis.com/auth/chat.spaces.create>`
770 /// - `<https://www.googleapis.com/auth/chat.spaces>`
771 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
772 /// only)
773 ///
774 /// When authenticating as an app, the `space.customer` field must be set in
775 /// the request.
776 ///
777 /// When authenticating as an app, the Chat app is added as a member of the
778 /// space. However, unlike human authentication, the Chat app is not added as a
779 /// space manager. By default, the Chat app can be removed from the space by
780 /// all space members. To allow only space managers to remove the app from a
781 /// space, set `space.permission_settings.manage_apps` to `managers_allowed`.
782 ///
783 /// Space membership upon creation depends on whether the space is created in
784 /// `Import mode`:
785 ///
786 /// * **Import mode:** No members are created.
787 /// * **All other modes:** The calling user is added as a member. This is:
788 /// * The app itself when using app authentication.
789 /// * The human user when using user authentication.
790 ///
791 /// If you receive the error message `ALREADY_EXISTS` when creating
792 /// a space, try a different `displayName`. An existing space within
793 /// the Google Workspace organization might already use this display name.
794 ///
795 /// # Example
796 /// ```
797 /// # use google_chat_v1::client::ChatService;
798 /// use google_chat_v1::Result;
799 /// async fn sample(
800 /// client: &ChatService
801 /// ) -> Result<()> {
802 /// let response = client.create_space()
803 /// /* set fields */
804 /// .send().await?;
805 /// println!("response {:?}", response);
806 /// Ok(())
807 /// }
808 /// ```
809 pub fn create_space(&self) -> super::builder::chat_service::CreateSpace {
810 super::builder::chat_service::CreateSpace::new(self.inner.clone())
811 }
812
813 /// Creates a space and adds specified users to it. The calling user is
814 /// automatically added to the space, and shouldn't be specified as a
815 /// membership in the request. For an example, see
816 /// [Set up a space with initial
817 /// members](https://developers.google.com/workspace/chat/set-up-spaces).
818 ///
819 /// To specify the human members to add, add memberships with the appropriate
820 /// `membership.member.name`. To add a human user, use `users/{user}`, where
821 /// `{user}` can be the email address for the user. For users in the same
822 /// Workspace organization `{user}` can also be the `id` for the person from
823 /// the People API, or the `id` for the user in the Directory API. For example,
824 /// if the People API Person profile ID for `user@example.com` is `123456789`,
825 /// you can add the user to the space by setting the `membership.member.name`
826 /// to `users/user@example.com` or `users/123456789`.
827 ///
828 /// To specify the Google groups to add, add memberships with the
829 /// appropriate `membership.group_member.name`. To add or invite a Google
830 /// group, use `groups/{group}`, where `{group}` is the `id` for the group from
831 /// the Cloud Identity Groups API. For example, you can use [Cloud Identity
832 /// Groups lookup
833 /// API](https://cloud.google.com/identity/docs/reference/rest/v1/groups/lookup)
834 /// to retrieve the ID `123456789` for group email `group@example.com`, then
835 /// you can add the group to the space by setting the
836 /// `membership.group_member.name` to `groups/123456789`. Group email is not
837 /// supported, and Google groups can only be added as members in named spaces.
838 ///
839 /// For a named space or group chat, if the caller blocks, or is blocked
840 /// by some members, or doesn't have permission to add some members, then
841 /// those members aren't added to the created space.
842 ///
843 /// To create a direct message (DM) between the calling user and another human
844 /// user, specify exactly one membership to represent the human user. If
845 /// one user blocks the other, the request fails and the DM isn't created.
846 ///
847 /// To create a DM between the calling user and the calling app, set
848 /// `Space.singleUserBotDm` to `true` and don't specify any memberships. You
849 /// can only use this method to set up a DM with the calling app. To add the
850 /// calling app as a member of a space or an existing DM between two human
851 /// users, see
852 /// [Invite or add a user or app to a
853 /// space](https://developers.google.com/workspace/chat/create-members).
854 ///
855 /// If a DM already exists between two users, even when one user blocks the
856 /// other at the time a request is made, then the existing DM is returned.
857 ///
858 /// Spaces with threaded replies aren't supported. If you receive the error
859 /// message `ALREADY_EXISTS` when setting up a space, try a different
860 /// `displayName`. An existing space within the Google Workspace organization
861 /// might already use this display name.
862 ///
863 /// Requires [user
864 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
865 /// with one of the following [authorization
866 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
867 ///
868 /// - `<https://www.googleapis.com/auth/chat.spaces.create>`
869 /// - `<https://www.googleapis.com/auth/chat.spaces>`
870 ///
871 /// # Example
872 /// ```
873 /// # use google_chat_v1::client::ChatService;
874 /// use google_chat_v1::Result;
875 /// async fn sample(
876 /// client: &ChatService
877 /// ) -> Result<()> {
878 /// let response = client.set_up_space()
879 /// /* set fields */
880 /// .send().await?;
881 /// println!("response {:?}", response);
882 /// Ok(())
883 /// }
884 /// ```
885 pub fn set_up_space(&self) -> super::builder::chat_service::SetUpSpace {
886 super::builder::chat_service::SetUpSpace::new(self.inner.clone())
887 }
888
889 /// Updates a space. For an example, see
890 /// [Update a
891 /// space](https://developers.google.com/workspace/chat/update-spaces).
892 ///
893 /// If you're updating the `displayName` field and receive the error message
894 /// `ALREADY_EXISTS`, try a different display name.. An existing space within
895 /// the Google Workspace organization might already use this display name.
896 ///
897 /// Supports the following types of
898 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
899 ///
900 /// - [App
901 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
902 /// with [administrator approval](https://support.google.com/a?p=chat-app-auth)
903 /// and one of the following authorization scopes:
904 ///
905 /// - `<https://www.googleapis.com/auth/chat.app.spaces>`
906 /// - [User
907 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
908 /// with one of the following authorization scopes:
909 ///
910 /// - `<https://www.googleapis.com/auth/chat.spaces>`
911 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
912 /// only)
913 /// - User authentication grants administrator privileges when an
914 /// administrator account authenticates, `use_admin_access` is `true`, and
915 /// the following authorization scopes is used:
916 /// - `<https://www.googleapis.com/auth/chat.admin.spaces>`
917 ///
918 /// App authentication has the following limitations:
919 ///
920 /// - To update either `space.predefined_permission_settings` or
921 /// `space.permission_settings`, the app must be the space creator.
922 /// - Updating the `space.access_settings.audience` is not supported for app
923 /// authentication.
924 ///
925 /// # Example
926 /// ```
927 /// # use google_chat_v1::client::ChatService;
928 /// # extern crate wkt as google_cloud_wkt;
929 /// use google_cloud_wkt::FieldMask;
930 /// use google_chat_v1::model::Space;
931 /// use google_chat_v1::Result;
932 /// async fn sample(
933 /// client: &ChatService, space_id: &str
934 /// ) -> Result<()> {
935 /// let response = client.update_space()
936 /// .set_space(
937 /// Space::new().set_name(format!("spaces/{space_id}"))/* set fields */
938 /// )
939 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
940 /// .send().await?;
941 /// println!("response {:?}", response);
942 /// Ok(())
943 /// }
944 /// ```
945 pub fn update_space(&self) -> super::builder::chat_service::UpdateSpace {
946 super::builder::chat_service::UpdateSpace::new(self.inner.clone())
947 }
948
949 /// Deletes a named space. Always performs a cascading delete, which means
950 /// that the space's child resources—like messages posted in the space and
951 /// memberships in the space—are also deleted. For an example, see
952 /// [Delete a
953 /// space](https://developers.google.com/workspace/chat/delete-spaces).
954 ///
955 /// Supports the following types of
956 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
957 ///
958 /// - [App
959 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
960 /// with [administrator
961 /// approval](https://support.google.com/a?p=chat-app-auth) and the
962 /// authorization scope:
963 ///
964 /// - `<https://www.googleapis.com/auth/chat.app.delete>` (only in
965 /// spaces the app created)
966 /// - [User
967 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
968 /// with one of the following authorization scopes:
969 ///
970 /// - `<https://www.googleapis.com/auth/chat.delete>`
971 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
972 /// only)
973 /// - User authentication grants administrator privileges when an
974 /// administrator account authenticates, `use_admin_access` is `true`, and
975 /// the following authorization scope is used:
976 /// - `<https://www.googleapis.com/auth/chat.admin.delete>`
977 ///
978 /// # Example
979 /// ```
980 /// # use google_chat_v1::client::ChatService;
981 /// use google_chat_v1::Result;
982 /// async fn sample(
983 /// client: &ChatService, space_id: &str
984 /// ) -> Result<()> {
985 /// client.delete_space()
986 /// .set_name(format!("spaces/{space_id}"))
987 /// .send().await?;
988 /// Ok(())
989 /// }
990 /// ```
991 pub fn delete_space(&self) -> super::builder::chat_service::DeleteSpace {
992 super::builder::chat_service::DeleteSpace::new(self.inner.clone())
993 }
994
995 /// Completes the
996 /// [import process](https://developers.google.com/workspace/chat/import-data)
997 /// for the specified space and makes it visible to users.
998 ///
999 /// Requires [user
1000 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1001 /// and domain-wide delegation with the [authorization
1002 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1003 ///
1004 /// - `<https://www.googleapis.com/auth/chat.import>`
1005 ///
1006 /// For more information, see [Authorize Google
1007 /// Chat apps to import
1008 /// data](https://developers.google.com/workspace/chat/authorize-import).
1009 ///
1010 /// # Example
1011 /// ```
1012 /// # use google_chat_v1::client::ChatService;
1013 /// use google_chat_v1::Result;
1014 /// async fn sample(
1015 /// client: &ChatService
1016 /// ) -> Result<()> {
1017 /// let response = client.complete_import_space()
1018 /// /* set fields */
1019 /// .send().await?;
1020 /// println!("response {:?}", response);
1021 /// Ok(())
1022 /// }
1023 /// ```
1024 pub fn complete_import_space(&self) -> super::builder::chat_service::CompleteImportSpace {
1025 super::builder::chat_service::CompleteImportSpace::new(self.inner.clone())
1026 }
1027
1028 /// Returns the existing direct message with the specified user. If no direct
1029 /// message space is found, returns a `404 NOT_FOUND` error. For an example,
1030 /// see
1031 /// [Find a direct message](/chat/api/guides/v1/spaces/find-direct-message).
1032 ///
1033 /// With [app
1034 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app),
1035 /// returns the direct message space between the specified user and the calling
1036 /// Chat app.
1037 ///
1038 /// With [user
1039 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
1040 /// returns the direct message space between the specified user and the
1041 /// authenticated user.
1042 ///
1043 /// Supports the following types of
1044 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
1045 ///
1046 /// - [App
1047 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1048 /// with the authorization scope:
1049 ///
1050 /// - `<https://www.googleapis.com/auth/chat.bot>`
1051 /// - [User
1052 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1053 /// with one of the following authorization scopes:
1054 ///
1055 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
1056 /// - `<https://www.googleapis.com/auth/chat.spaces>`
1057 ///
1058 /// # Example
1059 /// ```
1060 /// # use google_chat_v1::client::ChatService;
1061 /// use google_chat_v1::Result;
1062 /// async fn sample(
1063 /// client: &ChatService
1064 /// ) -> Result<()> {
1065 /// let response = client.find_direct_message()
1066 /// /* set fields */
1067 /// .send().await?;
1068 /// println!("response {:?}", response);
1069 /// Ok(())
1070 /// }
1071 /// ```
1072 pub fn find_direct_message(&self) -> super::builder::chat_service::FindDirectMessage {
1073 super::builder::chat_service::FindDirectMessage::new(self.inner.clone())
1074 }
1075
1076 /// Returns all spaces with `spaceType == GROUP_CHAT`, whose
1077 /// human memberships contain exactly the calling user, and the users specified
1078 /// in `FindGroupChatsRequest.users`. Only members that have joined the
1079 /// conversation are supported. For an example, see [Find group
1080 /// chats](https://developers.google.com/workspace/chat/find-group-chats).
1081 ///
1082 /// If the calling user blocks, or is blocked by, some users, and no spaces
1083 /// with the entire specified set of users are found, this method returns
1084 /// spaces that don't include the blocked or blocking users.
1085 ///
1086 /// The specified set of users must contain only human (non-app) memberships.
1087 /// A request that contains non-human users doesn't return any spaces.
1088 ///
1089 /// Requires [user
1090 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1091 /// with one of the following [authorization
1092 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1093 ///
1094 /// - `<https://www.googleapis.com/auth/chat.memberships.readonly>`
1095 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1096 ///
1097 /// # Example
1098 /// ```
1099 /// # use google_chat_v1::client::ChatService;
1100 /// use google_cloud_gax::paginator::ItemPaginator as _;
1101 /// use google_chat_v1::Result;
1102 /// async fn sample(
1103 /// client: &ChatService
1104 /// ) -> Result<()> {
1105 /// let mut list = client.find_group_chats()
1106 /// /* set fields */
1107 /// .by_item();
1108 /// while let Some(item) = list.next().await.transpose()? {
1109 /// println!("{:?}", item);
1110 /// }
1111 /// Ok(())
1112 /// }
1113 /// ```
1114 pub fn find_group_chats(&self) -> super::builder::chat_service::FindGroupChats {
1115 super::builder::chat_service::FindGroupChats::new(self.inner.clone())
1116 }
1117
1118 /// Creates a membership for the calling Chat app, a user, or a Google Group.
1119 /// Creating memberships for other Chat apps isn't supported.
1120 /// When creating a membership, if the specified member has their auto-accept
1121 /// policy turned off, then they're invited, and must accept the space
1122 /// invitation before joining. Otherwise, creating a membership adds the member
1123 /// directly to the specified space.
1124 ///
1125 /// Supports the following types of
1126 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
1127 ///
1128 /// - [App
1129 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1130 /// with [administrator approval](https://support.google.com/a?p=chat-app-auth)
1131 /// and the authorization scope:
1132 ///
1133 /// - `<https://www.googleapis.com/auth/chat.app.memberships>`
1134 /// - [User
1135 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1136 /// with one of the following authorization scopes:
1137 ///
1138 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1139 /// - `<https://www.googleapis.com/auth/chat.memberships.app>` (to add the
1140 /// calling app to the space)
1141 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
1142 /// only)
1143 /// - User authentication grants administrator privileges when an
1144 /// administrator account authenticates, `use_admin_access` is `true`, and
1145 /// the following authorization scope is used:
1146 /// - `<https://www.googleapis.com/auth/chat.admin.memberships>`
1147 ///
1148 /// App authentication is not supported for the following use cases:
1149 ///
1150 /// - Inviting users external to the Workspace organization that owns the
1151 /// space.
1152 /// - Adding a Google Group to a space.
1153 /// - Adding a Chat app to a space.
1154 ///
1155 /// For example usage, see:
1156 ///
1157 /// - [Invite or add a user to a
1158 /// space](https://developers.google.com/workspace/chat/create-members#create-user-membership).
1159 /// - [Invite or add a Google Group to a
1160 /// space](https://developers.google.com/workspace/chat/create-members#create-group-membership).
1161 /// - [Add the Chat app to a
1162 /// space](https://developers.google.com/workspace/chat/create-members#create-membership-calling-api).
1163 ///
1164 /// # Example
1165 /// ```
1166 /// # use google_chat_v1::client::ChatService;
1167 /// use google_chat_v1::model::Membership;
1168 /// use google_chat_v1::Result;
1169 /// async fn sample(
1170 /// client: &ChatService, space_id: &str
1171 /// ) -> Result<()> {
1172 /// let response = client.create_membership()
1173 /// .set_parent(format!("spaces/{space_id}"))
1174 /// .set_membership(
1175 /// Membership::new()/* set fields */
1176 /// )
1177 /// .send().await?;
1178 /// println!("response {:?}", response);
1179 /// Ok(())
1180 /// }
1181 /// ```
1182 pub fn create_membership(&self) -> super::builder::chat_service::CreateMembership {
1183 super::builder::chat_service::CreateMembership::new(self.inner.clone())
1184 }
1185
1186 /// Updates a membership. For an example, see [Update a user's membership in
1187 /// a space](https://developers.google.com/workspace/chat/update-members).
1188 ///
1189 /// Supports the following types of
1190 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
1191 ///
1192 /// - [App
1193 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1194 /// with [administrator
1195 /// approval](https://support.google.com/a?p=chat-app-auth) and the
1196 /// authorization scope:
1197 ///
1198 /// - `<https://www.googleapis.com/auth/chat.app.memberships>` (only in
1199 /// spaces the app created)
1200 /// - [User
1201 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1202 /// with one of the following authorization scopes:
1203 ///
1204 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1205 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
1206 /// only)
1207 /// - User authentication grants administrator privileges when an
1208 /// administrator account authenticates, `use_admin_access` is `true`, and
1209 /// the following authorization scope is used:
1210 /// - `<https://www.googleapis.com/auth/chat.admin.memberships>`
1211 ///
1212 /// # Example
1213 /// ```
1214 /// # use google_chat_v1::client::ChatService;
1215 /// # extern crate wkt as google_cloud_wkt;
1216 /// use google_cloud_wkt::FieldMask;
1217 /// use google_chat_v1::model::Membership;
1218 /// use google_chat_v1::Result;
1219 /// async fn sample(
1220 /// client: &ChatService, space_id: &str, member_id: &str
1221 /// ) -> Result<()> {
1222 /// let response = client.update_membership()
1223 /// .set_membership(
1224 /// Membership::new().set_name(format!("spaces/{space_id}/members/{member_id}"))/* set fields */
1225 /// )
1226 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1227 /// .send().await?;
1228 /// println!("response {:?}", response);
1229 /// Ok(())
1230 /// }
1231 /// ```
1232 pub fn update_membership(&self) -> super::builder::chat_service::UpdateMembership {
1233 super::builder::chat_service::UpdateMembership::new(self.inner.clone())
1234 }
1235
1236 /// Deletes a membership. For an example, see
1237 /// [Remove a user or a Google Chat app from a
1238 /// space](https://developers.google.com/workspace/chat/delete-members).
1239 ///
1240 /// Supports the following types of
1241 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):
1242 ///
1243 /// - [App
1244 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1245 /// with [administrator approval](https://support.google.com/a?p=chat-app-auth)
1246 /// and the authorization scope:
1247 ///
1248 /// - `<https://www.googleapis.com/auth/chat.app.memberships>`
1249 /// - [User
1250 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1251 /// with one of the following authorization scopes:
1252 ///
1253 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1254 /// - `<https://www.googleapis.com/auth/chat.memberships.app>` (to remove
1255 /// the calling app from the space)
1256 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces
1257 /// only)
1258 /// - User authentication grants administrator privileges when an
1259 /// administrator account authenticates, `use_admin_access` is `true`, and
1260 /// the following authorization scope is used:
1261 /// - `<https://www.googleapis.com/auth/chat.admin.memberships>`
1262 ///
1263 /// App authentication is not supported for the following use cases:
1264 ///
1265 /// - Removing a Google Group from a space.
1266 /// - Removing a Chat app from a space.
1267 ///
1268 /// To delete memberships for space managers, the requester
1269 /// must be a space manager. If you're using [app
1270 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1271 /// the Chat app must be the space creator.
1272 ///
1273 /// # Example
1274 /// ```
1275 /// # use google_chat_v1::client::ChatService;
1276 /// use google_chat_v1::Result;
1277 /// async fn sample(
1278 /// client: &ChatService, space_id: &str, member_id: &str
1279 /// ) -> Result<()> {
1280 /// let response = client.delete_membership()
1281 /// .set_name(format!("spaces/{space_id}/members/{member_id}"))
1282 /// .send().await?;
1283 /// println!("response {:?}", response);
1284 /// Ok(())
1285 /// }
1286 /// ```
1287 pub fn delete_membership(&self) -> super::builder::chat_service::DeleteMembership {
1288 super::builder::chat_service::DeleteMembership::new(self.inner.clone())
1289 }
1290
1291 /// Creates a reaction and adds it to a message. For an example, see
1292 /// [Add a reaction to a
1293 /// message](https://developers.google.com/workspace/chat/create-reactions).
1294 ///
1295 /// Requires [user
1296 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1297 /// with one of the following [authorization
1298 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1299 ///
1300 /// - `<https://www.googleapis.com/auth/chat.messages.reactions.create>`
1301 /// - `<https://www.googleapis.com/auth/chat.messages.reactions>`
1302 /// - `<https://www.googleapis.com/auth/chat.messages>`
1303 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces only)
1304 ///
1305 /// # Example
1306 /// ```
1307 /// # use google_chat_v1::client::ChatService;
1308 /// use google_chat_v1::model::Reaction;
1309 /// use google_chat_v1::Result;
1310 /// async fn sample(
1311 /// client: &ChatService, space_id: &str, message_id: &str
1312 /// ) -> Result<()> {
1313 /// let response = client.create_reaction()
1314 /// .set_parent(format!("spaces/{space_id}/messages/{message_id}"))
1315 /// .set_reaction(
1316 /// Reaction::new()/* set fields */
1317 /// )
1318 /// .send().await?;
1319 /// println!("response {:?}", response);
1320 /// Ok(())
1321 /// }
1322 /// ```
1323 pub fn create_reaction(&self) -> super::builder::chat_service::CreateReaction {
1324 super::builder::chat_service::CreateReaction::new(self.inner.clone())
1325 }
1326
1327 /// Lists reactions to a message. For an example, see
1328 /// [List reactions for a
1329 /// message](https://developers.google.com/workspace/chat/list-reactions).
1330 ///
1331 /// Requires [user
1332 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1333 /// with one of the following [authorization
1334 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1335 ///
1336 /// - `<https://www.googleapis.com/auth/chat.messages.reactions.readonly>`
1337 /// - `<https://www.googleapis.com/auth/chat.messages.reactions>`
1338 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
1339 /// - `<https://www.googleapis.com/auth/chat.messages>`
1340 ///
1341 /// # Example
1342 /// ```
1343 /// # use google_chat_v1::client::ChatService;
1344 /// use google_cloud_gax::paginator::ItemPaginator as _;
1345 /// use google_chat_v1::Result;
1346 /// async fn sample(
1347 /// client: &ChatService, space_id: &str, message_id: &str
1348 /// ) -> Result<()> {
1349 /// let mut list = client.list_reactions()
1350 /// .set_parent(format!("spaces/{space_id}/messages/{message_id}"))
1351 /// .by_item();
1352 /// while let Some(item) = list.next().await.transpose()? {
1353 /// println!("{:?}", item);
1354 /// }
1355 /// Ok(())
1356 /// }
1357 /// ```
1358 pub fn list_reactions(&self) -> super::builder::chat_service::ListReactions {
1359 super::builder::chat_service::ListReactions::new(self.inner.clone())
1360 }
1361
1362 /// Deletes a reaction to a message. For an example, see
1363 /// [Delete a
1364 /// reaction](https://developers.google.com/workspace/chat/delete-reactions).
1365 ///
1366 /// Requires [user
1367 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1368 /// with one of the following [authorization
1369 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1370 ///
1371 /// - `<https://www.googleapis.com/auth/chat.messages.reactions>`
1372 /// - `<https://www.googleapis.com/auth/chat.messages>`
1373 /// - `<https://www.googleapis.com/auth/chat.import>` (import mode spaces only)
1374 ///
1375 /// # Example
1376 /// ```
1377 /// # use google_chat_v1::client::ChatService;
1378 /// use google_chat_v1::Result;
1379 /// async fn sample(
1380 /// client: &ChatService, space_id: &str, message_id: &str, reaction_id: &str
1381 /// ) -> Result<()> {
1382 /// client.delete_reaction()
1383 /// .set_name(format!("spaces/{space_id}/messages/{message_id}/reactions/{reaction_id}"))
1384 /// .send().await?;
1385 /// Ok(())
1386 /// }
1387 /// ```
1388 pub fn delete_reaction(&self) -> super::builder::chat_service::DeleteReaction {
1389 super::builder::chat_service::DeleteReaction::new(self.inner.clone())
1390 }
1391
1392 /// Creates a custom emoji.
1393 ///
1394 /// Custom emojis are only available for Google Workspace accounts, and the
1395 /// administrator must turn custom emojis on for the organization. For more
1396 /// information, see [Learn about custom emojis in Google
1397 /// Chat](https://support.google.com/chat/answer/12800149) and
1398 /// [Manage custom emoji
1399 /// permissions](https://support.google.com/a/answer/12850085).
1400 ///
1401 /// Requires [user
1402 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1403 /// with the [authorization
1404 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1405 ///
1406 /// - `<https://www.googleapis.com/auth/chat.customemojis>`
1407 ///
1408 /// # Example
1409 /// ```
1410 /// # use google_chat_v1::client::ChatService;
1411 /// use google_chat_v1::Result;
1412 /// async fn sample(
1413 /// client: &ChatService
1414 /// ) -> Result<()> {
1415 /// let response = client.create_custom_emoji()
1416 /// /* set fields */
1417 /// .send().await?;
1418 /// println!("response {:?}", response);
1419 /// Ok(())
1420 /// }
1421 /// ```
1422 pub fn create_custom_emoji(&self) -> super::builder::chat_service::CreateCustomEmoji {
1423 super::builder::chat_service::CreateCustomEmoji::new(self.inner.clone())
1424 }
1425
1426 /// Returns details about a custom emoji.
1427 ///
1428 /// Custom emojis are only available for Google Workspace accounts, and the
1429 /// administrator must turn custom emojis on for the organization. For more
1430 /// information, see [Learn about custom emojis in Google
1431 /// Chat](https://support.google.com/chat/answer/12800149) and
1432 /// [Manage custom emoji
1433 /// permissions](https://support.google.com/a/answer/12850085).
1434 ///
1435 /// Requires [user
1436 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1437 /// with one of the following [authorization
1438 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1439 ///
1440 /// - `<https://www.googleapis.com/auth/chat.customemojis.readonly>`
1441 /// - `<https://www.googleapis.com/auth/chat.customemojis>`
1442 ///
1443 /// # Example
1444 /// ```
1445 /// # use google_chat_v1::client::ChatService;
1446 /// use google_chat_v1::Result;
1447 /// async fn sample(
1448 /// client: &ChatService, custom_emoji_id: &str
1449 /// ) -> Result<()> {
1450 /// let response = client.get_custom_emoji()
1451 /// .set_name(format!("customEmojis/{custom_emoji_id}"))
1452 /// .send().await?;
1453 /// println!("response {:?}", response);
1454 /// Ok(())
1455 /// }
1456 /// ```
1457 pub fn get_custom_emoji(&self) -> super::builder::chat_service::GetCustomEmoji {
1458 super::builder::chat_service::GetCustomEmoji::new(self.inner.clone())
1459 }
1460
1461 /// Lists custom emojis visible to the authenticated user.
1462 ///
1463 /// Custom emojis are only available for Google Workspace accounts, and the
1464 /// administrator must turn custom emojis on for the organization. For more
1465 /// information, see [Learn about custom emojis in Google
1466 /// Chat](https://support.google.com/chat/answer/12800149) and
1467 /// [Manage custom emoji
1468 /// permissions](https://support.google.com/a/answer/12850085).
1469 ///
1470 /// Requires [user
1471 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1472 /// with one of the following [authorization
1473 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1474 ///
1475 /// - `<https://www.googleapis.com/auth/chat.customemojis.readonly>`
1476 /// - `<https://www.googleapis.com/auth/chat.customemojis>`
1477 ///
1478 /// # Example
1479 /// ```
1480 /// # use google_chat_v1::client::ChatService;
1481 /// use google_cloud_gax::paginator::ItemPaginator as _;
1482 /// use google_chat_v1::Result;
1483 /// async fn sample(
1484 /// client: &ChatService
1485 /// ) -> Result<()> {
1486 /// let mut list = client.list_custom_emojis()
1487 /// /* set fields */
1488 /// .by_item();
1489 /// while let Some(item) = list.next().await.transpose()? {
1490 /// println!("{:?}", item);
1491 /// }
1492 /// Ok(())
1493 /// }
1494 /// ```
1495 pub fn list_custom_emojis(&self) -> super::builder::chat_service::ListCustomEmojis {
1496 super::builder::chat_service::ListCustomEmojis::new(self.inner.clone())
1497 }
1498
1499 /// Deletes a custom emoji. By default, users can only delete custom emoji they
1500 /// created. [Emoji managers](https://support.google.com/a/answer/12850085)
1501 /// assigned by the administrator can delete any custom emoji in the
1502 /// organization. See [Learn about custom emojis in Google
1503 /// Chat](https://support.google.com/chat/answer/12800149).
1504 ///
1505 /// Custom emojis are only available for Google Workspace accounts, and the
1506 /// administrator must turn custom emojis on for the organization. For more
1507 /// information, see [Learn about custom emojis in Google
1508 /// Chat](https://support.google.com/chat/answer/12800149) and
1509 /// [Manage custom emoji
1510 /// permissions](https://support.google.com/a/answer/12850085).
1511 ///
1512 /// Requires [user
1513 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1514 /// with the [authorization
1515 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1516 ///
1517 /// - `<https://www.googleapis.com/auth/chat.customemojis>`
1518 ///
1519 /// # Example
1520 /// ```
1521 /// # use google_chat_v1::client::ChatService;
1522 /// use google_chat_v1::Result;
1523 /// async fn sample(
1524 /// client: &ChatService, custom_emoji_id: &str
1525 /// ) -> Result<()> {
1526 /// client.delete_custom_emoji()
1527 /// .set_name(format!("customEmojis/{custom_emoji_id}"))
1528 /// .send().await?;
1529 /// Ok(())
1530 /// }
1531 /// ```
1532 pub fn delete_custom_emoji(&self) -> super::builder::chat_service::DeleteCustomEmoji {
1533 super::builder::chat_service::DeleteCustomEmoji::new(self.inner.clone())
1534 }
1535
1536 /// Returns details about a user's read state within a space, used to identify
1537 /// read and unread messages. For an example, see [Get details about a user's
1538 /// space read
1539 /// state](https://developers.google.com/workspace/chat/get-space-read-state).
1540 ///
1541 /// Requires [user
1542 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1543 /// with one of the following [authorization
1544 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1545 ///
1546 /// - `<https://www.googleapis.com/auth/chat.users.readstate.readonly>`
1547 /// - `<https://www.googleapis.com/auth/chat.users.readstate>`
1548 ///
1549 /// # Example
1550 /// ```
1551 /// # use google_chat_v1::client::ChatService;
1552 /// use google_chat_v1::Result;
1553 /// async fn sample(
1554 /// client: &ChatService, user_id: &str, space_id: &str
1555 /// ) -> Result<()> {
1556 /// let response = client.get_space_read_state()
1557 /// .set_name(format!("users/{user_id}/spaces/{space_id}/spaceReadState"))
1558 /// .send().await?;
1559 /// println!("response {:?}", response);
1560 /// Ok(())
1561 /// }
1562 /// ```
1563 pub fn get_space_read_state(&self) -> super::builder::chat_service::GetSpaceReadState {
1564 super::builder::chat_service::GetSpaceReadState::new(self.inner.clone())
1565 }
1566
1567 /// Updates a user's read state within a space, used to identify read and
1568 /// unread messages. For an example, see [Update a user's space read
1569 /// state](https://developers.google.com/workspace/chat/update-space-read-state).
1570 ///
1571 /// Requires [user
1572 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1573 /// with the [authorization
1574 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1575 ///
1576 /// - `<https://www.googleapis.com/auth/chat.users.readstate>`
1577 ///
1578 /// # Example
1579 /// ```
1580 /// # use google_chat_v1::client::ChatService;
1581 /// # extern crate wkt as google_cloud_wkt;
1582 /// use google_cloud_wkt::FieldMask;
1583 /// use google_chat_v1::model::SpaceReadState;
1584 /// use google_chat_v1::Result;
1585 /// async fn sample(
1586 /// client: &ChatService, user_id: &str, space_id: &str
1587 /// ) -> Result<()> {
1588 /// let response = client.update_space_read_state()
1589 /// .set_space_read_state(
1590 /// SpaceReadState::new().set_name(format!("users/{user_id}/spaces/{space_id}/spaceReadState"))/* set fields */
1591 /// )
1592 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1593 /// .send().await?;
1594 /// println!("response {:?}", response);
1595 /// Ok(())
1596 /// }
1597 /// ```
1598 pub fn update_space_read_state(&self) -> super::builder::chat_service::UpdateSpaceReadState {
1599 super::builder::chat_service::UpdateSpaceReadState::new(self.inner.clone())
1600 }
1601
1602 /// Returns details about a user's read state within a thread, used to identify
1603 /// read and unread messages. For an example, see [Get details about a user's
1604 /// thread read
1605 /// state](https://developers.google.com/workspace/chat/get-thread-read-state).
1606 ///
1607 /// Requires [user
1608 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1609 /// with one of the following [authorization
1610 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1611 ///
1612 /// - `<https://www.googleapis.com/auth/chat.users.readstate.readonly>`
1613 /// - `<https://www.googleapis.com/auth/chat.users.readstate>`
1614 ///
1615 /// # Example
1616 /// ```
1617 /// # use google_chat_v1::client::ChatService;
1618 /// use google_chat_v1::Result;
1619 /// async fn sample(
1620 /// client: &ChatService, user_id: &str, space_id: &str, thread_id: &str
1621 /// ) -> Result<()> {
1622 /// let response = client.get_thread_read_state()
1623 /// .set_name(format!("users/{user_id}/spaces/{space_id}/threads/{thread_id}/threadReadState"))
1624 /// .send().await?;
1625 /// println!("response {:?}", response);
1626 /// Ok(())
1627 /// }
1628 /// ```
1629 pub fn get_thread_read_state(&self) -> super::builder::chat_service::GetThreadReadState {
1630 super::builder::chat_service::GetThreadReadState::new(self.inner.clone())
1631 }
1632
1633 /// Returns availability information for a human user in Google Chat. For
1634 /// example, this can be used to check if a user is online or away, or to
1635 /// retrieve their custom status message.
1636 ///
1637 /// This method only retrieves the authenticated user's availability.
1638 ///
1639 /// Requires [user
1640 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1641 /// with one of the following [authorization
1642 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1643 ///
1644 /// - `<https://www.googleapis.com/auth/chat.users.availability.readonly>`
1645 /// - `<https://www.googleapis.com/auth/chat.users.availability>`
1646 ///
1647 /// # Example
1648 /// ```
1649 /// # use google_chat_v1::client::ChatService;
1650 /// use google_chat_v1::Result;
1651 /// async fn sample(
1652 /// client: &ChatService, user_id: &str
1653 /// ) -> Result<()> {
1654 /// let response = client.get_availability()
1655 /// .set_name(format!("users/{user_id}/availability"))
1656 /// .send().await?;
1657 /// println!("response {:?}", response);
1658 /// Ok(())
1659 /// }
1660 /// ```
1661 pub fn get_availability(&self) -> super::builder::chat_service::GetAvailability {
1662 super::builder::chat_service::GetAvailability::new(self.inner.clone())
1663 }
1664
1665 /// Marks user as `ACTIVE` in Google Chat.
1666 ///
1667 /// Sets the user's availability state to `ACTIVE`. The `ACTIVE` state
1668 /// lasts until the specified expiration, at which point the user's state
1669 /// becomes `AWAY`. Note that if the user is actively using Chat, the `ACTIVE`
1670 /// state duration may extend beyond the provided expiration.
1671 ///
1672 /// This method only updates the authenticated user's availability.
1673 ///
1674 /// Requires [user
1675 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1676 /// with [authorization
1677 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1678 ///
1679 /// - `<https://www.googleapis.com/auth/chat.users.availability>`
1680 ///
1681 /// # Example
1682 /// ```
1683 /// # use google_chat_v1::client::ChatService;
1684 /// use google_chat_v1::Result;
1685 /// async fn sample(
1686 /// client: &ChatService
1687 /// ) -> Result<()> {
1688 /// let response = client.mark_as_active()
1689 /// /* set fields */
1690 /// .send().await?;
1691 /// println!("response {:?}", response);
1692 /// Ok(())
1693 /// }
1694 /// ```
1695 pub fn mark_as_active(&self) -> super::builder::chat_service::MarkAsActive {
1696 super::builder::chat_service::MarkAsActive::new(self.inner.clone())
1697 }
1698
1699 /// Marks user as `AWAY` in Google Chat.
1700 ///
1701 /// Sets the user's state to away and is not affected by the user's
1702 /// activity.
1703 ///
1704 /// This method only updates the authenticated user's availability.
1705 ///
1706 /// Requires [user
1707 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1708 /// with [authorization
1709 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1710 ///
1711 /// - `<https://www.googleapis.com/auth/chat.users.availability>`
1712 ///
1713 /// # Example
1714 /// ```
1715 /// # use google_chat_v1::client::ChatService;
1716 /// use google_chat_v1::Result;
1717 /// async fn sample(
1718 /// client: &ChatService
1719 /// ) -> Result<()> {
1720 /// let response = client.mark_as_away()
1721 /// /* set fields */
1722 /// .send().await?;
1723 /// println!("response {:?}", response);
1724 /// Ok(())
1725 /// }
1726 /// ```
1727 pub fn mark_as_away(&self) -> super::builder::chat_service::MarkAsAway {
1728 super::builder::chat_service::MarkAsAway::new(self.inner.clone())
1729 }
1730
1731 /// Marks user as `DO_NOT_DISTURB` in Google Chat.
1732 ///
1733 /// Sets a user's availability state to `DO_NOT_DISTURB` until a specified
1734 /// expiration time.
1735 /// When in `DO_NOT_DISTURB`, users typically won't receive notifications.
1736 ///
1737 /// This method only updates the authenticated user's availability.
1738 ///
1739 /// Requires [user
1740 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1741 /// with [authorization
1742 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1743 ///
1744 /// - `<https://www.googleapis.com/auth/chat.users.availability>`
1745 ///
1746 /// # Example
1747 /// ```
1748 /// # use google_chat_v1::client::ChatService;
1749 /// use google_chat_v1::Result;
1750 /// async fn sample(
1751 /// client: &ChatService
1752 /// ) -> Result<()> {
1753 /// let response = client.mark_as_do_not_disturb()
1754 /// /* set fields */
1755 /// .send().await?;
1756 /// println!("response {:?}", response);
1757 /// Ok(())
1758 /// }
1759 /// ```
1760 pub fn mark_as_do_not_disturb(&self) -> super::builder::chat_service::MarkAsDoNotDisturb {
1761 super::builder::chat_service::MarkAsDoNotDisturb::new(self.inner.clone())
1762 }
1763
1764 /// Updates availability information for a human user. Only the `custom_status`
1765 /// field can be updated through this method.
1766 ///
1767 /// This method only updates the authenticated user's availability.
1768 ///
1769 /// Requires [user
1770 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1771 /// with one of the following [authorization
1772 /// scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1773 ///
1774 /// - `<https://www.googleapis.com/auth/chat.users.availability>`
1775 ///
1776 /// # Example
1777 /// ```
1778 /// # use google_chat_v1::client::ChatService;
1779 /// # extern crate wkt as google_cloud_wkt;
1780 /// use google_cloud_wkt::FieldMask;
1781 /// use google_chat_v1::model::Availability;
1782 /// use google_chat_v1::Result;
1783 /// async fn sample(
1784 /// client: &ChatService, user_id: &str
1785 /// ) -> Result<()> {
1786 /// let response = client.update_availability()
1787 /// .set_availability(
1788 /// Availability::new().set_name(format!("users/{user_id}/availability"))/* set fields */
1789 /// )
1790 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1791 /// .send().await?;
1792 /// println!("response {:?}", response);
1793 /// Ok(())
1794 /// }
1795 /// ```
1796 pub fn update_availability(&self) -> super::builder::chat_service::UpdateAvailability {
1797 super::builder::chat_service::UpdateAvailability::new(self.inner.clone())
1798 }
1799
1800 /// Returns an event from a Google Chat space. The [event
1801 /// payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload)
1802 /// contains the most recent version of the resource that changed. For example,
1803 /// if you request an event about a new message but the message was later
1804 /// updated, the server returns the updated `Message` resource in the event
1805 /// payload.
1806 ///
1807 /// Note: The `permissionSettings` field is not returned in the Space
1808 /// object of the Space event data for this request.
1809 ///
1810 /// Supports the following types of
1811 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize)
1812 /// with an
1813 /// [authorization
1814 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes)
1815 /// appropriate for reading the requested data:
1816 ///
1817 /// - [App
1818 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1819 /// with [administrator
1820 /// approval](https://support.google.com/a?p=chat-app-auth)
1821 /// with one of the following authorization scopes:
1822 ///
1823 /// - `<https://www.googleapis.com/auth/chat.app.spaces>`
1824 /// - `<https://www.googleapis.com/auth/chat.app.spaces.readonly>`
1825 /// - `<https://www.googleapis.com/auth/chat.app.messages.readonly>`
1826 /// - `<https://www.googleapis.com/auth/chat.app.memberships>`
1827 /// - `<https://www.googleapis.com/auth/chat.app.memberships.readonly>`
1828 /// - [User
1829 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1830 /// with one of the following authorization scopes:
1831 ///
1832 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
1833 /// - `<https://www.googleapis.com/auth/chat.spaces>`
1834 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
1835 /// - `<https://www.googleapis.com/auth/chat.messages>`
1836 /// - `<https://www.googleapis.com/auth/chat.messages.reactions.readonly>`
1837 /// - `<https://www.googleapis.com/auth/chat.messages.reactions>`
1838 /// - `<https://www.googleapis.com/auth/chat.memberships.readonly>`
1839 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1840 ///
1841 /// To get an event, the authenticated caller must be a member of the space.
1842 ///
1843 /// For an example, see [Get details about an
1844 /// event from a Google Chat
1845 /// space](https://developers.google.com/workspace/chat/get-space-event).
1846 ///
1847 /// # Example
1848 /// ```
1849 /// # use google_chat_v1::client::ChatService;
1850 /// use google_chat_v1::Result;
1851 /// async fn sample(
1852 /// client: &ChatService, space_id: &str, space_event_id: &str
1853 /// ) -> Result<()> {
1854 /// let response = client.get_space_event()
1855 /// .set_name(format!("spaces/{space_id}/spaceEvents/{space_event_id}"))
1856 /// .send().await?;
1857 /// println!("response {:?}", response);
1858 /// Ok(())
1859 /// }
1860 /// ```
1861 pub fn get_space_event(&self) -> super::builder::chat_service::GetSpaceEvent {
1862 super::builder::chat_service::GetSpaceEvent::new(self.inner.clone())
1863 }
1864
1865 /// Lists events from a Google Chat space. For each event, the
1866 /// [payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload)
1867 /// contains the most recent version of the Chat resource. For example, if you
1868 /// list events about new space members, the server returns `Membership`
1869 /// resources that contain the latest membership details. If new members were
1870 /// removed during the requested period, the event payload contains an empty
1871 /// `Membership` resource.
1872 ///
1873 /// Supports the following types of
1874 /// [authentication](https://developers.google.com/workspace/chat/authenticate-authorize)
1875 /// with an
1876 /// [authorization
1877 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes)
1878 /// appropriate for reading the requested data:
1879 ///
1880 /// - [App
1881 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
1882 /// with [administrator
1883 /// approval](https://support.google.com/a?p=chat-app-auth)
1884 /// with one of the following authorization scopes:
1885 ///
1886 /// - `<https://www.googleapis.com/auth/chat.app.spaces>`
1887 /// - `<https://www.googleapis.com/auth/chat.app.spaces.readonly>`
1888 /// - `<https://www.googleapis.com/auth/chat.app.messages.readonly>`
1889 /// - `<https://www.googleapis.com/auth/chat.app.memberships>`
1890 /// - `<https://www.googleapis.com/auth/chat.app.memberships.readonly>`
1891 /// - [User
1892 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1893 /// with one of the following authorization scopes:
1894 ///
1895 /// - `<https://www.googleapis.com/auth/chat.spaces.readonly>`
1896 /// - `<https://www.googleapis.com/auth/chat.spaces>`
1897 /// - `<https://www.googleapis.com/auth/chat.messages.readonly>`
1898 /// - `<https://www.googleapis.com/auth/chat.messages>`
1899 /// - `<https://www.googleapis.com/auth/chat.messages.reactions.readonly>`
1900 /// - `<https://www.googleapis.com/auth/chat.messages.reactions>`
1901 /// - `<https://www.googleapis.com/auth/chat.memberships.readonly>`
1902 /// - `<https://www.googleapis.com/auth/chat.memberships>`
1903 ///
1904 /// To list events, the authenticated caller must be a member of the space.
1905 ///
1906 /// For an example, see [List events from a Google Chat
1907 /// space](https://developers.google.com/workspace/chat/list-space-events).
1908 ///
1909 /// # Example
1910 /// ```
1911 /// # use google_chat_v1::client::ChatService;
1912 /// use google_cloud_gax::paginator::ItemPaginator as _;
1913 /// use google_chat_v1::Result;
1914 /// async fn sample(
1915 /// client: &ChatService, space_id: &str
1916 /// ) -> Result<()> {
1917 /// let mut list = client.list_space_events()
1918 /// .set_parent(format!("spaces/{space_id}"))
1919 /// .by_item();
1920 /// while let Some(item) = list.next().await.transpose()? {
1921 /// println!("{:?}", item);
1922 /// }
1923 /// Ok(())
1924 /// }
1925 /// ```
1926 pub fn list_space_events(&self) -> super::builder::chat_service::ListSpaceEvents {
1927 super::builder::chat_service::ListSpaceEvents::new(self.inner.clone())
1928 }
1929
1930 /// Gets the space notification setting. For an example, see [Get the
1931 /// caller's space notification
1932 /// setting](https://developers.google.com/workspace/chat/get-space-notification-setting).
1933 ///
1934 /// Requires [user
1935 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1936 /// with the [authorization
1937 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1938 ///
1939 /// - `<https://www.googleapis.com/auth/chat.users.spacesettings>`
1940 ///
1941 /// # Example
1942 /// ```
1943 /// # use google_chat_v1::client::ChatService;
1944 /// use google_chat_v1::Result;
1945 /// async fn sample(
1946 /// client: &ChatService, user_id: &str, space_id: &str
1947 /// ) -> Result<()> {
1948 /// let response = client.get_space_notification_setting()
1949 /// .set_name(format!("users/{user_id}/spaces/{space_id}/spaceNotificationSetting"))
1950 /// .send().await?;
1951 /// println!("response {:?}", response);
1952 /// Ok(())
1953 /// }
1954 /// ```
1955 pub fn get_space_notification_setting(
1956 &self,
1957 ) -> super::builder::chat_service::GetSpaceNotificationSetting {
1958 super::builder::chat_service::GetSpaceNotificationSetting::new(self.inner.clone())
1959 }
1960
1961 /// Updates the space notification setting. For an example, see [Update
1962 /// the caller's space notification
1963 /// setting](https://developers.google.com/workspace/chat/update-space-notification-setting).
1964 ///
1965 /// Requires [user
1966 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
1967 /// with the [authorization
1968 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
1969 ///
1970 /// - `<https://www.googleapis.com/auth/chat.users.spacesettings>`
1971 ///
1972 /// # Example
1973 /// ```
1974 /// # use google_chat_v1::client::ChatService;
1975 /// # extern crate wkt as google_cloud_wkt;
1976 /// use google_cloud_wkt::FieldMask;
1977 /// use google_chat_v1::model::SpaceNotificationSetting;
1978 /// use google_chat_v1::Result;
1979 /// async fn sample(
1980 /// client: &ChatService, user_id: &str, space_id: &str
1981 /// ) -> Result<()> {
1982 /// let response = client.update_space_notification_setting()
1983 /// .set_space_notification_setting(
1984 /// SpaceNotificationSetting::new().set_name(format!("users/{user_id}/spaces/{space_id}/spaceNotificationSetting"))/* set fields */
1985 /// )
1986 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
1987 /// .send().await?;
1988 /// println!("response {:?}", response);
1989 /// Ok(())
1990 /// }
1991 /// ```
1992 pub fn update_space_notification_setting(
1993 &self,
1994 ) -> super::builder::chat_service::UpdateSpaceNotificationSetting {
1995 super::builder::chat_service::UpdateSpaceNotificationSetting::new(self.inner.clone())
1996 }
1997
1998 /// Creates a section in Google Chat. Sections help users group conversations
1999 /// and customize the list of spaces displayed in Chat navigation panel. Only
2000 /// sections of type `CUSTOM_SECTION` can be created. For details, see [Create
2001 /// and organize sections in Google
2002 /// Chat](https://support.google.com/chat/answer/16059854).
2003 ///
2004 /// Requires [user
2005 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2006 /// with the [authorization
2007 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2008 ///
2009 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2010 ///
2011 /// # Example
2012 /// ```
2013 /// # use google_chat_v1::client::ChatService;
2014 /// use google_chat_v1::model::Section;
2015 /// use google_chat_v1::Result;
2016 /// async fn sample(
2017 /// client: &ChatService, parent: &str
2018 /// ) -> Result<()> {
2019 /// let response = client.create_section()
2020 /// .set_parent(parent)
2021 /// .set_section(
2022 /// Section::new()/* set fields */
2023 /// )
2024 /// .send().await?;
2025 /// println!("response {:?}", response);
2026 /// Ok(())
2027 /// }
2028 /// ```
2029 pub fn create_section(&self) -> super::builder::chat_service::CreateSection {
2030 super::builder::chat_service::CreateSection::new(self.inner.clone())
2031 }
2032
2033 /// Deletes a section of type `CUSTOM_SECTION`.
2034 ///
2035 /// If the section contains items, such as spaces, the items are moved to
2036 /// Google Chat's default sections and are not deleted.
2037 ///
2038 /// For details, see [Create and organize sections in Google
2039 /// Chat](https://support.google.com/chat/answer/16059854).
2040 ///
2041 /// Requires [user
2042 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2043 /// with the [authorization
2044 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2045 ///
2046 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2047 ///
2048 /// # Example
2049 /// ```
2050 /// # use google_chat_v1::client::ChatService;
2051 /// use google_chat_v1::Result;
2052 /// async fn sample(
2053 /// client: &ChatService, user_id: &str, section_id: &str
2054 /// ) -> Result<()> {
2055 /// client.delete_section()
2056 /// .set_name(format!("users/{user_id}/sections/{section_id}"))
2057 /// .send().await?;
2058 /// Ok(())
2059 /// }
2060 /// ```
2061 pub fn delete_section(&self) -> super::builder::chat_service::DeleteSection {
2062 super::builder::chat_service::DeleteSection::new(self.inner.clone())
2063 }
2064
2065 /// Updates a section. Only sections of type `CUSTOM_SECTION` can be updated.
2066 /// For details, see [Create and organize sections in Google
2067 /// Chat](https://support.google.com/chat/answer/16059854).
2068 ///
2069 /// Requires [user
2070 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2071 /// with the [authorization
2072 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2073 ///
2074 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2075 ///
2076 /// # Example
2077 /// ```
2078 /// # use google_chat_v1::client::ChatService;
2079 /// # extern crate wkt as google_cloud_wkt;
2080 /// use google_cloud_wkt::FieldMask;
2081 /// use google_chat_v1::model::Section;
2082 /// use google_chat_v1::Result;
2083 /// async fn sample(
2084 /// client: &ChatService, user_id: &str, section_id: &str
2085 /// ) -> Result<()> {
2086 /// let response = client.update_section()
2087 /// .set_section(
2088 /// Section::new().set_name(format!("users/{user_id}/sections/{section_id}"))/* set fields */
2089 /// )
2090 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
2091 /// .send().await?;
2092 /// println!("response {:?}", response);
2093 /// Ok(())
2094 /// }
2095 /// ```
2096 pub fn update_section(&self) -> super::builder::chat_service::UpdateSection {
2097 super::builder::chat_service::UpdateSection::new(self.inner.clone())
2098 }
2099
2100 /// Lists sections available to the Chat user. Sections help users group their
2101 /// conversations and customize the list of spaces displayed in Chat
2102 /// navigation panel. For details, see [Create and organize sections in Google
2103 /// Chat](https://support.google.com/chat/answer/16059854).
2104 ///
2105 /// Requires [user
2106 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2107 /// with the [authorization
2108 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2109 ///
2110 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2111 /// - `<https://www.googleapis.com/auth/chat.users.sections.readonly>`
2112 ///
2113 /// # Example
2114 /// ```
2115 /// # use google_chat_v1::client::ChatService;
2116 /// use google_cloud_gax::paginator::ItemPaginator as _;
2117 /// use google_chat_v1::Result;
2118 /// async fn sample(
2119 /// client: &ChatService, parent: &str
2120 /// ) -> Result<()> {
2121 /// let mut list = client.list_sections()
2122 /// .set_parent(parent)
2123 /// .by_item();
2124 /// while let Some(item) = list.next().await.transpose()? {
2125 /// println!("{:?}", item);
2126 /// }
2127 /// Ok(())
2128 /// }
2129 /// ```
2130 pub fn list_sections(&self) -> super::builder::chat_service::ListSections {
2131 super::builder::chat_service::ListSections::new(self.inner.clone())
2132 }
2133
2134 /// Changes the sort order of a section. For details, see [Create and organize
2135 /// sections in Google Chat](https://support.google.com/chat/answer/16059854).
2136 ///
2137 /// Requires [user
2138 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2139 /// with the [authorization
2140 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2141 ///
2142 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2143 ///
2144 /// # Example
2145 /// ```
2146 /// # use google_chat_v1::client::ChatService;
2147 /// use google_chat_v1::Result;
2148 /// async fn sample(
2149 /// client: &ChatService
2150 /// ) -> Result<()> {
2151 /// let response = client.position_section()
2152 /// /* set fields */
2153 /// .send().await?;
2154 /// println!("response {:?}", response);
2155 /// Ok(())
2156 /// }
2157 /// ```
2158 pub fn position_section(&self) -> super::builder::chat_service::PositionSection {
2159 super::builder::chat_service::PositionSection::new(self.inner.clone())
2160 }
2161
2162 /// Lists items in a section.
2163 ///
2164 /// Only spaces can be section items. For details, see [Create and organize
2165 /// sections in Google Chat](https://support.google.com/chat/answer/16059854).
2166 ///
2167 /// Requires [user
2168 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2169 /// with the [authorization
2170 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2171 ///
2172 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2173 /// - `<https://www.googleapis.com/auth/chat.users.sections.readonly>`
2174 ///
2175 /// # Example
2176 /// ```
2177 /// # use google_chat_v1::client::ChatService;
2178 /// use google_cloud_gax::paginator::ItemPaginator as _;
2179 /// use google_chat_v1::Result;
2180 /// async fn sample(
2181 /// client: &ChatService, user_id: &str, section_id: &str
2182 /// ) -> Result<()> {
2183 /// let mut list = client.list_section_items()
2184 /// .set_parent(format!("users/{user_id}/sections/{section_id}"))
2185 /// .by_item();
2186 /// while let Some(item) = list.next().await.transpose()? {
2187 /// println!("{:?}", item);
2188 /// }
2189 /// Ok(())
2190 /// }
2191 /// ```
2192 pub fn list_section_items(&self) -> super::builder::chat_service::ListSectionItems {
2193 super::builder::chat_service::ListSectionItems::new(self.inner.clone())
2194 }
2195
2196 /// Moves an item from one section to another. For example, if a section
2197 /// contains spaces, this method can be used to move a space to a different
2198 /// section. For details, see [Create and organize sections in Google
2199 /// Chat](https://support.google.com/chat/answer/16059854).
2200 ///
2201 /// Requires [user
2202 /// authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
2203 /// with the [authorization
2204 /// scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
2205 ///
2206 /// - `<https://www.googleapis.com/auth/chat.users.sections>`
2207 ///
2208 /// # Example
2209 /// ```
2210 /// # use google_chat_v1::client::ChatService;
2211 /// use google_chat_v1::Result;
2212 /// async fn sample(
2213 /// client: &ChatService
2214 /// ) -> Result<()> {
2215 /// let response = client.move_section_item()
2216 /// /* set fields */
2217 /// .send().await?;
2218 /// println!("response {:?}", response);
2219 /// Ok(())
2220 /// }
2221 /// ```
2222 pub fn move_section_item(&self) -> super::builder::chat_service::MoveSectionItem {
2223 super::builder::chat_service::MoveSectionItem::new(self.inner.clone())
2224 }
2225}