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