google_cloud_support_v2/client.rs
1// Copyright 2025 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 Cloud Support API.
22///
23/// # Example
24/// ```
25/// # use google_cloud_support_v2::client::CaseAttachmentService;
26/// use google_cloud_gax::paginator::ItemPaginator as _;
27/// async fn sample(
28/// organization_id: &str,
29/// case_id: &str,
30/// ) -> anyhow::Result<()> {
31/// let client = CaseAttachmentService::builder().build().await?;
32/// let mut list = client.list_attachments()
33/// .set_parent(format!("organizations/{organization_id}/cases/{case_id}"))
34/// .by_item();
35/// while let Some(item) = list.next().await.transpose()? {
36/// println!("{:?}", item);
37/// }
38/// Ok(())
39/// }
40/// ```
41///
42/// # Service Description
43///
44/// A service to manage file attachments for Google Cloud support cases.
45///
46/// # Configuration
47///
48/// To configure `CaseAttachmentService` use the `with_*` methods in the type returned
49/// by [builder()][CaseAttachmentService::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://cloudsupport.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::case_attachment_service::ClientBuilder::with_endpoint
62/// [with_credentials()]: super::builder::case_attachment_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/// `CaseAttachmentService` holds a connection pool internally, it is advised to
69/// create one and reuse it. You do not need to wrap `CaseAttachmentService` 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 CaseAttachmentService {
74 inner: std::sync::Arc<dyn super::stub::dynamic::CaseAttachmentService>,
75}
76
77impl CaseAttachmentService {
78 /// Returns a builder for [CaseAttachmentService].
79 ///
80 /// ```
81 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
82 /// # use google_cloud_support_v2::client::CaseAttachmentService;
83 /// let client = CaseAttachmentService::builder().build().await?;
84 /// # Ok(()) }
85 /// ```
86 pub fn builder() -> super::builder::case_attachment_service::ClientBuilder {
87 crate::new_client_builder(super::builder::case_attachment_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::CaseAttachmentService + '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::CaseAttachmentService>>
111 {
112 if gaxi::options::tracing_enabled(&conf) {
113 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
114 }
115 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
116 }
117
118 async fn build_transport(
119 conf: gaxi::options::ClientConfig,
120 ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
121 super::transport::CaseAttachmentService::new(conf).await
122 }
123
124 async fn build_with_tracing(
125 conf: gaxi::options::ClientConfig,
126 ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
127 Self::build_transport(conf)
128 .await
129 .map(super::tracing::CaseAttachmentService::new)
130 }
131
132 /// List all the attachments associated with a support case.
133 ///
134 /// # Example
135 /// ```
136 /// # use google_cloud_support_v2::client::CaseAttachmentService;
137 /// use google_cloud_gax::paginator::ItemPaginator as _;
138 /// use google_cloud_support_v2::Result;
139 /// async fn sample(
140 /// client: &CaseAttachmentService, organization_id: &str, case_id: &str
141 /// ) -> Result<()> {
142 /// let mut list = client.list_attachments()
143 /// .set_parent(format!("organizations/{organization_id}/cases/{case_id}"))
144 /// .by_item();
145 /// while let Some(item) = list.next().await.transpose()? {
146 /// println!("{:?}", item);
147 /// }
148 /// Ok(())
149 /// }
150 /// ```
151 pub fn list_attachments(&self) -> super::builder::case_attachment_service::ListAttachments {
152 super::builder::case_attachment_service::ListAttachments::new(self.inner.clone())
153 }
154
155 /// Retrieve an attachment associated with a support case.
156 ///
157 /// EXAMPLES:
158 ///
159 /// cURL:
160 ///
161 /// ```norust
162 /// attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB"
163 /// curl \
164 /// --header "Authorization: Bearer $(gcloud auth print-access-token)" \
165 /// "https://cloudsupport.googleapis.com/v2/$attachment"
166 /// ```
167 ///
168 /// Python:
169 ///
170 /// ```norust
171 /// import googleapiclient.discovery
172 ///
173 /// api_version = "v2"
174 /// supportApiService = googleapiclient.discovery.build(
175 /// serviceName="cloudsupport",
176 /// version=api_version,
177 /// discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}",
178 /// )
179 /// request = (
180 /// supportApiService.cases()
181 /// .attachments()
182 /// .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB")
183 /// )
184 /// print(request.execute())
185 /// ```
186 ///
187 /// # Example
188 /// ```
189 /// # use google_cloud_support_v2::client::CaseAttachmentService;
190 /// use google_cloud_support_v2::Result;
191 /// async fn sample(
192 /// client: &CaseAttachmentService, organization_id: &str, case_id: &str, attachment_id: &str
193 /// ) -> Result<()> {
194 /// let response = client.get_attachment()
195 /// .set_name(format!("organizations/{organization_id}/cases/{case_id}/attachments/{attachment_id}"))
196 /// .send().await?;
197 /// println!("response {:?}", response);
198 /// Ok(())
199 /// }
200 /// ```
201 pub fn get_attachment(&self) -> super::builder::case_attachment_service::GetAttachment {
202 super::builder::case_attachment_service::GetAttachment::new(self.inner.clone())
203 }
204}
205
206/// Implements a client for the Google Cloud Support API.
207///
208/// # Example
209/// ```
210/// # use google_cloud_support_v2::client::CaseService;
211/// use google_cloud_gax::paginator::ItemPaginator as _;
212/// async fn sample(
213/// organization_id: &str,
214/// ) -> anyhow::Result<()> {
215/// let client = CaseService::builder().build().await?;
216/// let mut list = client.list_cases()
217/// .set_parent(format!("organizations/{organization_id}"))
218/// .by_item();
219/// while let Some(item) = list.next().await.transpose()? {
220/// println!("{:?}", item);
221/// }
222/// Ok(())
223/// }
224/// ```
225///
226/// # Service Description
227///
228/// A service to manage Google Cloud support cases.
229///
230/// # Configuration
231///
232/// To configure `CaseService` use the `with_*` methods in the type returned
233/// by [builder()][CaseService::builder]. The default configuration should
234/// work for most applications. Common configuration changes include
235///
236/// * [with_endpoint()]: by default this client uses the global default endpoint
237/// (`https://cloudsupport.googleapis.com`). Applications using regional
238/// endpoints or running in restricted networks (e.g. a network configured
239/// with [Private Google Access with VPC Service Controls]) may want to
240/// override this default.
241/// * [with_credentials()]: by default this client uses
242/// [Application Default Credentials]. Applications using custom
243/// authentication may need to override this default.
244///
245/// [with_endpoint()]: super::builder::case_service::ClientBuilder::with_endpoint
246/// [with_credentials()]: super::builder::case_service::ClientBuilder::with_credentials
247/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
248/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
249///
250/// # Pooling and Cloning
251///
252/// `CaseService` holds a connection pool internally, it is advised to
253/// create one and reuse it. You do not need to wrap `CaseService` in
254/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
255/// already uses an `Arc` internally.
256#[derive(Clone, Debug)]
257pub struct CaseService {
258 inner: std::sync::Arc<dyn super::stub::dynamic::CaseService>,
259}
260
261impl CaseService {
262 /// Returns a builder for [CaseService].
263 ///
264 /// ```
265 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
266 /// # use google_cloud_support_v2::client::CaseService;
267 /// let client = CaseService::builder().build().await?;
268 /// # Ok(()) }
269 /// ```
270 pub fn builder() -> super::builder::case_service::ClientBuilder {
271 crate::new_client_builder(super::builder::case_service::client::Factory)
272 }
273
274 /// Creates a new client from the provided stub.
275 ///
276 /// The most common case for calling this function is in tests mocking the
277 /// client's behavior.
278 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
279 where
280 T: super::stub::CaseService + 'static,
281 {
282 Self { inner: stub.into() }
283 }
284
285 pub(crate) async fn new(
286 config: gaxi::options::ClientConfig,
287 ) -> crate::ClientBuilderResult<Self> {
288 let inner = Self::build_inner(config).await?;
289 Ok(Self { inner })
290 }
291
292 async fn build_inner(
293 conf: gaxi::options::ClientConfig,
294 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CaseService>> {
295 if gaxi::options::tracing_enabled(&conf) {
296 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
297 }
298 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
299 }
300
301 async fn build_transport(
302 conf: gaxi::options::ClientConfig,
303 ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
304 super::transport::CaseService::new(conf).await
305 }
306
307 async fn build_with_tracing(
308 conf: gaxi::options::ClientConfig,
309 ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
310 Self::build_transport(conf)
311 .await
312 .map(super::tracing::CaseService::new)
313 }
314
315 /// Retrieve a case.
316 ///
317 /// # Example
318 /// ```
319 /// # use google_cloud_support_v2::client::CaseService;
320 /// use google_cloud_support_v2::Result;
321 /// async fn sample(
322 /// client: &CaseService, organization_id: &str, case_id: &str
323 /// ) -> Result<()> {
324 /// let response = client.get_case()
325 /// .set_name(format!("organizations/{organization_id}/cases/{case_id}"))
326 /// .send().await?;
327 /// println!("response {:?}", response);
328 /// Ok(())
329 /// }
330 /// ```
331 pub fn get_case(&self) -> super::builder::case_service::GetCase {
332 super::builder::case_service::GetCase::new(self.inner.clone())
333 }
334
335 /// Retrieve all cases under a parent, but not its children.
336 ///
337 /// For example, listing cases under an organization only returns the cases
338 /// that are directly parented by that organization. To retrieve cases
339 /// under an organization and its projects, use `cases.search`.
340 ///
341 /// # Example
342 /// ```
343 /// # use google_cloud_support_v2::client::CaseService;
344 /// use google_cloud_gax::paginator::ItemPaginator as _;
345 /// use google_cloud_support_v2::Result;
346 /// async fn sample(
347 /// client: &CaseService, organization_id: &str
348 /// ) -> Result<()> {
349 /// let mut list = client.list_cases()
350 /// .set_parent(format!("organizations/{organization_id}"))
351 /// .by_item();
352 /// while let Some(item) = list.next().await.transpose()? {
353 /// println!("{:?}", item);
354 /// }
355 /// Ok(())
356 /// }
357 /// ```
358 pub fn list_cases(&self) -> super::builder::case_service::ListCases {
359 super::builder::case_service::ListCases::new(self.inner.clone())
360 }
361
362 /// Search for cases using a query.
363 ///
364 /// # Example
365 /// ```
366 /// # use google_cloud_support_v2::client::CaseService;
367 /// use google_cloud_gax::paginator::ItemPaginator as _;
368 /// use google_cloud_support_v2::Result;
369 /// async fn sample(
370 /// client: &CaseService
371 /// ) -> Result<()> {
372 /// let mut list = client.search_cases()
373 /// /* set fields */
374 /// .by_item();
375 /// while let Some(item) = list.next().await.transpose()? {
376 /// println!("{:?}", item);
377 /// }
378 /// Ok(())
379 /// }
380 /// ```
381 pub fn search_cases(&self) -> super::builder::case_service::SearchCases {
382 super::builder::case_service::SearchCases::new(self.inner.clone())
383 }
384
385 /// Create a new case and associate it with a parent.
386 ///
387 /// It must have the following fields set: `display_name`, `description`,
388 /// `classification`, and `priority`. If you're just testing the API and don't
389 /// want to route your case to an agent, set `testCase=true`.
390 ///
391 /// # Example
392 /// ```
393 /// # use google_cloud_support_v2::client::CaseService;
394 /// use google_cloud_support_v2::model::Case;
395 /// use google_cloud_support_v2::Result;
396 /// async fn sample(
397 /// client: &CaseService, organization_id: &str
398 /// ) -> Result<()> {
399 /// let response = client.create_case()
400 /// .set_parent(format!("organizations/{organization_id}"))
401 /// .set_case(
402 /// Case::new()/* set fields */
403 /// )
404 /// .send().await?;
405 /// println!("response {:?}", response);
406 /// Ok(())
407 /// }
408 /// ```
409 pub fn create_case(&self) -> super::builder::case_service::CreateCase {
410 super::builder::case_service::CreateCase::new(self.inner.clone())
411 }
412
413 /// Update a case. Only some fields can be updated.
414 ///
415 /// # Example
416 /// ```
417 /// # use google_cloud_support_v2::client::CaseService;
418 /// # extern crate wkt as google_cloud_wkt;
419 /// use google_cloud_wkt::FieldMask;
420 /// use google_cloud_support_v2::model::Case;
421 /// use google_cloud_support_v2::Result;
422 /// async fn sample(
423 /// client: &CaseService, organization_id: &str, case_id: &str
424 /// ) -> Result<()> {
425 /// let response = client.update_case()
426 /// .set_case(
427 /// Case::new().set_name(format!("organizations/{organization_id}/cases/{case_id}"))/* set fields */
428 /// )
429 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
430 /// .send().await?;
431 /// println!("response {:?}", response);
432 /// Ok(())
433 /// }
434 /// ```
435 pub fn update_case(&self) -> super::builder::case_service::UpdateCase {
436 super::builder::case_service::UpdateCase::new(self.inner.clone())
437 }
438
439 /// Escalate a case, starting the Google Cloud Support escalation management
440 /// process.
441 ///
442 /// This operation is only available for some support services. Go to
443 /// <https://cloud.google.com/support> and look for 'Technical support
444 /// escalations' in the feature list to find out which ones let you
445 /// do that.
446 ///
447 /// # Example
448 /// ```
449 /// # use google_cloud_support_v2::client::CaseService;
450 /// use google_cloud_support_v2::Result;
451 /// async fn sample(
452 /// client: &CaseService
453 /// ) -> Result<()> {
454 /// let response = client.escalate_case()
455 /// /* set fields */
456 /// .send().await?;
457 /// println!("response {:?}", response);
458 /// Ok(())
459 /// }
460 /// ```
461 pub fn escalate_case(&self) -> super::builder::case_service::EscalateCase {
462 super::builder::case_service::EscalateCase::new(self.inner.clone())
463 }
464
465 /// Close a case.
466 ///
467 /// # Example
468 /// ```
469 /// # use google_cloud_support_v2::client::CaseService;
470 /// use google_cloud_support_v2::Result;
471 /// async fn sample(
472 /// client: &CaseService
473 /// ) -> Result<()> {
474 /// let response = client.close_case()
475 /// /* set fields */
476 /// .send().await?;
477 /// println!("response {:?}", response);
478 /// Ok(())
479 /// }
480 /// ```
481 pub fn close_case(&self) -> super::builder::case_service::CloseCase {
482 super::builder::case_service::CloseCase::new(self.inner.clone())
483 }
484
485 /// Retrieve valid classifications to use when creating a support case.
486 ///
487 /// Classifications are hierarchical. Each classification is a string
488 /// containing all levels of the hierarchy separated by `" > "`. For example,
489 /// `"Technical Issue > Compute > Compute Engine"`.
490 ///
491 /// Classification IDs returned by this endpoint are valid for at least six
492 /// months. When a classification is deactivated, this endpoint immediately
493 /// stops returning it. After six months, `case.create` requests using the
494 /// classification will fail.
495 ///
496 /// # Example
497 /// ```
498 /// # use google_cloud_support_v2::client::CaseService;
499 /// use google_cloud_gax::paginator::ItemPaginator as _;
500 /// use google_cloud_support_v2::Result;
501 /// async fn sample(
502 /// client: &CaseService
503 /// ) -> Result<()> {
504 /// let mut list = client.search_case_classifications()
505 /// /* set fields */
506 /// .by_item();
507 /// while let Some(item) = list.next().await.transpose()? {
508 /// println!("{:?}", item);
509 /// }
510 /// Ok(())
511 /// }
512 /// ```
513 pub fn search_case_classifications(
514 &self,
515 ) -> super::builder::case_service::SearchCaseClassifications {
516 super::builder::case_service::SearchCaseClassifications::new(self.inner.clone())
517 }
518}
519
520/// Implements a client for the Google Cloud Support API.
521///
522/// # Example
523/// ```
524/// # use google_cloud_support_v2::client::CommentService;
525/// use google_cloud_gax::paginator::ItemPaginator as _;
526/// async fn sample(
527/// organization_id: &str,
528/// case_id: &str,
529/// ) -> anyhow::Result<()> {
530/// let client = CommentService::builder().build().await?;
531/// let mut list = client.list_comments()
532/// .set_parent(format!("organizations/{organization_id}/cases/{case_id}"))
533/// .by_item();
534/// while let Some(item) = list.next().await.transpose()? {
535/// println!("{:?}", item);
536/// }
537/// Ok(())
538/// }
539/// ```
540///
541/// # Service Description
542///
543/// A service to manage comments on cases.
544///
545/// # Configuration
546///
547/// To configure `CommentService` use the `with_*` methods in the type returned
548/// by [builder()][CommentService::builder]. The default configuration should
549/// work for most applications. Common configuration changes include
550///
551/// * [with_endpoint()]: by default this client uses the global default endpoint
552/// (`https://cloudsupport.googleapis.com`). Applications using regional
553/// endpoints or running in restricted networks (e.g. a network configured
554/// with [Private Google Access with VPC Service Controls]) may want to
555/// override this default.
556/// * [with_credentials()]: by default this client uses
557/// [Application Default Credentials]. Applications using custom
558/// authentication may need to override this default.
559///
560/// [with_endpoint()]: super::builder::comment_service::ClientBuilder::with_endpoint
561/// [with_credentials()]: super::builder::comment_service::ClientBuilder::with_credentials
562/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
563/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
564///
565/// # Pooling and Cloning
566///
567/// `CommentService` holds a connection pool internally, it is advised to
568/// create one and reuse it. You do not need to wrap `CommentService` in
569/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
570/// already uses an `Arc` internally.
571#[derive(Clone, Debug)]
572pub struct CommentService {
573 inner: std::sync::Arc<dyn super::stub::dynamic::CommentService>,
574}
575
576impl CommentService {
577 /// Returns a builder for [CommentService].
578 ///
579 /// ```
580 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
581 /// # use google_cloud_support_v2::client::CommentService;
582 /// let client = CommentService::builder().build().await?;
583 /// # Ok(()) }
584 /// ```
585 pub fn builder() -> super::builder::comment_service::ClientBuilder {
586 crate::new_client_builder(super::builder::comment_service::client::Factory)
587 }
588
589 /// Creates a new client from the provided stub.
590 ///
591 /// The most common case for calling this function is in tests mocking the
592 /// client's behavior.
593 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
594 where
595 T: super::stub::CommentService + 'static,
596 {
597 Self { inner: stub.into() }
598 }
599
600 pub(crate) async fn new(
601 config: gaxi::options::ClientConfig,
602 ) -> crate::ClientBuilderResult<Self> {
603 let inner = Self::build_inner(config).await?;
604 Ok(Self { inner })
605 }
606
607 async fn build_inner(
608 conf: gaxi::options::ClientConfig,
609 ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CommentService>> {
610 if gaxi::options::tracing_enabled(&conf) {
611 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
612 }
613 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
614 }
615
616 async fn build_transport(
617 conf: gaxi::options::ClientConfig,
618 ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
619 super::transport::CommentService::new(conf).await
620 }
621
622 async fn build_with_tracing(
623 conf: gaxi::options::ClientConfig,
624 ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
625 Self::build_transport(conf)
626 .await
627 .map(super::tracing::CommentService::new)
628 }
629
630 /// List all the comments associated with a case.
631 ///
632 /// # Example
633 /// ```
634 /// # use google_cloud_support_v2::client::CommentService;
635 /// use google_cloud_gax::paginator::ItemPaginator as _;
636 /// use google_cloud_support_v2::Result;
637 /// async fn sample(
638 /// client: &CommentService, organization_id: &str, case_id: &str
639 /// ) -> Result<()> {
640 /// let mut list = client.list_comments()
641 /// .set_parent(format!("organizations/{organization_id}/cases/{case_id}"))
642 /// .by_item();
643 /// while let Some(item) = list.next().await.transpose()? {
644 /// println!("{:?}", item);
645 /// }
646 /// Ok(())
647 /// }
648 /// ```
649 pub fn list_comments(&self) -> super::builder::comment_service::ListComments {
650 super::builder::comment_service::ListComments::new(self.inner.clone())
651 }
652
653 /// Add a new comment to a case.
654 ///
655 /// The comment must have the following fields set: `body`.
656 ///
657 /// # Example
658 /// ```
659 /// # use google_cloud_support_v2::client::CommentService;
660 /// use google_cloud_support_v2::model::Comment;
661 /// use google_cloud_support_v2::Result;
662 /// async fn sample(
663 /// client: &CommentService, organization_id: &str, case_id: &str
664 /// ) -> Result<()> {
665 /// let response = client.create_comment()
666 /// .set_parent(format!("organizations/{organization_id}/cases/{case_id}"))
667 /// .set_comment(
668 /// Comment::new()/* set fields */
669 /// )
670 /// .send().await?;
671 /// println!("response {:?}", response);
672 /// Ok(())
673 /// }
674 /// ```
675 pub fn create_comment(&self) -> super::builder::comment_service::CreateComment {
676 super::builder::comment_service::CreateComment::new(self.inner.clone())
677 }
678
679 /// Retrieve a comment.
680 ///
681 /// EXAMPLES:
682 ///
683 /// cURL:
684 ///
685 /// ```norust
686 /// comment="projects/some-project/cases/43595344/comments/234567890"
687 /// curl \
688 /// --header "Authorization: Bearer $(gcloud auth print-access-token)" \
689 /// "https://cloudsupport.googleapis.com/v2/$comment"
690 /// ```
691 ///
692 /// Python:
693 ///
694 /// ```norust
695 /// import googleapiclient.discovery
696 ///
697 /// api_version = "v2"
698 /// supportApiService = googleapiclient.discovery.build(
699 /// serviceName="cloudsupport",
700 /// version=api_version,
701 /// discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}",
702 /// )
703 ///
704 /// request = supportApiService.cases().comments().get(
705 /// name="projects/some-project/cases/43595344/comments/234567890",
706 /// )
707 /// print(request.execute())
708 /// ```
709 ///
710 /// # Example
711 /// ```
712 /// # use google_cloud_support_v2::client::CommentService;
713 /// use google_cloud_support_v2::Result;
714 /// async fn sample(
715 /// client: &CommentService, organization_id: &str, case_id: &str, comment_id: &str
716 /// ) -> Result<()> {
717 /// let response = client.get_comment()
718 /// .set_name(format!("organizations/{organization_id}/cases/{case_id}/comments/{comment_id}"))
719 /// .send().await?;
720 /// println!("response {:?}", response);
721 /// Ok(())
722 /// }
723 /// ```
724 pub fn get_comment(&self) -> super::builder::comment_service::GetComment {
725 super::builder::comment_service::GetComment::new(self.inner.clone())
726 }
727}
728
729/// Implements a client for the Google Cloud Support API.
730///
731/// # Example
732/// ```
733/// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
734/// use google_cloud_gax::paginator::ItemPaginator as _;
735/// async fn sample(
736/// organization_id: &str,
737/// ) -> anyhow::Result<()> {
738/// let client = SupportEventSubscriptionService::builder().build().await?;
739/// let mut list = client.list_support_event_subscriptions()
740/// .set_parent(format!("organizations/{organization_id}"))
741/// .by_item();
742/// while let Some(item) = list.next().await.transpose()? {
743/// println!("{:?}", item);
744/// }
745/// Ok(())
746/// }
747/// ```
748///
749/// # Service Description
750///
751/// Service for managing customer support event subscriptions.
752///
753/// # Configuration
754///
755/// To configure `SupportEventSubscriptionService` use the `with_*` methods in the type returned
756/// by [builder()][SupportEventSubscriptionService::builder]. The default configuration should
757/// work for most applications. Common configuration changes include
758///
759/// * [with_endpoint()]: by default this client uses the global default endpoint
760/// (`https://cloudsupport.googleapis.com`). Applications using regional
761/// endpoints or running in restricted networks (e.g. a network configured
762/// with [Private Google Access with VPC Service Controls]) may want to
763/// override this default.
764/// * [with_credentials()]: by default this client uses
765/// [Application Default Credentials]. Applications using custom
766/// authentication may need to override this default.
767///
768/// [with_endpoint()]: super::builder::support_event_subscription_service::ClientBuilder::with_endpoint
769/// [with_credentials()]: super::builder::support_event_subscription_service::ClientBuilder::with_credentials
770/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
771/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
772///
773/// # Pooling and Cloning
774///
775/// `SupportEventSubscriptionService` holds a connection pool internally, it is advised to
776/// create one and reuse it. You do not need to wrap `SupportEventSubscriptionService` in
777/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
778/// already uses an `Arc` internally.
779#[derive(Clone, Debug)]
780pub struct SupportEventSubscriptionService {
781 inner: std::sync::Arc<dyn super::stub::dynamic::SupportEventSubscriptionService>,
782}
783
784impl SupportEventSubscriptionService {
785 /// Returns a builder for [SupportEventSubscriptionService].
786 ///
787 /// ```
788 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
789 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
790 /// let client = SupportEventSubscriptionService::builder().build().await?;
791 /// # Ok(()) }
792 /// ```
793 pub fn builder() -> super::builder::support_event_subscription_service::ClientBuilder {
794 crate::new_client_builder(
795 super::builder::support_event_subscription_service::client::Factory,
796 )
797 }
798
799 /// Creates a new client from the provided stub.
800 ///
801 /// The most common case for calling this function is in tests mocking the
802 /// client's behavior.
803 pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
804 where
805 T: super::stub::SupportEventSubscriptionService + 'static,
806 {
807 Self { inner: stub.into() }
808 }
809
810 pub(crate) async fn new(
811 config: gaxi::options::ClientConfig,
812 ) -> crate::ClientBuilderResult<Self> {
813 let inner = Self::build_inner(config).await?;
814 Ok(Self { inner })
815 }
816
817 async fn build_inner(
818 conf: gaxi::options::ClientConfig,
819 ) -> crate::ClientBuilderResult<
820 std::sync::Arc<dyn super::stub::dynamic::SupportEventSubscriptionService>,
821 > {
822 if gaxi::options::tracing_enabled(&conf) {
823 return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
824 }
825 Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
826 }
827
828 async fn build_transport(
829 conf: gaxi::options::ClientConfig,
830 ) -> crate::ClientBuilderResult<impl super::stub::SupportEventSubscriptionService> {
831 super::transport::SupportEventSubscriptionService::new(conf).await
832 }
833
834 async fn build_with_tracing(
835 conf: gaxi::options::ClientConfig,
836 ) -> crate::ClientBuilderResult<impl super::stub::SupportEventSubscriptionService> {
837 Self::build_transport(conf)
838 .await
839 .map(super::tracing::SupportEventSubscriptionService::new)
840 }
841
842 /// Creates a support event subscription for an organization.
843 ///
844 /// # Example
845 /// ```
846 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
847 /// use google_cloud_support_v2::model::SupportEventSubscription;
848 /// use google_cloud_support_v2::Result;
849 /// async fn sample(
850 /// client: &SupportEventSubscriptionService, organization_id: &str
851 /// ) -> Result<()> {
852 /// let response = client.create_support_event_subscription()
853 /// .set_parent(format!("organizations/{organization_id}"))
854 /// .set_support_event_subscription(
855 /// SupportEventSubscription::new()/* set fields */
856 /// )
857 /// .send().await?;
858 /// println!("response {:?}", response);
859 /// Ok(())
860 /// }
861 /// ```
862 pub fn create_support_event_subscription(
863 &self,
864 ) -> super::builder::support_event_subscription_service::CreateSupportEventSubscription {
865 super::builder::support_event_subscription_service::CreateSupportEventSubscription::new(
866 self.inner.clone(),
867 )
868 }
869
870 /// Gets a support event subscription.
871 ///
872 /// # Example
873 /// ```
874 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
875 /// use google_cloud_support_v2::Result;
876 /// async fn sample(
877 /// client: &SupportEventSubscriptionService, organization_id: &str, support_event_subscription_id: &str
878 /// ) -> Result<()> {
879 /// let response = client.get_support_event_subscription()
880 /// .set_name(format!("organizations/{organization_id}/supportEventSubscriptions/{support_event_subscription_id}"))
881 /// .send().await?;
882 /// println!("response {:?}", response);
883 /// Ok(())
884 /// }
885 /// ```
886 pub fn get_support_event_subscription(
887 &self,
888 ) -> super::builder::support_event_subscription_service::GetSupportEventSubscription {
889 super::builder::support_event_subscription_service::GetSupportEventSubscription::new(
890 self.inner.clone(),
891 )
892 }
893
894 /// Lists support event subscriptions.
895 ///
896 /// # Example
897 /// ```
898 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
899 /// use google_cloud_gax::paginator::ItemPaginator as _;
900 /// use google_cloud_support_v2::Result;
901 /// async fn sample(
902 /// client: &SupportEventSubscriptionService, organization_id: &str
903 /// ) -> Result<()> {
904 /// let mut list = client.list_support_event_subscriptions()
905 /// .set_parent(format!("organizations/{organization_id}"))
906 /// .by_item();
907 /// while let Some(item) = list.next().await.transpose()? {
908 /// println!("{:?}", item);
909 /// }
910 /// Ok(())
911 /// }
912 /// ```
913 pub fn list_support_event_subscriptions(
914 &self,
915 ) -> super::builder::support_event_subscription_service::ListSupportEventSubscriptions {
916 super::builder::support_event_subscription_service::ListSupportEventSubscriptions::new(
917 self.inner.clone(),
918 )
919 }
920
921 /// Updates a support event subscription.
922 ///
923 /// # Example
924 /// ```
925 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
926 /// # extern crate wkt as google_cloud_wkt;
927 /// use google_cloud_wkt::FieldMask;
928 /// use google_cloud_support_v2::model::SupportEventSubscription;
929 /// use google_cloud_support_v2::Result;
930 /// async fn sample(
931 /// client: &SupportEventSubscriptionService, organization_id: &str, support_event_subscription_id: &str
932 /// ) -> Result<()> {
933 /// let response = client.update_support_event_subscription()
934 /// .set_support_event_subscription(
935 /// SupportEventSubscription::new().set_name(format!("organizations/{organization_id}/supportEventSubscriptions/{support_event_subscription_id}"))/* set fields */
936 /// )
937 /// .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
938 /// .send().await?;
939 /// println!("response {:?}", response);
940 /// Ok(())
941 /// }
942 /// ```
943 pub fn update_support_event_subscription(
944 &self,
945 ) -> super::builder::support_event_subscription_service::UpdateSupportEventSubscription {
946 super::builder::support_event_subscription_service::UpdateSupportEventSubscription::new(
947 self.inner.clone(),
948 )
949 }
950
951 /// Soft deletes a support event subscription.
952 ///
953 /// # Example
954 /// ```
955 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
956 /// use google_cloud_support_v2::Result;
957 /// async fn sample(
958 /// client: &SupportEventSubscriptionService, organization_id: &str, support_event_subscription_id: &str
959 /// ) -> Result<()> {
960 /// let response = client.delete_support_event_subscription()
961 /// .set_name(format!("organizations/{organization_id}/supportEventSubscriptions/{support_event_subscription_id}"))
962 /// .send().await?;
963 /// println!("response {:?}", response);
964 /// Ok(())
965 /// }
966 /// ```
967 pub fn delete_support_event_subscription(
968 &self,
969 ) -> super::builder::support_event_subscription_service::DeleteSupportEventSubscription {
970 super::builder::support_event_subscription_service::DeleteSupportEventSubscription::new(
971 self.inner.clone(),
972 )
973 }
974
975 /// Undeletes a support event subscription.
976 ///
977 /// # Example
978 /// ```
979 /// # use google_cloud_support_v2::client::SupportEventSubscriptionService;
980 /// use google_cloud_support_v2::Result;
981 /// async fn sample(
982 /// client: &SupportEventSubscriptionService, organization_id: &str, support_event_subscription_id: &str
983 /// ) -> Result<()> {
984 /// let response = client.undelete_support_event_subscription()
985 /// .set_name(format!("organizations/{organization_id}/supportEventSubscriptions/{support_event_subscription_id}"))
986 /// .send().await?;
987 /// println!("response {:?}", response);
988 /// Ok(())
989 /// }
990 /// ```
991 pub fn undelete_support_event_subscription(
992 &self,
993 ) -> super::builder::support_event_subscription_service::UndeleteSupportEventSubscription {
994 super::builder::support_event_subscription_service::UndeleteSupportEventSubscription::new(
995 self.inner.clone(),
996 )
997 }
998}