Skip to main content

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::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Google Cloud Support API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_support_v2::client::CaseAttachmentService;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26///     let client = CaseAttachmentService::builder().build().await?;
27///     let parent = "parent_value";
28///     let mut list = client.list_attachments()
29///         .set_parent(parent)
30///         .by_item();
31///     while let Some(item) = list.next().await.transpose()? {
32///         println!("{:?}", item);
33///     }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// A service to manage file attachments for Google Cloud support cases.
40///
41/// # Configuration
42///
43/// To configure `CaseAttachmentService` use the `with_*` methods in the type returned
44/// by [builder()][CaseAttachmentService::builder]. The default configuration should
45/// work for most applications. Common configuration changes include
46///
47/// * [with_endpoint()]: by default this client uses the global default endpoint
48///   (`https://cloudsupport.googleapis.com`). Applications using regional
49///   endpoints or running in restricted networks (e.g. a network configured
50//    with [Private Google Access with VPC Service Controls]) may want to
51///   override this default.
52/// * [with_credentials()]: by default this client uses
53///   [Application Default Credentials]. Applications using custom
54///   authentication may need to override this default.
55///
56/// [with_endpoint()]: super::builder::case_attachment_service::ClientBuilder::with_endpoint
57/// [with_credentials()]: super::builder::case_attachment_service::ClientBuilder::with_credentials
58/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
59/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
60///
61/// # Pooling and Cloning
62///
63/// `CaseAttachmentService` holds a connection pool internally, it is advised to
64/// create one and reuse it. You do not need to wrap `CaseAttachmentService` in
65/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
66/// already uses an `Arc` internally.
67#[derive(Clone, Debug)]
68pub struct CaseAttachmentService {
69    inner: std::sync::Arc<dyn super::stub::dynamic::CaseAttachmentService>,
70}
71
72impl CaseAttachmentService {
73    /// Returns a builder for [CaseAttachmentService].
74    ///
75    /// ```
76    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
77    /// # use google_cloud_support_v2::client::CaseAttachmentService;
78    /// let client = CaseAttachmentService::builder().build().await?;
79    /// # Ok(()) }
80    /// ```
81    pub fn builder() -> super::builder::case_attachment_service::ClientBuilder {
82        crate::new_client_builder(super::builder::case_attachment_service::client::Factory)
83    }
84
85    /// Creates a new client from the provided stub.
86    ///
87    /// The most common case for calling this function is in tests mocking the
88    /// client's behavior.
89    pub fn from_stub<T>(stub: T) -> Self
90    where
91        T: super::stub::CaseAttachmentService + 'static,
92    {
93        Self {
94            inner: std::sync::Arc::new(stub),
95        }
96    }
97
98    pub(crate) async fn new(
99        config: gaxi::options::ClientConfig,
100    ) -> crate::ClientBuilderResult<Self> {
101        let inner = Self::build_inner(config).await?;
102        Ok(Self { inner })
103    }
104
105    async fn build_inner(
106        conf: gaxi::options::ClientConfig,
107    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CaseAttachmentService>>
108    {
109        if gaxi::options::tracing_enabled(&conf) {
110            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111        }
112        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113    }
114
115    async fn build_transport(
116        conf: gaxi::options::ClientConfig,
117    ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
118        super::transport::CaseAttachmentService::new(conf).await
119    }
120
121    async fn build_with_tracing(
122        conf: gaxi::options::ClientConfig,
123    ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
124        Self::build_transport(conf)
125            .await
126            .map(super::tracing::CaseAttachmentService::new)
127    }
128
129    /// List all the attachments associated with a support case.
130    ///
131    /// # Example
132    /// ```
133    /// # use google_cloud_support_v2::client::CaseAttachmentService;
134    /// use google_cloud_gax::paginator::ItemPaginator as _;
135    /// use google_cloud_support_v2::Result;
136    /// async fn sample(
137    ///    client: &CaseAttachmentService, parent: &str
138    /// ) -> Result<()> {
139    ///     let mut list = client.list_attachments()
140    ///         .set_parent(parent)
141    ///         .by_item();
142    ///     while let Some(item) = list.next().await.transpose()? {
143    ///         println!("{:?}", item);
144    ///     }
145    ///     Ok(())
146    /// }
147    /// ```
148    pub fn list_attachments(&self) -> super::builder::case_attachment_service::ListAttachments {
149        super::builder::case_attachment_service::ListAttachments::new(self.inner.clone())
150    }
151}
152
153/// Implements a client for the Google Cloud Support API.
154///
155/// # Example
156/// ```
157/// # use google_cloud_support_v2::client::CaseService;
158/// use google_cloud_gax::paginator::ItemPaginator as _;
159/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
160///     let client = CaseService::builder().build().await?;
161///     let parent = "parent_value";
162///     let mut list = client.list_cases()
163///         .set_parent(parent)
164///         .by_item();
165///     while let Some(item) = list.next().await.transpose()? {
166///         println!("{:?}", item);
167///     }
168/// # Ok(()) }
169/// ```
170///
171/// # Service Description
172///
173/// A service to manage Google Cloud support cases.
174///
175/// # Configuration
176///
177/// To configure `CaseService` use the `with_*` methods in the type returned
178/// by [builder()][CaseService::builder]. The default configuration should
179/// work for most applications. Common configuration changes include
180///
181/// * [with_endpoint()]: by default this client uses the global default endpoint
182///   (`https://cloudsupport.googleapis.com`). Applications using regional
183///   endpoints or running in restricted networks (e.g. a network configured
184//    with [Private Google Access with VPC Service Controls]) may want to
185///   override this default.
186/// * [with_credentials()]: by default this client uses
187///   [Application Default Credentials]. Applications using custom
188///   authentication may need to override this default.
189///
190/// [with_endpoint()]: super::builder::case_service::ClientBuilder::with_endpoint
191/// [with_credentials()]: super::builder::case_service::ClientBuilder::with_credentials
192/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
193/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
194///
195/// # Pooling and Cloning
196///
197/// `CaseService` holds a connection pool internally, it is advised to
198/// create one and reuse it. You do not need to wrap `CaseService` in
199/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
200/// already uses an `Arc` internally.
201#[derive(Clone, Debug)]
202pub struct CaseService {
203    inner: std::sync::Arc<dyn super::stub::dynamic::CaseService>,
204}
205
206impl CaseService {
207    /// Returns a builder for [CaseService].
208    ///
209    /// ```
210    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
211    /// # use google_cloud_support_v2::client::CaseService;
212    /// let client = CaseService::builder().build().await?;
213    /// # Ok(()) }
214    /// ```
215    pub fn builder() -> super::builder::case_service::ClientBuilder {
216        crate::new_client_builder(super::builder::case_service::client::Factory)
217    }
218
219    /// Creates a new client from the provided stub.
220    ///
221    /// The most common case for calling this function is in tests mocking the
222    /// client's behavior.
223    pub fn from_stub<T>(stub: T) -> Self
224    where
225        T: super::stub::CaseService + 'static,
226    {
227        Self {
228            inner: std::sync::Arc::new(stub),
229        }
230    }
231
232    pub(crate) async fn new(
233        config: gaxi::options::ClientConfig,
234    ) -> crate::ClientBuilderResult<Self> {
235        let inner = Self::build_inner(config).await?;
236        Ok(Self { inner })
237    }
238
239    async fn build_inner(
240        conf: gaxi::options::ClientConfig,
241    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CaseService>> {
242        if gaxi::options::tracing_enabled(&conf) {
243            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
244        }
245        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
246    }
247
248    async fn build_transport(
249        conf: gaxi::options::ClientConfig,
250    ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
251        super::transport::CaseService::new(conf).await
252    }
253
254    async fn build_with_tracing(
255        conf: gaxi::options::ClientConfig,
256    ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
257        Self::build_transport(conf)
258            .await
259            .map(super::tracing::CaseService::new)
260    }
261
262    /// Retrieve a case.
263    ///
264    /// # Example
265    /// ```
266    /// # use google_cloud_support_v2::client::CaseService;
267    /// use google_cloud_support_v2::Result;
268    /// async fn sample(
269    ///    client: &CaseService, name: &str
270    /// ) -> Result<()> {
271    ///     let response = client.get_case()
272    ///         .set_name(name)
273    ///         .send().await?;
274    ///     println!("response {:?}", response);
275    ///     Ok(())
276    /// }
277    /// ```
278    pub fn get_case(&self) -> super::builder::case_service::GetCase {
279        super::builder::case_service::GetCase::new(self.inner.clone())
280    }
281
282    /// Retrieve all cases under a parent, but not its children.
283    ///
284    /// For example, listing cases under an organization only returns the cases
285    /// that are directly parented by that organization. To retrieve cases
286    /// under an organization and its projects, use `cases.search`.
287    ///
288    /// # Example
289    /// ```
290    /// # use google_cloud_support_v2::client::CaseService;
291    /// use google_cloud_gax::paginator::ItemPaginator as _;
292    /// use google_cloud_support_v2::Result;
293    /// async fn sample(
294    ///    client: &CaseService, parent: &str
295    /// ) -> Result<()> {
296    ///     let mut list = client.list_cases()
297    ///         .set_parent(parent)
298    ///         .by_item();
299    ///     while let Some(item) = list.next().await.transpose()? {
300    ///         println!("{:?}", item);
301    ///     }
302    ///     Ok(())
303    /// }
304    /// ```
305    pub fn list_cases(&self) -> super::builder::case_service::ListCases {
306        super::builder::case_service::ListCases::new(self.inner.clone())
307    }
308
309    /// Search for cases using a query.
310    ///
311    /// # Example
312    /// ```
313    /// # use google_cloud_support_v2::client::CaseService;
314    /// use google_cloud_gax::paginator::ItemPaginator as _;
315    /// use google_cloud_support_v2::Result;
316    /// async fn sample(
317    ///    client: &CaseService
318    /// ) -> Result<()> {
319    ///     let mut list = client.search_cases()
320    ///         /* set fields */
321    ///         .by_item();
322    ///     while let Some(item) = list.next().await.transpose()? {
323    ///         println!("{:?}", item);
324    ///     }
325    ///     Ok(())
326    /// }
327    /// ```
328    pub fn search_cases(&self) -> super::builder::case_service::SearchCases {
329        super::builder::case_service::SearchCases::new(self.inner.clone())
330    }
331
332    /// Create a new case and associate it with a parent.
333    ///
334    /// It must have the following fields set: `display_name`, `description`,
335    /// `classification`, and `priority`. If you're just testing the API and don't
336    /// want to route your case to an agent, set `testCase=true`.
337    ///
338    /// # Example
339    /// ```
340    /// # use google_cloud_support_v2::client::CaseService;
341    /// use google_cloud_support_v2::model::Case;
342    /// use google_cloud_support_v2::Result;
343    /// async fn sample(
344    ///    client: &CaseService, parent: &str
345    /// ) -> Result<()> {
346    ///     let response = client.create_case()
347    ///         .set_parent(parent)
348    ///         .set_case(
349    ///             Case::new()/* set fields */
350    ///         )
351    ///         .send().await?;
352    ///     println!("response {:?}", response);
353    ///     Ok(())
354    /// }
355    /// ```
356    pub fn create_case(&self) -> super::builder::case_service::CreateCase {
357        super::builder::case_service::CreateCase::new(self.inner.clone())
358    }
359
360    /// Update a case. Only some fields can be updated.
361    ///
362    /// # Example
363    /// ```
364    /// # use google_cloud_support_v2::client::CaseService;
365    /// # extern crate wkt as google_cloud_wkt;
366    /// use google_cloud_wkt::FieldMask;
367    /// use google_cloud_support_v2::model::Case;
368    /// use google_cloud_support_v2::Result;
369    /// async fn sample(
370    ///    client: &CaseService, name: &str
371    /// ) -> Result<()> {
372    ///     let response = client.update_case()
373    ///         .set_case(
374    ///             Case::new().set_name(name)/* set fields */
375    ///         )
376    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
377    ///         .send().await?;
378    ///     println!("response {:?}", response);
379    ///     Ok(())
380    /// }
381    /// ```
382    pub fn update_case(&self) -> super::builder::case_service::UpdateCase {
383        super::builder::case_service::UpdateCase::new(self.inner.clone())
384    }
385
386    /// Escalate a case, starting the Google Cloud Support escalation management
387    /// process.
388    ///
389    /// This operation is only available for some support services. Go to
390    /// <https://cloud.google.com/support> and look for 'Technical support
391    /// escalations' in the feature list to find out which ones let you
392    /// do that.
393    ///
394    /// # Example
395    /// ```
396    /// # use google_cloud_support_v2::client::CaseService;
397    /// use google_cloud_support_v2::Result;
398    /// async fn sample(
399    ///    client: &CaseService
400    /// ) -> Result<()> {
401    ///     let response = client.escalate_case()
402    ///         /* set fields */
403    ///         .send().await?;
404    ///     println!("response {:?}", response);
405    ///     Ok(())
406    /// }
407    /// ```
408    pub fn escalate_case(&self) -> super::builder::case_service::EscalateCase {
409        super::builder::case_service::EscalateCase::new(self.inner.clone())
410    }
411
412    /// Close a case.
413    ///
414    /// # Example
415    /// ```
416    /// # use google_cloud_support_v2::client::CaseService;
417    /// use google_cloud_support_v2::Result;
418    /// async fn sample(
419    ///    client: &CaseService
420    /// ) -> Result<()> {
421    ///     let response = client.close_case()
422    ///         /* set fields */
423    ///         .send().await?;
424    ///     println!("response {:?}", response);
425    ///     Ok(())
426    /// }
427    /// ```
428    pub fn close_case(&self) -> super::builder::case_service::CloseCase {
429        super::builder::case_service::CloseCase::new(self.inner.clone())
430    }
431
432    /// Retrieve valid classifications to use when creating a support case.
433    ///
434    /// Classifications are hierarchical. Each classification is a string
435    /// containing all levels of the hierarchy separated by `" > "`. For example,
436    /// `"Technical Issue > Compute > Compute Engine"`.
437    ///
438    /// Classification IDs returned by this endpoint are valid for at least six
439    /// months. When a classification is deactivated, this endpoint immediately
440    /// stops returning it. After six months, `case.create` requests using the
441    /// classification will fail.
442    ///
443    /// # Example
444    /// ```
445    /// # use google_cloud_support_v2::client::CaseService;
446    /// use google_cloud_gax::paginator::ItemPaginator as _;
447    /// use google_cloud_support_v2::Result;
448    /// async fn sample(
449    ///    client: &CaseService
450    /// ) -> Result<()> {
451    ///     let mut list = client.search_case_classifications()
452    ///         /* set fields */
453    ///         .by_item();
454    ///     while let Some(item) = list.next().await.transpose()? {
455    ///         println!("{:?}", item);
456    ///     }
457    ///     Ok(())
458    /// }
459    /// ```
460    pub fn search_case_classifications(
461        &self,
462    ) -> super::builder::case_service::SearchCaseClassifications {
463        super::builder::case_service::SearchCaseClassifications::new(self.inner.clone())
464    }
465}
466
467/// Implements a client for the Google Cloud Support API.
468///
469/// # Example
470/// ```
471/// # use google_cloud_support_v2::client::CommentService;
472/// use google_cloud_gax::paginator::ItemPaginator as _;
473/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
474///     let client = CommentService::builder().build().await?;
475///     let parent = "parent_value";
476///     let mut list = client.list_comments()
477///         .set_parent(parent)
478///         .by_item();
479///     while let Some(item) = list.next().await.transpose()? {
480///         println!("{:?}", item);
481///     }
482/// # Ok(()) }
483/// ```
484///
485/// # Service Description
486///
487/// A service to manage comments on cases.
488///
489/// # Configuration
490///
491/// To configure `CommentService` use the `with_*` methods in the type returned
492/// by [builder()][CommentService::builder]. The default configuration should
493/// work for most applications. Common configuration changes include
494///
495/// * [with_endpoint()]: by default this client uses the global default endpoint
496///   (`https://cloudsupport.googleapis.com`). Applications using regional
497///   endpoints or running in restricted networks (e.g. a network configured
498//    with [Private Google Access with VPC Service Controls]) may want to
499///   override this default.
500/// * [with_credentials()]: by default this client uses
501///   [Application Default Credentials]. Applications using custom
502///   authentication may need to override this default.
503///
504/// [with_endpoint()]: super::builder::comment_service::ClientBuilder::with_endpoint
505/// [with_credentials()]: super::builder::comment_service::ClientBuilder::with_credentials
506/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
507/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
508///
509/// # Pooling and Cloning
510///
511/// `CommentService` holds a connection pool internally, it is advised to
512/// create one and reuse it. You do not need to wrap `CommentService` in
513/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
514/// already uses an `Arc` internally.
515#[derive(Clone, Debug)]
516pub struct CommentService {
517    inner: std::sync::Arc<dyn super::stub::dynamic::CommentService>,
518}
519
520impl CommentService {
521    /// Returns a builder for [CommentService].
522    ///
523    /// ```
524    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
525    /// # use google_cloud_support_v2::client::CommentService;
526    /// let client = CommentService::builder().build().await?;
527    /// # Ok(()) }
528    /// ```
529    pub fn builder() -> super::builder::comment_service::ClientBuilder {
530        crate::new_client_builder(super::builder::comment_service::client::Factory)
531    }
532
533    /// Creates a new client from the provided stub.
534    ///
535    /// The most common case for calling this function is in tests mocking the
536    /// client's behavior.
537    pub fn from_stub<T>(stub: T) -> Self
538    where
539        T: super::stub::CommentService + 'static,
540    {
541        Self {
542            inner: std::sync::Arc::new(stub),
543        }
544    }
545
546    pub(crate) async fn new(
547        config: gaxi::options::ClientConfig,
548    ) -> crate::ClientBuilderResult<Self> {
549        let inner = Self::build_inner(config).await?;
550        Ok(Self { inner })
551    }
552
553    async fn build_inner(
554        conf: gaxi::options::ClientConfig,
555    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CommentService>> {
556        if gaxi::options::tracing_enabled(&conf) {
557            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
558        }
559        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
560    }
561
562    async fn build_transport(
563        conf: gaxi::options::ClientConfig,
564    ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
565        super::transport::CommentService::new(conf).await
566    }
567
568    async fn build_with_tracing(
569        conf: gaxi::options::ClientConfig,
570    ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
571        Self::build_transport(conf)
572            .await
573            .map(super::tracing::CommentService::new)
574    }
575
576    /// List all the comments associated with a case.
577    ///
578    /// # Example
579    /// ```
580    /// # use google_cloud_support_v2::client::CommentService;
581    /// use google_cloud_gax::paginator::ItemPaginator as _;
582    /// use google_cloud_support_v2::Result;
583    /// async fn sample(
584    ///    client: &CommentService, parent: &str
585    /// ) -> Result<()> {
586    ///     let mut list = client.list_comments()
587    ///         .set_parent(parent)
588    ///         .by_item();
589    ///     while let Some(item) = list.next().await.transpose()? {
590    ///         println!("{:?}", item);
591    ///     }
592    ///     Ok(())
593    /// }
594    /// ```
595    pub fn list_comments(&self) -> super::builder::comment_service::ListComments {
596        super::builder::comment_service::ListComments::new(self.inner.clone())
597    }
598
599    /// Add a new comment to a case.
600    ///
601    /// The comment must have the following fields set: `body`.
602    ///
603    /// # Example
604    /// ```
605    /// # use google_cloud_support_v2::client::CommentService;
606    /// use google_cloud_support_v2::model::Comment;
607    /// use google_cloud_support_v2::Result;
608    /// async fn sample(
609    ///    client: &CommentService, parent: &str
610    /// ) -> Result<()> {
611    ///     let response = client.create_comment()
612    ///         .set_parent(parent)
613    ///         .set_comment(
614    ///             Comment::new()/* set fields */
615    ///         )
616    ///         .send().await?;
617    ///     println!("response {:?}", response);
618    ///     Ok(())
619    /// }
620    /// ```
621    pub fn create_comment(&self) -> super::builder::comment_service::CreateComment {
622        super::builder::comment_service::CreateComment::new(self.inner.clone())
623    }
624}