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