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/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24/// # use google_cloud_support_v2::client::CaseAttachmentService;
25/// let client = CaseAttachmentService::builder().build().await?;
26/// // use `client` to make requests to the Google Cloud Support API.
27/// # Ok(()) }
28/// ```
29///
30/// # Service Description
31///
32/// A service to manage file attachments for Google Cloud support cases.
33///
34/// # Configuration
35///
36/// To configure `CaseAttachmentService` use the `with_*` methods in the type returned
37/// by [builder()][CaseAttachmentService::builder]. The default configuration should
38/// work for most applications. Common configuration changes include
39///
40/// * [with_endpoint()]: by default this client uses the global default endpoint
41///   (`https://cloudsupport.googleapis.com`). Applications using regional
42///   endpoints or running in restricted networks (e.g. a network configured
43//    with [Private Google Access with VPC Service Controls]) may want to
44///   override this default.
45/// * [with_credentials()]: by default this client uses
46///   [Application Default Credentials]. Applications using custom
47///   authentication may need to override this default.
48///
49/// [with_endpoint()]: super::builder::case_attachment_service::ClientBuilder::with_endpoint
50/// [with_credentials()]: super::builder::case_attachment_service::ClientBuilder::credentials
51/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
52/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
53///
54/// # Pooling and Cloning
55///
56/// `CaseAttachmentService` holds a connection pool internally, it is advised to
57/// create one and the reuse it.  You do not need to wrap `CaseAttachmentService` in
58/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
59/// already uses an `Arc` internally.
60#[derive(Clone, Debug)]
61pub struct CaseAttachmentService {
62    inner: std::sync::Arc<dyn super::stub::dynamic::CaseAttachmentService>,
63}
64
65impl CaseAttachmentService {
66    /// Returns a builder for [CaseAttachmentService].
67    ///
68    /// ```
69    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
70    /// # use google_cloud_support_v2::client::CaseAttachmentService;
71    /// let client = CaseAttachmentService::builder().build().await?;
72    /// # Ok(()) }
73    /// ```
74    pub fn builder() -> super::builder::case_attachment_service::ClientBuilder {
75        crate::new_client_builder(super::builder::case_attachment_service::client::Factory)
76    }
77
78    /// Creates a new client from the provided stub.
79    ///
80    /// The most common case for calling this function is in tests mocking the
81    /// client's behavior.
82    pub fn from_stub<T>(stub: T) -> Self
83    where
84        T: super::stub::CaseAttachmentService + 'static,
85    {
86        Self {
87            inner: std::sync::Arc::new(stub),
88        }
89    }
90
91    pub(crate) async fn new(
92        config: gaxi::options::ClientConfig,
93    ) -> crate::ClientBuilderResult<Self> {
94        let inner = Self::build_inner(config).await?;
95        Ok(Self { inner })
96    }
97
98    async fn build_inner(
99        conf: gaxi::options::ClientConfig,
100    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CaseAttachmentService>>
101    {
102        if gaxi::options::tracing_enabled(&conf) {
103            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
104        }
105        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
106    }
107
108    async fn build_transport(
109        conf: gaxi::options::ClientConfig,
110    ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
111        super::transport::CaseAttachmentService::new(conf).await
112    }
113
114    async fn build_with_tracing(
115        conf: gaxi::options::ClientConfig,
116    ) -> crate::ClientBuilderResult<impl super::stub::CaseAttachmentService> {
117        Self::build_transport(conf)
118            .await
119            .map(super::tracing::CaseAttachmentService::new)
120    }
121
122    /// List all the attachments associated with a support case.
123    pub fn list_attachments(&self) -> super::builder::case_attachment_service::ListAttachments {
124        super::builder::case_attachment_service::ListAttachments::new(self.inner.clone())
125    }
126}
127
128/// Implements a client for the Google Cloud Support API.
129///
130/// # Example
131/// ```
132/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
133/// # use google_cloud_support_v2::client::CaseService;
134/// let client = CaseService::builder().build().await?;
135/// // use `client` to make requests to the Google Cloud Support API.
136/// # Ok(()) }
137/// ```
138///
139/// # Service Description
140///
141/// A service to manage Google Cloud support cases.
142///
143/// # Configuration
144///
145/// To configure `CaseService` use the `with_*` methods in the type returned
146/// by [builder()][CaseService::builder]. The default configuration should
147/// work for most applications. Common configuration changes include
148///
149/// * [with_endpoint()]: by default this client uses the global default endpoint
150///   (`https://cloudsupport.googleapis.com`). Applications using regional
151///   endpoints or running in restricted networks (e.g. a network configured
152//    with [Private Google Access with VPC Service Controls]) may want to
153///   override this default.
154/// * [with_credentials()]: by default this client uses
155///   [Application Default Credentials]. Applications using custom
156///   authentication may need to override this default.
157///
158/// [with_endpoint()]: super::builder::case_service::ClientBuilder::with_endpoint
159/// [with_credentials()]: super::builder::case_service::ClientBuilder::credentials
160/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
161/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
162///
163/// # Pooling and Cloning
164///
165/// `CaseService` holds a connection pool internally, it is advised to
166/// create one and the reuse it.  You do not need to wrap `CaseService` in
167/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
168/// already uses an `Arc` internally.
169#[derive(Clone, Debug)]
170pub struct CaseService {
171    inner: std::sync::Arc<dyn super::stub::dynamic::CaseService>,
172}
173
174impl CaseService {
175    /// Returns a builder for [CaseService].
176    ///
177    /// ```
178    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
179    /// # use google_cloud_support_v2::client::CaseService;
180    /// let client = CaseService::builder().build().await?;
181    /// # Ok(()) }
182    /// ```
183    pub fn builder() -> super::builder::case_service::ClientBuilder {
184        crate::new_client_builder(super::builder::case_service::client::Factory)
185    }
186
187    /// Creates a new client from the provided stub.
188    ///
189    /// The most common case for calling this function is in tests mocking the
190    /// client's behavior.
191    pub fn from_stub<T>(stub: T) -> Self
192    where
193        T: super::stub::CaseService + 'static,
194    {
195        Self {
196            inner: std::sync::Arc::new(stub),
197        }
198    }
199
200    pub(crate) async fn new(
201        config: gaxi::options::ClientConfig,
202    ) -> crate::ClientBuilderResult<Self> {
203        let inner = Self::build_inner(config).await?;
204        Ok(Self { inner })
205    }
206
207    async fn build_inner(
208        conf: gaxi::options::ClientConfig,
209    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CaseService>> {
210        if gaxi::options::tracing_enabled(&conf) {
211            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
212        }
213        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
214    }
215
216    async fn build_transport(
217        conf: gaxi::options::ClientConfig,
218    ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
219        super::transport::CaseService::new(conf).await
220    }
221
222    async fn build_with_tracing(
223        conf: gaxi::options::ClientConfig,
224    ) -> crate::ClientBuilderResult<impl super::stub::CaseService> {
225        Self::build_transport(conf)
226            .await
227            .map(super::tracing::CaseService::new)
228    }
229
230    /// Retrieve a case.
231    pub fn get_case(&self) -> super::builder::case_service::GetCase {
232        super::builder::case_service::GetCase::new(self.inner.clone())
233    }
234
235    /// Retrieve all cases under a parent, but not its children.
236    ///
237    /// For example, listing cases under an organization only returns the cases
238    /// that are directly parented by that organization. To retrieve cases
239    /// under an organization and its projects, use `cases.search`.
240    pub fn list_cases(&self) -> super::builder::case_service::ListCases {
241        super::builder::case_service::ListCases::new(self.inner.clone())
242    }
243
244    /// Search for cases using a query.
245    pub fn search_cases(&self) -> super::builder::case_service::SearchCases {
246        super::builder::case_service::SearchCases::new(self.inner.clone())
247    }
248
249    /// Create a new case and associate it with a parent.
250    ///
251    /// It must have the following fields set: `display_name`, `description`,
252    /// `classification`, and `priority`. If you're just testing the API and don't
253    /// want to route your case to an agent, set `testCase=true`.
254    pub fn create_case(&self) -> super::builder::case_service::CreateCase {
255        super::builder::case_service::CreateCase::new(self.inner.clone())
256    }
257
258    /// Update a case. Only some fields can be updated.
259    pub fn update_case(&self) -> super::builder::case_service::UpdateCase {
260        super::builder::case_service::UpdateCase::new(self.inner.clone())
261    }
262
263    /// Escalate a case, starting the Google Cloud Support escalation management
264    /// process.
265    ///
266    /// This operation is only available for some support services. Go to
267    /// <https://cloud.google.com/support> and look for 'Technical support
268    /// escalations' in the feature list to find out which ones let you
269    /// do that.
270    pub fn escalate_case(&self) -> super::builder::case_service::EscalateCase {
271        super::builder::case_service::EscalateCase::new(self.inner.clone())
272    }
273
274    /// Close a case.
275    pub fn close_case(&self) -> super::builder::case_service::CloseCase {
276        super::builder::case_service::CloseCase::new(self.inner.clone())
277    }
278
279    /// Retrieve valid classifications to use when creating a support case.
280    ///
281    /// Classifications are hierarchical. Each classification is a string
282    /// containing all levels of the hierarchy separated by `" > "`. For example,
283    /// `"Technical Issue > Compute > Compute Engine"`.
284    ///
285    /// Classification IDs returned by this endpoint are valid for at least six
286    /// months. When a classification is deactivated, this endpoint immediately
287    /// stops returning it. After six months, `case.create` requests using the
288    /// classification will fail.
289    pub fn search_case_classifications(
290        &self,
291    ) -> super::builder::case_service::SearchCaseClassifications {
292        super::builder::case_service::SearchCaseClassifications::new(self.inner.clone())
293    }
294}
295
296/// Implements a client for the Google Cloud Support API.
297///
298/// # Example
299/// ```
300/// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
301/// # use google_cloud_support_v2::client::CommentService;
302/// let client = CommentService::builder().build().await?;
303/// // use `client` to make requests to the Google Cloud Support API.
304/// # Ok(()) }
305/// ```
306///
307/// # Service Description
308///
309/// A service to manage comments on cases.
310///
311/// # Configuration
312///
313/// To configure `CommentService` use the `with_*` methods in the type returned
314/// by [builder()][CommentService::builder]. The default configuration should
315/// work for most applications. Common configuration changes include
316///
317/// * [with_endpoint()]: by default this client uses the global default endpoint
318///   (`https://cloudsupport.googleapis.com`). Applications using regional
319///   endpoints or running in restricted networks (e.g. a network configured
320//    with [Private Google Access with VPC Service Controls]) may want to
321///   override this default.
322/// * [with_credentials()]: by default this client uses
323///   [Application Default Credentials]. Applications using custom
324///   authentication may need to override this default.
325///
326/// [with_endpoint()]: super::builder::comment_service::ClientBuilder::with_endpoint
327/// [with_credentials()]: super::builder::comment_service::ClientBuilder::credentials
328/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
329/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
330///
331/// # Pooling and Cloning
332///
333/// `CommentService` holds a connection pool internally, it is advised to
334/// create one and the reuse it.  You do not need to wrap `CommentService` in
335/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
336/// already uses an `Arc` internally.
337#[derive(Clone, Debug)]
338pub struct CommentService {
339    inner: std::sync::Arc<dyn super::stub::dynamic::CommentService>,
340}
341
342impl CommentService {
343    /// Returns a builder for [CommentService].
344    ///
345    /// ```
346    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
347    /// # use google_cloud_support_v2::client::CommentService;
348    /// let client = CommentService::builder().build().await?;
349    /// # Ok(()) }
350    /// ```
351    pub fn builder() -> super::builder::comment_service::ClientBuilder {
352        crate::new_client_builder(super::builder::comment_service::client::Factory)
353    }
354
355    /// Creates a new client from the provided stub.
356    ///
357    /// The most common case for calling this function is in tests mocking the
358    /// client's behavior.
359    pub fn from_stub<T>(stub: T) -> Self
360    where
361        T: super::stub::CommentService + 'static,
362    {
363        Self {
364            inner: std::sync::Arc::new(stub),
365        }
366    }
367
368    pub(crate) async fn new(
369        config: gaxi::options::ClientConfig,
370    ) -> crate::ClientBuilderResult<Self> {
371        let inner = Self::build_inner(config).await?;
372        Ok(Self { inner })
373    }
374
375    async fn build_inner(
376        conf: gaxi::options::ClientConfig,
377    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CommentService>> {
378        if gaxi::options::tracing_enabled(&conf) {
379            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
380        }
381        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
382    }
383
384    async fn build_transport(
385        conf: gaxi::options::ClientConfig,
386    ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
387        super::transport::CommentService::new(conf).await
388    }
389
390    async fn build_with_tracing(
391        conf: gaxi::options::ClientConfig,
392    ) -> crate::ClientBuilderResult<impl super::stub::CommentService> {
393        Self::build_transport(conf)
394            .await
395            .map(super::tracing::CommentService::new)
396    }
397
398    /// List all the comments associated with a case.
399    pub fn list_comments(&self) -> super::builder::comment_service::ListComments {
400        super::builder::comment_service::ListComments::new(self.inner.clone())
401    }
402
403    /// Add a new comment to a case.
404    ///
405    /// The comment must have the following fields set: `body`.
406    pub fn create_comment(&self) -> super::builder::comment_service::CreateComment {
407        super::builder::comment_service::CreateComment::new(self.inner.clone())
408    }
409}