google_cloudsupport2_beta/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudSupport related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudsupport2_beta as cloudsupport2_beta;
49/// use cloudsupport2_beta::{Result, Error};
50/// # async fn dox() {
51/// use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = CloudSupport::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.cases().list("parent")
93///              .product_line("duo")
94///              .page_token("ipsum")
95///              .page_size(-62)
96///              .filter("Lorem")
97///              .doit().await;
98///
99/// match result {
100///     Err(e) => match e {
101///         // The Error enum provides details about what exactly happened.
102///         // You can also just use its `Debug`, `Display` or `Error` traits
103///          Error::HttpError(_)
104///         |Error::Io(_)
105///         |Error::MissingAPIKey
106///         |Error::MissingToken(_)
107///         |Error::Cancelled
108///         |Error::UploadSizeLimitExceeded(_, _)
109///         |Error::Failure(_)
110///         |Error::BadRequest(_)
111///         |Error::FieldClash(_)
112///         |Error::JsonDecodeError(_, _) => println!("{}", e),
113///     },
114///     Ok(res) => println!("Success: {:?}", res),
115/// }
116/// # }
117/// ```
118#[derive(Clone)]
119pub struct CloudSupport<C> {
120    pub client: common::Client<C>,
121    pub auth: Box<dyn common::GetToken>,
122    _user_agent: String,
123    _base_url: String,
124    _root_url: String,
125}
126
127impl<C> common::Hub for CloudSupport<C> {}
128
129impl<'a, C> CloudSupport<C> {
130    pub fn new<A: 'static + common::GetToken>(
131        client: common::Client<C>,
132        auth: A,
133    ) -> CloudSupport<C> {
134        CloudSupport {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://cloudsupport.googleapis.com/".to_string(),
139            _root_url: "https://cloudsupport.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn case_classifications(&'a self) -> CaseClassificationMethods<'a, C> {
144        CaseClassificationMethods { hub: self }
145    }
146    pub fn cases(&'a self) -> CaseMethods<'a, C> {
147        CaseMethods { hub: self }
148    }
149    pub fn media(&'a self) -> MediaMethods<'a, C> {
150        MediaMethods { hub: self }
151    }
152
153    /// Set the user-agent header field to use in all requests to the server.
154    /// It defaults to `google-api-rust-client/7.0.0`.
155    ///
156    /// Returns the previously set user-agent.
157    pub fn user_agent(&mut self, agent_name: String) -> String {
158        std::mem::replace(&mut self._user_agent, agent_name)
159    }
160
161    /// Set the base url to use in all requests to the server.
162    /// It defaults to `https://cloudsupport.googleapis.com/`.
163    ///
164    /// Returns the previously set base url.
165    pub fn base_url(&mut self, new_base_url: String) -> String {
166        std::mem::replace(&mut self._base_url, new_base_url)
167    }
168
169    /// Set the root url to use in all requests to the server.
170    /// It defaults to `https://cloudsupport.googleapis.com/`.
171    ///
172    /// Returns the previously set root url.
173    pub fn root_url(&mut self, new_root_url: String) -> String {
174        std::mem::replace(&mut self._root_url, new_root_url)
175    }
176}
177
178// ############
179// SCHEMAS ###
180// ##########
181/// An Actor represents an entity that performed an action. For example, an actor could be a user who posted a comment on a support case, a user who uploaded an attachment, or a service account that created a support case.
182///
183/// This type is not used in any activity, and only used as *part* of another schema.
184///
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct Actor {
189    /// The name to display for the actor. If not provided, it is inferred from credentials supplied during case creation. When an email is provided, a display name must also be provided. This will be obfuscated if the user is a Google Support agent.
190    #[serde(rename = "displayName")]
191    pub display_name: Option<String>,
192    /// The email address of the actor. If not provided, it is inferred from the credentials supplied during case creation. When a name is provided, an email must also be provided. If the user is a Google Support agent, this is obfuscated. This field is deprecated. Use `username` instead.
193    pub email: Option<String>,
194    /// Output only. Whether the actor is a Google support actor.
195    #[serde(rename = "googleSupport")]
196    pub google_support: Option<bool>,
197    /// Output only. The username of the actor. It may look like an email or other format provided by the identity provider. If not provided, it is inferred from the credentials supplied. When a name is provided, a username must also be provided. If the user is a Google Support agent, this will not be set.
198    pub username: Option<String>,
199}
200
201impl common::Part for Actor {}
202
203/// An Attachment contains metadata about a file that was uploaded to a case - it is NOT a file itself. That being said, the name of an Attachment object can be used to download its accompanying file through the `media.download` endpoint. While attachments can be uploaded in the console at the same time as a comment, they’re associated on a “case” level, not a “comment” level.
204///
205/// # Activities
206///
207/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
208/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
209///
210/// * [attachments get cases](CaseAttachmentGetCall) (response)
211/// * [upload media](MediaUploadCall) (response)
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct Attachment {
216    /// Output only. The time at which the attachment was created.
217    #[serde(rename = "createTime")]
218    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
219    /// Output only. The user who uploaded the attachment. Note, the name and email will be obfuscated if the attachment was uploaded by Google support.
220    pub creator: Option<Actor>,
221    /// The filename of the attachment (e.g. `"graph.jpg"`).
222    pub filename: Option<String>,
223    /// Output only. The MIME type of the attachment (e.g. text/plain).
224    #[serde(rename = "mimeType")]
225    pub mime_type: Option<String>,
226    /// Output only. Identifier. The resource name of the attachment.
227    pub name: Option<String>,
228    /// Output only. The size of the attachment in bytes.
229    #[serde(rename = "sizeBytes")]
230    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
231    pub size_bytes: Option<i64>,
232}
233
234impl common::ResponseResult for Attachment {}
235
236/// # gdata.* are outside protos with mising documentation
237///
238/// This type is not used in any activity, and only used as *part* of another schema.
239///
240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
241#[serde_with::serde_as]
242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
243pub struct Blobstore2Info {
244    /// # gdata.* are outside protos with mising documentation
245    #[serde(rename = "blobGeneration")]
246    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
247    pub blob_generation: Option<i64>,
248    /// # gdata.* are outside protos with mising documentation
249    #[serde(rename = "blobId")]
250    pub blob_id: Option<String>,
251    /// # gdata.* are outside protos with mising documentation
252    #[serde(rename = "downloadExternalReadToken")]
253    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
254    pub download_external_read_token: Option<Vec<u8>>,
255    /// # gdata.* are outside protos with mising documentation
256    #[serde(rename = "downloadReadHandle")]
257    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
258    pub download_read_handle: Option<Vec<u8>>,
259    /// # gdata.* are outside protos with mising documentation
260    #[serde(rename = "readToken")]
261    pub read_token: Option<String>,
262    /// # gdata.* are outside protos with mising documentation
263    #[serde(rename = "uploadMetadataContainer")]
264    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
265    pub upload_metadata_container: Option<Vec<u8>>,
266}
267
268impl common::Part for Blobstore2Info {}
269
270/// A Case is an object that contains the details of a support case. It contains fields for the time it was created, its priority, its classification, and more. Cases can also have comments and attachments that get added over time. A case is parented by a Google Cloud organization or project. Organizations are identified by a number, so the name of a case parented by an organization would look like this: `organizations/123/cases/456` Projects have two unique identifiers, an ID and a number, and they look like this: `projects/abc/cases/456` `projects/123/cases/456` You can use either of them when calling the API. To learn more about project identifiers, see [AIP-2510](https://google.aip.dev/cloud/2510).
271///
272/// # Activities
273///
274/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
275/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
276///
277/// * [attachments get cases](CaseAttachmentGetCall) (none)
278/// * [attachments list cases](CaseAttachmentListCall) (none)
279/// * [comments create cases](CaseCommentCreateCall) (none)
280/// * [comments get cases](CaseCommentGetCall) (none)
281/// * [comments list cases](CaseCommentListCall) (none)
282/// * [close cases](CaseCloseCall) (response)
283/// * [create cases](CaseCreateCall) (request|response)
284/// * [escalate cases](CaseEscalateCall) (response)
285/// * [get cases](CaseGetCall) (response)
286/// * [list cases](CaseListCall) (none)
287/// * [patch cases](CasePatchCall) (request|response)
288/// * [search cases](CaseSearchCall) (none)
289/// * [show feed cases](CaseShowFeedCall) (none)
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct Case {
294    /// The issue classification applicable to this case.
295    pub classification: Option<CaseClassification>,
296    /// A user-supplied email address to send case update notifications for. This should only be used in BYOID flows, where we cannot infer the user's email address directly from their EUCs.
297    #[serde(rename = "contactEmail")]
298    pub contact_email: Option<String>,
299    /// Output only. The time this case was created.
300    #[serde(rename = "createTime")]
301    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
302    /// The user who created the case. Note: The name and email will be obfuscated if the case was created by Google Support.
303    pub creator: Option<Actor>,
304    /// A broad description of the issue.
305    pub description: Option<String>,
306    /// The short summary of the issue reported in this case.
307    #[serde(rename = "displayName")]
308    pub display_name: Option<String>,
309    /// Whether the case is currently escalated.
310    pub escalated: Option<bool>,
311    /// The language the user has requested to receive support in. This should be a BCP 47 language code (e.g., `"en"`, `"zh-CN"`, `"zh-TW"`, `"ja"`, `"ko"`). If no language or an unsupported language is specified, this field defaults to English (en). Language selection during case creation may affect your available support options. For a list of supported languages and their support working hours, see: https://cloud.google.com/support/docs/language-working-hours
312    #[serde(rename = "languageCode")]
313    pub language_code: Option<String>,
314    /// Identifier. The resource name for the case.
315    pub name: Option<String>,
316    /// The priority of this case.
317    pub priority: Option<String>,
318    /// REMOVED. The severity of this case. Use priority instead.
319    pub severity: Option<String>,
320    /// Output only. The current status of the support case.
321    pub state: Option<String>,
322    /// The email addresses to receive updates on this case.
323    #[serde(rename = "subscriberEmailAddresses")]
324    pub subscriber_email_addresses: Option<Vec<String>>,
325    /// Whether this case was created for internal API testing and should not be acted on by the support team.
326    #[serde(rename = "testCase")]
327    pub test_case: Option<bool>,
328    /// The timezone of the user who created the support case. It should be in a format IANA recognizes: https://www.iana.org/time-zones. There is no additional validation done by the API.
329    #[serde(rename = "timeZone")]
330    pub time_zone: Option<String>,
331    /// Output only. The time this case was last updated.
332    #[serde(rename = "updateTime")]
333    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
334}
335
336impl common::RequestValue for Case {}
337impl common::Resource for Case {}
338impl common::ResponseResult for Case {}
339
340/// A Case Classification represents the topic that a case is about. It’s very important to use accurate classifications, because they’re used to route your cases to specialists who can help you. A classification always has an ID that is its unique identifier. A valid ID is required when creating a case.
341///
342/// # Activities
343///
344/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
345/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
346///
347/// * [search case classifications](CaseClassificationSearchCall) (none)
348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
349#[serde_with::serde_as]
350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
351pub struct CaseClassification {
352    /// A display name for the classification. The display name is not static and can change. To uniquely and consistently identify classifications, use the `CaseClassification.id` field.
353    #[serde(rename = "displayName")]
354    pub display_name: Option<String>,
355    /// The unique ID for a classification. Must be specified for case creation. To retrieve valid classification IDs for case creation, use `caseClassifications.search`. Classification IDs returned by `caseClassifications.search` are guaranteed to be valid for at least 6 months. If a given classification is deactiveated, it will immediately stop being returned. After 6 months, `case.create` requests using the classification ID will fail.
356    pub id: Option<String>,
357    /// The full product the classification corresponds to.
358    pub product: Option<Product>,
359}
360
361impl common::Resource for CaseClassification {}
362
363/// The request message for the CloseCase endpoint.
364///
365/// # Activities
366///
367/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
368/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
369///
370/// * [close cases](CaseCloseCall) (request)
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct CloseCaseRequest {
375    _never_set: Option<bool>,
376}
377
378impl common::RequestValue for CloseCaseRequest {}
379
380/// A comment associated with a support case. Case comments are the primary way for Google Support to communicate with a user who has opened a case. When a user responds to Google Support, the user’s responses also appear as comments.
381///
382/// # Activities
383///
384/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
385/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
386///
387/// * [comments create cases](CaseCommentCreateCall) (request|response)
388/// * [comments get cases](CaseCommentGetCall) (response)
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct Comment {
393    /// The full comment body. Maximum of 12800 characters.
394    pub body: Option<String>,
395    /// Output only. The time when the comment was created.
396    #[serde(rename = "createTime")]
397    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
398    /// Output only. The user or Google Support agent who created the comment.
399    pub creator: Option<Actor>,
400    /// Output only. Identifier. The resource name of the comment.
401    pub name: Option<String>,
402    /// Output only. DEPRECATED. DO NOT USE. A duplicate of the `body` field. This field is only present for legacy reasons.
403    #[serde(rename = "plainTextBody")]
404    pub plain_text_body: Option<String>,
405}
406
407impl common::RequestValue for Comment {}
408impl common::ResponseResult for Comment {}
409
410/// # gdata.* are outside protos with mising documentation
411///
412/// This type is not used in any activity, and only used as *part* of another schema.
413///
414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
415#[serde_with::serde_as]
416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
417pub struct CompositeMedia {
418    /// # gdata.* are outside protos with mising documentation
419    #[serde(rename = "blobRef")]
420    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
421    pub blob_ref: Option<Vec<u8>>,
422    /// # gdata.* are outside protos with mising documentation
423    #[serde(rename = "blobstore2Info")]
424    pub blobstore2_info: Option<Blobstore2Info>,
425    /// # gdata.* are outside protos with mising documentation
426    #[serde(rename = "cosmoBinaryReference")]
427    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
428    pub cosmo_binary_reference: Option<Vec<u8>>,
429    /// # gdata.* are outside protos with mising documentation
430    #[serde(rename = "crc32cHash")]
431    pub crc32c_hash: Option<u32>,
432    /// # gdata.* are outside protos with mising documentation
433    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
434    pub inline: Option<Vec<u8>>,
435    /// # gdata.* are outside protos with mising documentation
436    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
437    pub length: Option<i64>,
438    /// # gdata.* are outside protos with mising documentation
439    #[serde(rename = "md5Hash")]
440    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
441    pub md5_hash: Option<Vec<u8>>,
442    /// # gdata.* are outside protos with mising documentation
443    #[serde(rename = "objectId")]
444    pub object_id: Option<ObjectId>,
445    /// # gdata.* are outside protos with mising documentation
446    pub path: Option<String>,
447    /// # gdata.* are outside protos with mising documentation
448    #[serde(rename = "referenceType")]
449    pub reference_type: Option<String>,
450    /// # gdata.* are outside protos with mising documentation
451    #[serde(rename = "sha1Hash")]
452    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
453    pub sha1_hash: Option<Vec<u8>>,
454}
455
456impl common::Part for CompositeMedia {}
457
458/// # gdata.* are outside protos with mising documentation
459///
460/// This type is not used in any activity, and only used as *part* of another schema.
461///
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct ContentTypeInfo {
466    /// # gdata.* are outside protos with mising documentation
467    #[serde(rename = "bestGuess")]
468    pub best_guess: Option<String>,
469    /// # gdata.* are outside protos with mising documentation
470    #[serde(rename = "fromBytes")]
471    pub from_bytes: Option<String>,
472    /// # gdata.* are outside protos with mising documentation
473    #[serde(rename = "fromFileName")]
474    pub from_file_name: Option<String>,
475    /// # gdata.* are outside protos with mising documentation
476    #[serde(rename = "fromHeader")]
477    pub from_header: Option<String>,
478    /// # gdata.* are outside protos with mising documentation
479    #[serde(rename = "fromUrlPath")]
480    pub from_url_path: Option<String>,
481}
482
483impl common::Part for ContentTypeInfo {}
484
485/// The request message for the CreateAttachment endpoint.
486///
487/// # Activities
488///
489/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
490/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
491///
492/// * [upload media](MediaUploadCall) (request)
493#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
494#[serde_with::serde_as]
495#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
496pub struct CreateAttachmentRequest {
497    /// Required. The attachment to be created.
498    pub attachment: Option<Attachment>,
499}
500
501impl common::RequestValue for CreateAttachmentRequest {}
502
503/// # gdata.* are outside protos with mising documentation
504///
505/// This type is not used in any activity, and only used as *part* of another schema.
506///
507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
508#[serde_with::serde_as]
509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
510pub struct DiffChecksumsResponse {
511    /// # gdata.* are outside protos with mising documentation
512    #[serde(rename = "checksumsLocation")]
513    pub checksums_location: Option<CompositeMedia>,
514    /// # gdata.* are outside protos with mising documentation
515    #[serde(rename = "chunkSizeBytes")]
516    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
517    pub chunk_size_bytes: Option<i64>,
518    /// # gdata.* are outside protos with mising documentation
519    #[serde(rename = "objectLocation")]
520    pub object_location: Option<CompositeMedia>,
521    /// # gdata.* are outside protos with mising documentation
522    #[serde(rename = "objectSizeBytes")]
523    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
524    pub object_size_bytes: Option<i64>,
525    /// # gdata.* are outside protos with mising documentation
526    #[serde(rename = "objectVersion")]
527    pub object_version: Option<String>,
528}
529
530impl common::Part for DiffChecksumsResponse {}
531
532/// # gdata.* are outside protos with mising documentation
533///
534/// This type is not used in any activity, and only used as *part* of another schema.
535///
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct DiffDownloadResponse {
540    /// # gdata.* are outside protos with mising documentation
541    #[serde(rename = "objectLocation")]
542    pub object_location: Option<CompositeMedia>,
543}
544
545impl common::Part for DiffDownloadResponse {}
546
547/// # gdata.* are outside protos with mising documentation
548///
549/// This type is not used in any activity, and only used as *part* of another schema.
550///
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct DiffUploadRequest {
555    /// # gdata.* are outside protos with mising documentation
556    #[serde(rename = "checksumsInfo")]
557    pub checksums_info: Option<CompositeMedia>,
558    /// # gdata.* are outside protos with mising documentation
559    #[serde(rename = "objectInfo")]
560    pub object_info: Option<CompositeMedia>,
561    /// # gdata.* are outside protos with mising documentation
562    #[serde(rename = "objectVersion")]
563    pub object_version: Option<String>,
564}
565
566impl common::Part for DiffUploadRequest {}
567
568/// # gdata.* are outside protos with mising documentation
569///
570/// This type is not used in any activity, and only used as *part* of another schema.
571///
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct DiffUploadResponse {
576    /// # gdata.* are outside protos with mising documentation
577    #[serde(rename = "objectVersion")]
578    pub object_version: Option<String>,
579    /// # gdata.* are outside protos with mising documentation
580    #[serde(rename = "originalObject")]
581    pub original_object: Option<CompositeMedia>,
582}
583
584impl common::Part for DiffUploadResponse {}
585
586/// # gdata.* are outside protos with mising documentation
587///
588/// This type is not used in any activity, and only used as *part* of another schema.
589///
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct DiffVersionResponse {
594    /// # gdata.* are outside protos with mising documentation
595    #[serde(rename = "objectSizeBytes")]
596    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
597    pub object_size_bytes: Option<i64>,
598    /// # gdata.* are outside protos with mising documentation
599    #[serde(rename = "objectVersion")]
600    pub object_version: Option<String>,
601}
602
603impl common::Part for DiffVersionResponse {}
604
605/// # gdata.* are outside protos with mising documentation
606///
607/// This type is not used in any activity, and only used as *part* of another schema.
608///
609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
610#[serde_with::serde_as]
611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
612pub struct DownloadParameters {
613    /// # gdata.* are outside protos with mising documentation
614    #[serde(rename = "allowGzipCompression")]
615    pub allow_gzip_compression: Option<bool>,
616    /// # gdata.* are outside protos with mising documentation
617    #[serde(rename = "ignoreRange")]
618    pub ignore_range: Option<bool>,
619}
620
621impl common::Part for DownloadParameters {}
622
623/// An email associated with a support case.
624///
625/// This type is not used in any activity, and only used as *part* of another schema.
626///
627#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
628#[serde_with::serde_as]
629#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
630pub struct EmailMessage {
631    /// Output only. The user or Google Support agent that created this email message. This is inferred from the headers on the email message.
632    pub actor: Option<Actor>,
633    /// Output only. The full email message body. A best-effort attempt is made to remove extraneous reply threads.
634    #[serde(rename = "bodyContent")]
635    pub body_content: Option<TextContent>,
636    /// Output only. Email addresses CCed on the email.
637    #[serde(rename = "ccEmailAddresses")]
638    pub cc_email_addresses: Option<Vec<String>>,
639    /// Output only. Time when this email message object was created.
640    #[serde(rename = "createTime")]
641    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
642    /// Identifier. Resource name for the email message.
643    pub name: Option<String>,
644    /// Output only. Email addresses the email was sent to.
645    #[serde(rename = "recipientEmailAddresses")]
646    pub recipient_email_addresses: Option<Vec<String>>,
647    /// Output only. Subject of the email.
648    pub subject: Option<String>,
649}
650
651impl common::Part for EmailMessage {}
652
653/// The request message for the EscalateCase endpoint.
654///
655/// # Activities
656///
657/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
658/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
659///
660/// * [escalate cases](CaseEscalateCall) (request)
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct EscalateCaseRequest {
665    /// The escalation information to be sent with the escalation request.
666    pub escalation: Option<Escalation>,
667}
668
669impl common::RequestValue for EscalateCaseRequest {}
670
671/// An escalation of a support case.
672///
673/// This type is not used in any activity, and only used as *part* of another schema.
674///
675#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
676#[serde_with::serde_as]
677#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
678pub struct Escalation {
679    /// Required. A free text description to accompany the `reason` field above. Provides additional context on why the case is being escalated.
680    pub justification: Option<String>,
681    /// Required. The reason why the Case is being escalated.
682    pub reason: Option<String>,
683}
684
685impl common::Part for Escalation {}
686
687/// A feed item associated with a support case.
688///
689/// This type is not used in any activity, and only used as *part* of another schema.
690///
691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
692#[serde_with::serde_as]
693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
694pub struct FeedItem {
695    /// Output only. An attachment attached to the case.
696    pub attachment: Option<Attachment>,
697    /// Output only. A comment added to the case.
698    pub comment: Option<Comment>,
699    /// Output only. A deleted attachment that used to be associated with the support case.
700    #[serde(rename = "deletedAttachment")]
701    pub deleted_attachment: Option<Attachment>,
702    /// Output only. An email message received in reply to the case.
703    #[serde(rename = "emailMessage")]
704    pub email_message: Option<EmailMessage>,
705    /// Output only. Time corresponding to the event of this item.
706    #[serde(rename = "eventTime")]
707    pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
708}
709
710impl common::Part for FeedItem {}
711
712/// The response message for the ListAttachments endpoint.
713///
714/// # Activities
715///
716/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
717/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
718///
719/// * [attachments list cases](CaseAttachmentListCall) (response)
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct ListAttachmentsResponse {
724    /// The list of attachments associated with a case.
725    pub attachments: Option<Vec<Attachment>>,
726    /// A token to retrieve the next page of results. Set this in the `page_token` field of subsequent `cases.attachments.list` requests. If unspecified, there are no more results to retrieve.
727    #[serde(rename = "nextPageToken")]
728    pub next_page_token: Option<String>,
729}
730
731impl common::ResponseResult for ListAttachmentsResponse {}
732
733/// The response message for the ListCases endpoint.
734///
735/// # Activities
736///
737/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
738/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
739///
740/// * [list cases](CaseListCall) (response)
741#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
742#[serde_with::serde_as]
743#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
744pub struct ListCasesResponse {
745    /// The list of cases associated with the parent after any filters have been applied.
746    pub cases: Option<Vec<Case>>,
747    /// A token to retrieve the next page of results. Set this in the `page_token` field of subsequent `cases.list` requests. If unspecified, there are no more results to retrieve.
748    #[serde(rename = "nextPageToken")]
749    pub next_page_token: Option<String>,
750}
751
752impl common::ResponseResult for ListCasesResponse {}
753
754/// The response message for the ListComments endpoint.
755///
756/// # Activities
757///
758/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
759/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
760///
761/// * [comments list cases](CaseCommentListCall) (response)
762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
763#[serde_with::serde_as]
764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
765pub struct ListCommentsResponse {
766    /// List of the comments associated with the case.
767    pub comments: Option<Vec<Comment>>,
768    /// A token to retrieve the next page of results. Set this in the `page_token` field of subsequent `cases.comments.list` requests. If unspecified, there are no more results to retrieve.
769    #[serde(rename = "nextPageToken")]
770    pub next_page_token: Option<String>,
771}
772
773impl common::ResponseResult for ListCommentsResponse {}
774
775/// # gdata.\* are outside protos with mising documentation
776///
777/// # Activities
778///
779/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
780/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
781///
782/// * [download media](MediaDownloadCall) (response)
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct Media {
787    /// # gdata.* are outside protos with mising documentation
788    pub algorithm: Option<String>,
789    /// # gdata.* are outside protos with mising documentation
790    #[serde(rename = "bigstoreObjectRef")]
791    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
792    pub bigstore_object_ref: Option<Vec<u8>>,
793    /// # gdata.* are outside protos with mising documentation
794    #[serde(rename = "blobRef")]
795    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
796    pub blob_ref: Option<Vec<u8>>,
797    /// # gdata.* are outside protos with mising documentation
798    #[serde(rename = "blobstore2Info")]
799    pub blobstore2_info: Option<Blobstore2Info>,
800    /// # gdata.* are outside protos with mising documentation
801    #[serde(rename = "compositeMedia")]
802    pub composite_media: Option<Vec<CompositeMedia>>,
803    /// # gdata.* are outside protos with mising documentation
804    #[serde(rename = "contentType")]
805    pub content_type: Option<String>,
806    /// # gdata.* are outside protos with mising documentation
807    #[serde(rename = "contentTypeInfo")]
808    pub content_type_info: Option<ContentTypeInfo>,
809    /// # gdata.* are outside protos with mising documentation
810    #[serde(rename = "cosmoBinaryReference")]
811    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
812    pub cosmo_binary_reference: Option<Vec<u8>>,
813    /// # gdata.* are outside protos with mising documentation
814    #[serde(rename = "crc32cHash")]
815    pub crc32c_hash: Option<u32>,
816    /// # gdata.* are outside protos with mising documentation
817    #[serde(rename = "diffChecksumsResponse")]
818    pub diff_checksums_response: Option<DiffChecksumsResponse>,
819    /// # gdata.* are outside protos with mising documentation
820    #[serde(rename = "diffDownloadResponse")]
821    pub diff_download_response: Option<DiffDownloadResponse>,
822    /// # gdata.* are outside protos with mising documentation
823    #[serde(rename = "diffUploadRequest")]
824    pub diff_upload_request: Option<DiffUploadRequest>,
825    /// # gdata.* are outside protos with mising documentation
826    #[serde(rename = "diffUploadResponse")]
827    pub diff_upload_response: Option<DiffUploadResponse>,
828    /// # gdata.* are outside protos with mising documentation
829    #[serde(rename = "diffVersionResponse")]
830    pub diff_version_response: Option<DiffVersionResponse>,
831    /// # gdata.* are outside protos with mising documentation
832    #[serde(rename = "downloadParameters")]
833    pub download_parameters: Option<DownloadParameters>,
834    /// # gdata.* are outside protos with mising documentation
835    pub filename: Option<String>,
836    /// # gdata.* are outside protos with mising documentation
837    pub hash: Option<String>,
838    /// # gdata.* are outside protos with mising documentation
839    #[serde(rename = "hashVerified")]
840    pub hash_verified: Option<bool>,
841    /// # gdata.* are outside protos with mising documentation
842    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
843    pub inline: Option<Vec<u8>>,
844    /// # gdata.* are outside protos with mising documentation
845    #[serde(rename = "isPotentialRetry")]
846    pub is_potential_retry: Option<bool>,
847    /// # gdata.* are outside protos with mising documentation
848    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
849    pub length: Option<i64>,
850    /// # gdata.* are outside protos with mising documentation
851    #[serde(rename = "md5Hash")]
852    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
853    pub md5_hash: Option<Vec<u8>>,
854    /// # gdata.* are outside protos with mising documentation
855    #[serde(rename = "mediaId")]
856    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
857    pub media_id: Option<Vec<u8>>,
858    /// # gdata.* are outside protos with mising documentation
859    #[serde(rename = "objectId")]
860    pub object_id: Option<ObjectId>,
861    /// # gdata.* are outside protos with mising documentation
862    pub path: Option<String>,
863    /// # gdata.* are outside protos with mising documentation
864    #[serde(rename = "referenceType")]
865    pub reference_type: Option<String>,
866    /// # gdata.* are outside protos with mising documentation
867    #[serde(rename = "sha1Hash")]
868    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
869    pub sha1_hash: Option<Vec<u8>>,
870    /// # gdata.* are outside protos with mising documentation
871    #[serde(rename = "sha256Hash")]
872    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
873    pub sha256_hash: Option<Vec<u8>>,
874    /// # gdata.* are outside protos with mising documentation
875    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
876    pub timestamp: Option<u64>,
877    /// # gdata.* are outside protos with mising documentation
878    pub token: Option<String>,
879}
880
881impl common::ResponseResult for Media {}
882
883/// # gdata.* are outside protos with mising documentation
884///
885/// This type is not used in any activity, and only used as *part* of another schema.
886///
887#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
888#[serde_with::serde_as]
889#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
890pub struct ObjectId {
891    /// # gdata.* are outside protos with mising documentation
892    #[serde(rename = "bucketName")]
893    pub bucket_name: Option<String>,
894    /// # gdata.* are outside protos with mising documentation
895    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
896    pub generation: Option<i64>,
897    /// # gdata.* are outside protos with mising documentation
898    #[serde(rename = "objectName")]
899    pub object_name: Option<String>,
900}
901
902impl common::Part for ObjectId {}
903
904/// The product a case may be associated with.
905///
906/// This type is not used in any activity, and only used as *part* of another schema.
907///
908#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
909#[serde_with::serde_as]
910#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
911pub struct Product {
912    /// The product line of the Product.
913    #[serde(rename = "productLine")]
914    pub product_line: Option<String>,
915}
916
917impl common::Part for Product {}
918
919/// The response message for SearchCaseClassifications endpoint.
920///
921/// # Activities
922///
923/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
924/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
925///
926/// * [search case classifications](CaseClassificationSearchCall) (response)
927#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
928#[serde_with::serde_as]
929#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
930pub struct SearchCaseClassificationsResponse {
931    /// The classifications retrieved.
932    #[serde(rename = "caseClassifications")]
933    pub case_classifications: Option<Vec<CaseClassification>>,
934    /// A token to retrieve the next page of results. Set this in the `page_token` field of subsequent `caseClassifications.list` requests. If unspecified, there are no more results to retrieve.
935    #[serde(rename = "nextPageToken")]
936    pub next_page_token: Option<String>,
937}
938
939impl common::ResponseResult for SearchCaseClassificationsResponse {}
940
941/// The response message for the SearchCases endpoint.
942///
943/// # Activities
944///
945/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
946/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
947///
948/// * [search cases](CaseSearchCall) (response)
949#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
950#[serde_with::serde_as]
951#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
952pub struct SearchCasesResponse {
953    /// The list of cases associated with the parent after any filters have been applied.
954    pub cases: Option<Vec<Case>>,
955    /// A token to retrieve the next page of results. Set this in the `page_token` field of subsequent `cases.search` requests. If unspecified, there are no more results to retrieve.
956    #[serde(rename = "nextPageToken")]
957    pub next_page_token: Option<String>,
958}
959
960impl common::ResponseResult for SearchCasesResponse {}
961
962/// The response message for the ShowFeed endpoint.
963///
964/// # Activities
965///
966/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
967/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
968///
969/// * [show feed cases](CaseShowFeedCall) (response)
970#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
971#[serde_with::serde_as]
972#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
973pub struct ShowFeedResponse {
974    /// The list of feed items associated with the given Case.
975    #[serde(rename = "feedItems")]
976    pub feed_items: Option<Vec<FeedItem>>,
977    /// A token to retrieve the next page of results. This should be set in the `page_token` field of subsequent `ShowFeedRequests`. If unspecified, there are no more results to retrieve.
978    #[serde(rename = "nextPageToken")]
979    pub next_page_token: Option<String>,
980}
981
982impl common::ResponseResult for ShowFeedResponse {}
983
984/// Stores text attached to a support object.
985///
986/// This type is not used in any activity, and only used as *part* of another schema.
987///
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct TextContent {
992    /// Content in this field should be rendered and interpreted as-is.
993    #[serde(rename = "plainText")]
994    pub plain_text: Option<String>,
995}
996
997impl common::Part for TextContent {}
998
999// ###################
1000// MethodBuilders ###
1001// #################
1002
1003/// A builder providing access to all methods supported on *caseClassification* resources.
1004/// It is not used directly, but through the [`CloudSupport`] hub.
1005///
1006/// # Example
1007///
1008/// Instantiate a resource builder
1009///
1010/// ```test_harness,no_run
1011/// extern crate hyper;
1012/// extern crate hyper_rustls;
1013/// extern crate google_cloudsupport2_beta as cloudsupport2_beta;
1014///
1015/// # async fn dox() {
1016/// use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1017///
1018/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1019/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1020///     .with_native_roots()
1021///     .unwrap()
1022///     .https_only()
1023///     .enable_http2()
1024///     .build();
1025///
1026/// let executor = hyper_util::rt::TokioExecutor::new();
1027/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1028///     secret,
1029///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1030///     yup_oauth2::client::CustomHyperClientBuilder::from(
1031///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1032///     ),
1033/// ).build().await.unwrap();
1034///
1035/// let client = hyper_util::client::legacy::Client::builder(
1036///     hyper_util::rt::TokioExecutor::new()
1037/// )
1038/// .build(
1039///     hyper_rustls::HttpsConnectorBuilder::new()
1040///         .with_native_roots()
1041///         .unwrap()
1042///         .https_or_http()
1043///         .enable_http2()
1044///         .build()
1045/// );
1046/// let mut hub = CloudSupport::new(client, auth);
1047/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1048/// // like `search(...)`
1049/// // to build up your call.
1050/// let rb = hub.case_classifications();
1051/// # }
1052/// ```
1053pub struct CaseClassificationMethods<'a, C>
1054where
1055    C: 'a,
1056{
1057    hub: &'a CloudSupport<C>,
1058}
1059
1060impl<'a, C> common::MethodsBuilder for CaseClassificationMethods<'a, C> {}
1061
1062impl<'a, C> CaseClassificationMethods<'a, C> {
1063    /// Create a builder to help you perform the following task:
1064    ///
1065    /// Retrieve valid classifications to use when creating a support case. Classifications are hierarchical. Each classification is a string containing all levels of the hierarchy separated by `" > "`. For example, `"Technical Issue > Compute > Compute Engine"`. Classification IDs returned by this endpoint are valid for at least six months. When a classification is deactivated, this endpoint immediately stops returning it. After six months, `case.create` requests using the classification will fail. EXAMPLES: cURL: ```shell curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ 'https://cloudsupport.googleapis.com/v2/caseClassifications:search?query=display_name:"*Compute%20Engine*"' ``` Python: ```python import googleapiclient.discovery supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version="v2", discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=v2", ) request = supportApiService.caseClassifications().search( query='display_name:"*Compute Engine*"' ) print(request.execute()) ```
1066    pub fn search(&self) -> CaseClassificationSearchCall<'a, C> {
1067        CaseClassificationSearchCall {
1068            hub: self.hub,
1069            _query: Default::default(),
1070            _product_product_line: Default::default(),
1071            _page_token: Default::default(),
1072            _page_size: Default::default(),
1073            _delegate: Default::default(),
1074            _additional_params: Default::default(),
1075            _scopes: Default::default(),
1076        }
1077    }
1078}
1079
1080/// A builder providing access to all methods supported on *case* resources.
1081/// It is not used directly, but through the [`CloudSupport`] hub.
1082///
1083/// # Example
1084///
1085/// Instantiate a resource builder
1086///
1087/// ```test_harness,no_run
1088/// extern crate hyper;
1089/// extern crate hyper_rustls;
1090/// extern crate google_cloudsupport2_beta as cloudsupport2_beta;
1091///
1092/// # async fn dox() {
1093/// use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1094///
1095/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1096/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1097///     .with_native_roots()
1098///     .unwrap()
1099///     .https_only()
1100///     .enable_http2()
1101///     .build();
1102///
1103/// let executor = hyper_util::rt::TokioExecutor::new();
1104/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1105///     secret,
1106///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1107///     yup_oauth2::client::CustomHyperClientBuilder::from(
1108///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1109///     ),
1110/// ).build().await.unwrap();
1111///
1112/// let client = hyper_util::client::legacy::Client::builder(
1113///     hyper_util::rt::TokioExecutor::new()
1114/// )
1115/// .build(
1116///     hyper_rustls::HttpsConnectorBuilder::new()
1117///         .with_native_roots()
1118///         .unwrap()
1119///         .https_or_http()
1120///         .enable_http2()
1121///         .build()
1122/// );
1123/// let mut hub = CloudSupport::new(client, auth);
1124/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1125/// // like `attachments_get(...)`, `attachments_list(...)`, `close(...)`, `comments_create(...)`, `comments_get(...)`, `comments_list(...)`, `create(...)`, `escalate(...)`, `get(...)`, `list(...)`, `patch(...)`, `search(...)` and `show_feed(...)`
1126/// // to build up your call.
1127/// let rb = hub.cases();
1128/// # }
1129/// ```
1130pub struct CaseMethods<'a, C>
1131where
1132    C: 'a,
1133{
1134    hub: &'a CloudSupport<C>,
1135}
1136
1137impl<'a, C> common::MethodsBuilder for CaseMethods<'a, C> {}
1138
1139impl<'a, C> CaseMethods<'a, C> {
1140    /// Create a builder to help you perform the following task:
1141    ///
1142    /// Retrieve an attachment associated with a support case. EXAMPLES: cURL: ```shell attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$attachment" ``` Python: ```python import googleapiclient.discovery api_version = "v2beta" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .attachments() .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") ) print(request.execute()) ```
1143    ///
1144    /// # Arguments
1145    ///
1146    /// * `name` - Required. The name of the attachment to get.
1147    pub fn attachments_get(&self, name: &str) -> CaseAttachmentGetCall<'a, C> {
1148        CaseAttachmentGetCall {
1149            hub: self.hub,
1150            _name: name.to_string(),
1151            _delegate: Default::default(),
1152            _additional_params: Default::default(),
1153            _scopes: Default::default(),
1154        }
1155    }
1156
1157    /// Create a builder to help you perform the following task:
1158    ///
1159    /// List all the attachments associated with a support case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/23598314" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case/attachments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .attachments() .list(parent="projects/some-project/cases/43595344") ) print(request.execute()) ```
1160    ///
1161    /// # Arguments
1162    ///
1163    /// * `parent` - Required. The name of the case for which attachments should be listed.
1164    pub fn attachments_list(&self, parent: &str) -> CaseAttachmentListCall<'a, C> {
1165        CaseAttachmentListCall {
1166            hub: self.hub,
1167            _parent: parent.to_string(),
1168            _page_token: Default::default(),
1169            _page_size: Default::default(),
1170            _delegate: Default::default(),
1171            _additional_params: Default::default(),
1172            _scopes: Default::default(),
1173        }
1174    }
1175
1176    /// Create a builder to help you perform the following task:
1177    ///
1178    /// Add a new comment to a case. The comment must have the following fields set: `body`. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43591344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header 'Content-Type: application/json' \ --data '{ "body": "This is a test comment." }' \ "https://cloudsupport.googleapis.com/v2/$case/comments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .comments() .create( parent="projects/some-project/cases/43595344", body={"body": "This is a test comment."}, ) ) print(request.execute()) ```
1179    ///
1180    /// # Arguments
1181    ///
1182    /// * `request` - No description provided.
1183    /// * `parent` - Required. The name of the case to which the comment should be added.
1184    pub fn comments_create(&self, request: Comment, parent: &str) -> CaseCommentCreateCall<'a, C> {
1185        CaseCommentCreateCall {
1186            hub: self.hub,
1187            _request: request,
1188            _parent: parent.to_string(),
1189            _delegate: Default::default(),
1190            _additional_params: Default::default(),
1191            _scopes: Default::default(),
1192        }
1193    }
1194
1195    /// Create a builder to help you perform the following task:
1196    ///
1197    /// Retrieve a comment. EXAMPLES: cURL: ```shell comment="projects/some-project/cases/43595344/comments/234567890" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$comment" ``` Python: ```python import googleapiclient.discovery api_version = "v2beta" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().comments().get( name="projects/some-project/cases/43595344/comments/234567890", ) print(request.execute()) ```
1198    ///
1199    /// # Arguments
1200    ///
1201    /// * `name` - Required. The name of the comment to retrieve.
1202    pub fn comments_get(&self, name: &str) -> CaseCommentGetCall<'a, C> {
1203        CaseCommentGetCall {
1204            hub: self.hub,
1205            _name: name.to_string(),
1206            _delegate: Default::default(),
1207            _additional_params: Default::default(),
1208            _scopes: Default::default(),
1209        }
1210    }
1211
1212    /// Create a builder to help you perform the following task:
1213    ///
1214    /// List all the comments associated with a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case/comments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .comments() .list(parent="projects/some-project/cases/43595344") ) print(request.execute()) ```
1215    ///
1216    /// # Arguments
1217    ///
1218    /// * `parent` - Required. The name of the case for which to list comments.
1219    pub fn comments_list(&self, parent: &str) -> CaseCommentListCall<'a, C> {
1220        CaseCommentListCall {
1221            hub: self.hub,
1222            _parent: parent.to_string(),
1223            _page_token: Default::default(),
1224            _page_size: Default::default(),
1225            _delegate: Default::default(),
1226            _additional_params: Default::default(),
1227            _scopes: Default::default(),
1228        }
1229    }
1230
1231    /// Create a builder to help you perform the following task:
1232    ///
1233    /// Close a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case:close" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().close( name="projects/some-project/cases/43595344" ) print(request.execute()) ```
1234    ///
1235    /// # Arguments
1236    ///
1237    /// * `request` - No description provided.
1238    /// * `name` - Required. The name of the case to close.
1239    pub fn close(&self, request: CloseCaseRequest, name: &str) -> CaseCloseCall<'a, C> {
1240        CaseCloseCall {
1241            hub: self.hub,
1242            _request: request,
1243            _name: name.to_string(),
1244            _delegate: Default::default(),
1245            _additional_params: Default::default(),
1246            _scopes: Default::default(),
1247        }
1248    }
1249
1250    /// Create a builder to help you perform the following task:
1251    ///
1252    /// Create a new case and associate it with a parent. It must have the following fields set: `display_name`, `description`, `classification`, and `priority`. If you're just testing the API and don't want to route your case to an agent, set `testCase=true`. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header 'Content-Type: application/json' \ --data '{ "display_name": "Test case created by me.", "description": "a random test case, feel free to close", "classification": { "id": "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" }, "time_zone": "-07:00", "subscriber_email_addresses": [ "foo@domain.com", "bar@domain.com" ], "testCase": true, "priority": "P3" }' \ "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().create( parent="projects/some-project", body={ "displayName": "A Test Case", "description": "This is a test case.", "testCase": True, "priority": "P2", "classification": { "id": "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" }, }, ) print(request.execute()) ```
1253    ///
1254    /// # Arguments
1255    ///
1256    /// * `request` - No description provided.
1257    /// * `parent` - Required. The name of the parent under which the case should be created.
1258    pub fn create(&self, request: Case, parent: &str) -> CaseCreateCall<'a, C> {
1259        CaseCreateCall {
1260            hub: self.hub,
1261            _request: request,
1262            _parent: parent.to_string(),
1263            _delegate: Default::default(),
1264            _additional_params: Default::default(),
1265            _scopes: Default::default(),
1266        }
1267    }
1268
1269    /// Create a builder to help you perform the following task:
1270    ///
1271    /// Escalate a case, starting the Google Cloud Support escalation management process. This operation is only available for some support services. Go to https://cloud.google.com/support and look for 'Technical support escalations' in the feature list to find out which ones let you do that. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header "Content-Type: application/json" \ --data '{ "escalation": { "reason": "BUSINESS_IMPACT", "justification": "This is a test escalation." } }' \ "https://cloudsupport.googleapis.com/v2/$case:escalate" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().escalate( name="projects/some-project/cases/43595344", body={ "escalation": { "reason": "BUSINESS_IMPACT", "justification": "This is a test escalation.", }, }, ) print(request.execute()) ```
1272    ///
1273    /// # Arguments
1274    ///
1275    /// * `request` - No description provided.
1276    /// * `name` - Required. The name of the case to be escalated.
1277    pub fn escalate(&self, request: EscalateCaseRequest, name: &str) -> CaseEscalateCall<'a, C> {
1278        CaseEscalateCall {
1279            hub: self.hub,
1280            _request: request,
1281            _name: name.to_string(),
1282            _delegate: Default::default(),
1283            _additional_params: Default::default(),
1284            _scopes: Default::default(),
1285        }
1286    }
1287
1288    /// Create a builder to help you perform the following task:
1289    ///
1290    /// Retrieve a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/16033687" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().get( name="projects/some-project/cases/43595344", ) print(request.execute()) ```
1291    ///
1292    /// # Arguments
1293    ///
1294    /// * `name` - Required. The full name of a case to be retrieved.
1295    pub fn get(&self, name: &str) -> CaseGetCall<'a, C> {
1296        CaseGetCall {
1297            hub: self.hub,
1298            _name: name.to_string(),
1299            _delegate: Default::default(),
1300            _additional_params: Default::default(),
1301            _scopes: Default::default(),
1302        }
1303    }
1304
1305    /// Create a builder to help you perform the following task:
1306    ///
1307    /// Retrieve all cases under a parent, but not its children. For example, listing cases under an organization only returns the cases that are directly parented by that organization. To retrieve cases under an organization and its projects, use `cases.search`. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().list(parent="projects/some-project") print(request.execute()) ```
1308    ///
1309    /// # Arguments
1310    ///
1311    /// * `parent` - Required. The name of a parent to list cases under.
1312    pub fn list(&self, parent: &str) -> CaseListCall<'a, C> {
1313        CaseListCall {
1314            hub: self.hub,
1315            _parent: parent.to_string(),
1316            _product_line: Default::default(),
1317            _page_token: Default::default(),
1318            _page_size: Default::default(),
1319            _filter: Default::default(),
1320            _delegate: Default::default(),
1321            _additional_params: Default::default(),
1322            _scopes: Default::default(),
1323        }
1324    }
1325
1326    /// Create a builder to help you perform the following task:
1327    ///
1328    /// Update a case. Only some fields can be updated. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request PATCH \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header "Content-Type: application/json" \ --data '{ "priority": "P1" }' \ "https://cloudsupport.googleapis.com/v2/$case?updateMask=priority" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().patch( name="projects/some-project/cases/43112854", body={ "displayName": "This is Now a New Title", "priority": "P2", }, ) print(request.execute()) ```
1329    ///
1330    /// # Arguments
1331    ///
1332    /// * `request` - No description provided.
1333    /// * `name` - Identifier. The resource name for the case.
1334    pub fn patch(&self, request: Case, name: &str) -> CasePatchCall<'a, C> {
1335        CasePatchCall {
1336            hub: self.hub,
1337            _request: request,
1338            _name: name.to_string(),
1339            _update_mask: Default::default(),
1340            _delegate: Default::default(),
1341            _additional_params: Default::default(),
1342            _scopes: Default::default(),
1343        }
1344    }
1345
1346    /// Create a builder to help you perform the following task:
1347    ///
1348    /// Search for cases using a query. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$parent/cases:search" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().search( parent="projects/some-project", query="state=OPEN" ) print(request.execute()) ```
1349    pub fn search(&self) -> CaseSearchCall<'a, C> {
1350        CaseSearchCall {
1351            hub: self.hub,
1352            _query: Default::default(),
1353            _parent: Default::default(),
1354            _page_token: Default::default(),
1355            _page_size: Default::default(),
1356            _delegate: Default::default(),
1357            _additional_params: Default::default(),
1358            _scopes: Default::default(),
1359        }
1360    }
1361
1362    /// Create a builder to help you perform the following task:
1363    ///
1364    /// Show items in the feed of this case, including case emails, attachments, and comments.
1365    ///
1366    /// # Arguments
1367    ///
1368    /// * `parent` - Required. The resource name of the case for which feed items should be listed.
1369    pub fn show_feed(&self, parent: &str) -> CaseShowFeedCall<'a, C> {
1370        CaseShowFeedCall {
1371            hub: self.hub,
1372            _parent: parent.to_string(),
1373            _page_token: Default::default(),
1374            _page_size: Default::default(),
1375            _order_by: Default::default(),
1376            _delegate: Default::default(),
1377            _additional_params: Default::default(),
1378            _scopes: Default::default(),
1379        }
1380    }
1381}
1382
1383/// A builder providing access to all methods supported on *media* resources.
1384/// It is not used directly, but through the [`CloudSupport`] hub.
1385///
1386/// # Example
1387///
1388/// Instantiate a resource builder
1389///
1390/// ```test_harness,no_run
1391/// extern crate hyper;
1392/// extern crate hyper_rustls;
1393/// extern crate google_cloudsupport2_beta as cloudsupport2_beta;
1394///
1395/// # async fn dox() {
1396/// use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1397///
1398/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1399/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1400///     .with_native_roots()
1401///     .unwrap()
1402///     .https_only()
1403///     .enable_http2()
1404///     .build();
1405///
1406/// let executor = hyper_util::rt::TokioExecutor::new();
1407/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1408///     secret,
1409///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1410///     yup_oauth2::client::CustomHyperClientBuilder::from(
1411///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1412///     ),
1413/// ).build().await.unwrap();
1414///
1415/// let client = hyper_util::client::legacy::Client::builder(
1416///     hyper_util::rt::TokioExecutor::new()
1417/// )
1418/// .build(
1419///     hyper_rustls::HttpsConnectorBuilder::new()
1420///         .with_native_roots()
1421///         .unwrap()
1422///         .https_or_http()
1423///         .enable_http2()
1424///         .build()
1425/// );
1426/// let mut hub = CloudSupport::new(client, auth);
1427/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1428/// // like `download(...)` and `upload(...)`
1429/// // to build up your call.
1430/// let rb = hub.media();
1431/// # }
1432/// ```
1433pub struct MediaMethods<'a, C>
1434where
1435    C: 'a,
1436{
1437    hub: &'a CloudSupport<C>,
1438}
1439
1440impl<'a, C> common::MethodsBuilder for MediaMethods<'a, C> {}
1441
1442impl<'a, C> MediaMethods<'a, C> {
1443    /// Create a builder to help you perform the following task:
1444    ///
1445    /// Download a file attached to a case. When this endpoint is called, no "response body" will be returned. Instead, the attachment's blob will be returned. Note: HTTP requests must append "?alt=media" to the URL. EXAMPLES: cURL: ```shell name="projects/some-project/cases/43594844/attachments/0674M00000WijAnZAJ" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$name:download?alt=media" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.media().download( name="projects/some-project/cases/43595344/attachments/0684M00000Pw6pHQAR" ) request.uri = request.uri.split("?")[0] + "?alt=media" print(request.execute()) ```
1446    ///
1447    /// # Arguments
1448    ///
1449    /// * `name` - The name of the file attachment to download.
1450    pub fn download(&self, name: &str) -> MediaDownloadCall<'a, C> {
1451        MediaDownloadCall {
1452            hub: self.hub,
1453            _name: name.to_string(),
1454            _delegate: Default::default(),
1455            _additional_params: Default::default(),
1456            _scopes: Default::default(),
1457        }
1458    }
1459
1460    /// Create a builder to help you perform the following task:
1461    ///
1462    /// Create a file attachment on a case or Cloud resource. The attachment must have the following fields set: `filename`. EXAMPLES: cURL: ```shell echo "This text is in a file I'm uploading using CSAPI." \ > "./example_file.txt" case="projects/some-project/cases/43594844" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --data-binary @"./example_file.txt" \ "https://cloudsupport.googleapis.com/upload/v2beta/$case/attachments?attachment.filename=uploaded_via_curl.txt" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) file_path = "./example_file.txt" with open(file_path, "w") as file: file.write( "This text is inside a file I'm going to upload using the Cloud Support API.", ) request = supportApiService.media().upload( parent="projects/some-project/cases/43595344", media_body=file_path ) request.uri = request.uri.split("?")[0] + "?attachment.filename=uploaded_via_python.txt" print(request.execute()) ```
1463    ///
1464    /// # Arguments
1465    ///
1466    /// * `request` - No description provided.
1467    /// * `parent` - Required. The name of the case or Cloud resource to which the attachment should be attached.
1468    pub fn upload(&self, request: CreateAttachmentRequest, parent: &str) -> MediaUploadCall<'a, C> {
1469        MediaUploadCall {
1470            hub: self.hub,
1471            _request: request,
1472            _parent: parent.to_string(),
1473            _delegate: Default::default(),
1474            _additional_params: Default::default(),
1475            _scopes: Default::default(),
1476        }
1477    }
1478}
1479
1480// ###################
1481// CallBuilders   ###
1482// #################
1483
1484/// Retrieve valid classifications to use when creating a support case. Classifications are hierarchical. Each classification is a string containing all levels of the hierarchy separated by `" > "`. For example, `"Technical Issue > Compute > Compute Engine"`. Classification IDs returned by this endpoint are valid for at least six months. When a classification is deactivated, this endpoint immediately stops returning it. After six months, `case.create` requests using the classification will fail. EXAMPLES: cURL: ```shell curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ 'https://cloudsupport.googleapis.com/v2/caseClassifications:search?query=display_name:"*Compute%20Engine*"' ``` Python: ```python import googleapiclient.discovery supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version="v2", discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=v2", ) request = supportApiService.caseClassifications().search( query='display_name:"*Compute Engine*"' ) print(request.execute()) ```
1485///
1486/// A builder for the *search* method supported by a *caseClassification* resource.
1487/// It is not used directly, but through a [`CaseClassificationMethods`] instance.
1488///
1489/// # Example
1490///
1491/// Instantiate a resource method builder
1492///
1493/// ```test_harness,no_run
1494/// # extern crate hyper;
1495/// # extern crate hyper_rustls;
1496/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
1497/// # async fn dox() {
1498/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1499///
1500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1502/// #     .with_native_roots()
1503/// #     .unwrap()
1504/// #     .https_only()
1505/// #     .enable_http2()
1506/// #     .build();
1507///
1508/// # let executor = hyper_util::rt::TokioExecutor::new();
1509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1510/// #     secret,
1511/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1512/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1513/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1514/// #     ),
1515/// # ).build().await.unwrap();
1516///
1517/// # let client = hyper_util::client::legacy::Client::builder(
1518/// #     hyper_util::rt::TokioExecutor::new()
1519/// # )
1520/// # .build(
1521/// #     hyper_rustls::HttpsConnectorBuilder::new()
1522/// #         .with_native_roots()
1523/// #         .unwrap()
1524/// #         .https_or_http()
1525/// #         .enable_http2()
1526/// #         .build()
1527/// # );
1528/// # let mut hub = CloudSupport::new(client, auth);
1529/// // You can configure optional parameters by calling the respective setters at will, and
1530/// // execute the final call using `doit()`.
1531/// // Values shown here are possibly random and not representative !
1532/// let result = hub.case_classifications().search()
1533///              .query("gubergren")
1534///              .product_product_line("eos")
1535///              .page_token("dolor")
1536///              .page_size(-17)
1537///              .doit().await;
1538/// # }
1539/// ```
1540pub struct CaseClassificationSearchCall<'a, C>
1541where
1542    C: 'a,
1543{
1544    hub: &'a CloudSupport<C>,
1545    _query: Option<String>,
1546    _product_product_line: Option<String>,
1547    _page_token: Option<String>,
1548    _page_size: Option<i32>,
1549    _delegate: Option<&'a mut dyn common::Delegate>,
1550    _additional_params: HashMap<String, String>,
1551    _scopes: BTreeSet<String>,
1552}
1553
1554impl<'a, C> common::CallBuilder for CaseClassificationSearchCall<'a, C> {}
1555
1556impl<'a, C> CaseClassificationSearchCall<'a, C>
1557where
1558    C: common::Connector,
1559{
1560    /// Perform the operation you have build so far.
1561    pub async fn doit(
1562        mut self,
1563    ) -> common::Result<(common::Response, SearchCaseClassificationsResponse)> {
1564        use std::borrow::Cow;
1565        use std::io::{Read, Seek};
1566
1567        use common::{url::Params, ToParts};
1568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1569
1570        let mut dd = common::DefaultDelegate;
1571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1572        dlg.begin(common::MethodInfo {
1573            id: "cloudsupport.caseClassifications.search",
1574            http_method: hyper::Method::GET,
1575        });
1576
1577        for &field in [
1578            "alt",
1579            "query",
1580            "product.productLine",
1581            "pageToken",
1582            "pageSize",
1583        ]
1584        .iter()
1585        {
1586            if self._additional_params.contains_key(field) {
1587                dlg.finished(false);
1588                return Err(common::Error::FieldClash(field));
1589            }
1590        }
1591
1592        let mut params = Params::with_capacity(6 + self._additional_params.len());
1593        if let Some(value) = self._query.as_ref() {
1594            params.push("query", value);
1595        }
1596        if let Some(value) = self._product_product_line.as_ref() {
1597            params.push("product.productLine", value);
1598        }
1599        if let Some(value) = self._page_token.as_ref() {
1600            params.push("pageToken", value);
1601        }
1602        if let Some(value) = self._page_size.as_ref() {
1603            params.push("pageSize", value.to_string());
1604        }
1605
1606        params.extend(self._additional_params.iter());
1607
1608        params.push("alt", "json");
1609        let mut url = self.hub._base_url.clone() + "v2beta/caseClassifications:search";
1610        if self._scopes.is_empty() {
1611            self._scopes
1612                .insert(Scope::CloudPlatform.as_ref().to_string());
1613        }
1614
1615        let url = params.parse_with_url(&url);
1616
1617        loop {
1618            let token = match self
1619                .hub
1620                .auth
1621                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1622                .await
1623            {
1624                Ok(token) => token,
1625                Err(e) => match dlg.token(e) {
1626                    Ok(token) => token,
1627                    Err(e) => {
1628                        dlg.finished(false);
1629                        return Err(common::Error::MissingToken(e));
1630                    }
1631                },
1632            };
1633            let mut req_result = {
1634                let client = &self.hub.client;
1635                dlg.pre_request();
1636                let mut req_builder = hyper::Request::builder()
1637                    .method(hyper::Method::GET)
1638                    .uri(url.as_str())
1639                    .header(USER_AGENT, self.hub._user_agent.clone());
1640
1641                if let Some(token) = token.as_ref() {
1642                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1643                }
1644
1645                let request = req_builder
1646                    .header(CONTENT_LENGTH, 0_u64)
1647                    .body(common::to_body::<String>(None));
1648
1649                client.request(request.unwrap()).await
1650            };
1651
1652            match req_result {
1653                Err(err) => {
1654                    if let common::Retry::After(d) = dlg.http_error(&err) {
1655                        sleep(d).await;
1656                        continue;
1657                    }
1658                    dlg.finished(false);
1659                    return Err(common::Error::HttpError(err));
1660                }
1661                Ok(res) => {
1662                    let (mut parts, body) = res.into_parts();
1663                    let mut body = common::Body::new(body);
1664                    if !parts.status.is_success() {
1665                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1666                        let error = serde_json::from_str(&common::to_string(&bytes));
1667                        let response = common::to_response(parts, bytes.into());
1668
1669                        if let common::Retry::After(d) =
1670                            dlg.http_failure(&response, error.as_ref().ok())
1671                        {
1672                            sleep(d).await;
1673                            continue;
1674                        }
1675
1676                        dlg.finished(false);
1677
1678                        return Err(match error {
1679                            Ok(value) => common::Error::BadRequest(value),
1680                            _ => common::Error::Failure(response),
1681                        });
1682                    }
1683                    let response = {
1684                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1685                        let encoded = common::to_string(&bytes);
1686                        match serde_json::from_str(&encoded) {
1687                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1688                            Err(error) => {
1689                                dlg.response_json_decode_error(&encoded, &error);
1690                                return Err(common::Error::JsonDecodeError(
1691                                    encoded.to_string(),
1692                                    error,
1693                                ));
1694                            }
1695                        }
1696                    };
1697
1698                    dlg.finished(true);
1699                    return Ok(response);
1700                }
1701            }
1702        }
1703    }
1704
1705    /// An expression used to filter case classifications. If it's an empty string, then no filtering happens. Otherwise, case classifications will be returned that match the filter.
1706    ///
1707    /// Sets the *query* query property to the given value.
1708    pub fn query(mut self, new_value: &str) -> CaseClassificationSearchCall<'a, C> {
1709        self._query = Some(new_value.to_string());
1710        self
1711    }
1712    /// The product line of the Product.
1713    ///
1714    /// Sets the *product.product line* query property to the given value.
1715    pub fn product_product_line(mut self, new_value: &str) -> CaseClassificationSearchCall<'a, C> {
1716        self._product_product_line = Some(new_value.to_string());
1717        self
1718    }
1719    /// A token identifying the page of results to return. If unspecified, the first page is retrieved.
1720    ///
1721    /// Sets the *page token* query property to the given value.
1722    pub fn page_token(mut self, new_value: &str) -> CaseClassificationSearchCall<'a, C> {
1723        self._page_token = Some(new_value.to_string());
1724        self
1725    }
1726    /// The maximum number of classifications fetched with each request.
1727    ///
1728    /// Sets the *page size* query property to the given value.
1729    pub fn page_size(mut self, new_value: i32) -> CaseClassificationSearchCall<'a, C> {
1730        self._page_size = Some(new_value);
1731        self
1732    }
1733    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1734    /// while executing the actual API request.
1735    ///
1736    /// ````text
1737    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1738    /// ````
1739    ///
1740    /// Sets the *delegate* property to the given value.
1741    pub fn delegate(
1742        mut self,
1743        new_value: &'a mut dyn common::Delegate,
1744    ) -> CaseClassificationSearchCall<'a, C> {
1745        self._delegate = Some(new_value);
1746        self
1747    }
1748
1749    /// Set any additional parameter of the query string used in the request.
1750    /// It should be used to set parameters which are not yet available through their own
1751    /// setters.
1752    ///
1753    /// Please note that this method must not be used to set any of the known parameters
1754    /// which have their own setter method. If done anyway, the request will fail.
1755    ///
1756    /// # Additional Parameters
1757    ///
1758    /// * *$.xgafv* (query-string) - V1 error format.
1759    /// * *access_token* (query-string) - OAuth access token.
1760    /// * *alt* (query-string) - Data format for response.
1761    /// * *callback* (query-string) - JSONP
1762    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1763    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1764    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1765    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1766    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1767    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1768    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1769    pub fn param<T>(mut self, name: T, value: T) -> CaseClassificationSearchCall<'a, C>
1770    where
1771        T: AsRef<str>,
1772    {
1773        self._additional_params
1774            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1775        self
1776    }
1777
1778    /// Identifies the authorization scope for the method you are building.
1779    ///
1780    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1781    /// [`Scope::CloudPlatform`].
1782    ///
1783    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1784    /// tokens for more than one scope.
1785    ///
1786    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1787    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1788    /// sufficient, a read-write scope will do as well.
1789    pub fn add_scope<St>(mut self, scope: St) -> CaseClassificationSearchCall<'a, C>
1790    where
1791        St: AsRef<str>,
1792    {
1793        self._scopes.insert(String::from(scope.as_ref()));
1794        self
1795    }
1796    /// Identifies the authorization scope(s) for the method you are building.
1797    ///
1798    /// See [`Self::add_scope()`] for details.
1799    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseClassificationSearchCall<'a, C>
1800    where
1801        I: IntoIterator<Item = St>,
1802        St: AsRef<str>,
1803    {
1804        self._scopes
1805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1806        self
1807    }
1808
1809    /// Removes all scopes, and no default scope will be used either.
1810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1811    /// for details).
1812    pub fn clear_scopes(mut self) -> CaseClassificationSearchCall<'a, C> {
1813        self._scopes.clear();
1814        self
1815    }
1816}
1817
1818/// Retrieve an attachment associated with a support case. EXAMPLES: cURL: ```shell attachment="projects/some-project/cases/23598314/attachments/0684M00000P3h1fQAB" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$attachment" ``` Python: ```python import googleapiclient.discovery api_version = "v2beta" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .attachments() .get(name="projects/some-project/cases/43595344/attachments/0684M00000P3h1fQAB") ) print(request.execute()) ```
1819///
1820/// A builder for the *attachments.get* method supported by a *case* resource.
1821/// It is not used directly, but through a [`CaseMethods`] instance.
1822///
1823/// # Example
1824///
1825/// Instantiate a resource method builder
1826///
1827/// ```test_harness,no_run
1828/// # extern crate hyper;
1829/// # extern crate hyper_rustls;
1830/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
1831/// # async fn dox() {
1832/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1833///
1834/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1835/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1836/// #     .with_native_roots()
1837/// #     .unwrap()
1838/// #     .https_only()
1839/// #     .enable_http2()
1840/// #     .build();
1841///
1842/// # let executor = hyper_util::rt::TokioExecutor::new();
1843/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1844/// #     secret,
1845/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1846/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1847/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1848/// #     ),
1849/// # ).build().await.unwrap();
1850///
1851/// # let client = hyper_util::client::legacy::Client::builder(
1852/// #     hyper_util::rt::TokioExecutor::new()
1853/// # )
1854/// # .build(
1855/// #     hyper_rustls::HttpsConnectorBuilder::new()
1856/// #         .with_native_roots()
1857/// #         .unwrap()
1858/// #         .https_or_http()
1859/// #         .enable_http2()
1860/// #         .build()
1861/// # );
1862/// # let mut hub = CloudSupport::new(client, auth);
1863/// // You can configure optional parameters by calling the respective setters at will, and
1864/// // execute the final call using `doit()`.
1865/// // Values shown here are possibly random and not representative !
1866/// let result = hub.cases().attachments_get("name")
1867///              .doit().await;
1868/// # }
1869/// ```
1870pub struct CaseAttachmentGetCall<'a, C>
1871where
1872    C: 'a,
1873{
1874    hub: &'a CloudSupport<C>,
1875    _name: String,
1876    _delegate: Option<&'a mut dyn common::Delegate>,
1877    _additional_params: HashMap<String, String>,
1878    _scopes: BTreeSet<String>,
1879}
1880
1881impl<'a, C> common::CallBuilder for CaseAttachmentGetCall<'a, C> {}
1882
1883impl<'a, C> CaseAttachmentGetCall<'a, C>
1884where
1885    C: common::Connector,
1886{
1887    /// Perform the operation you have build so far.
1888    pub async fn doit(mut self) -> common::Result<(common::Response, Attachment)> {
1889        use std::borrow::Cow;
1890        use std::io::{Read, Seek};
1891
1892        use common::{url::Params, ToParts};
1893        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1894
1895        let mut dd = common::DefaultDelegate;
1896        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1897        dlg.begin(common::MethodInfo {
1898            id: "cloudsupport.cases.attachments.get",
1899            http_method: hyper::Method::GET,
1900        });
1901
1902        for &field in ["alt", "name"].iter() {
1903            if self._additional_params.contains_key(field) {
1904                dlg.finished(false);
1905                return Err(common::Error::FieldClash(field));
1906            }
1907        }
1908
1909        let mut params = Params::with_capacity(3 + self._additional_params.len());
1910        params.push("name", self._name);
1911
1912        params.extend(self._additional_params.iter());
1913
1914        params.push("alt", "json");
1915        let mut url = self.hub._base_url.clone() + "v2beta/{+name}";
1916        if self._scopes.is_empty() {
1917            self._scopes
1918                .insert(Scope::CloudPlatform.as_ref().to_string());
1919        }
1920
1921        #[allow(clippy::single_element_loop)]
1922        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1923            url = params.uri_replacement(url, param_name, find_this, true);
1924        }
1925        {
1926            let to_remove = ["name"];
1927            params.remove_params(&to_remove);
1928        }
1929
1930        let url = params.parse_with_url(&url);
1931
1932        loop {
1933            let token = match self
1934                .hub
1935                .auth
1936                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1937                .await
1938            {
1939                Ok(token) => token,
1940                Err(e) => match dlg.token(e) {
1941                    Ok(token) => token,
1942                    Err(e) => {
1943                        dlg.finished(false);
1944                        return Err(common::Error::MissingToken(e));
1945                    }
1946                },
1947            };
1948            let mut req_result = {
1949                let client = &self.hub.client;
1950                dlg.pre_request();
1951                let mut req_builder = hyper::Request::builder()
1952                    .method(hyper::Method::GET)
1953                    .uri(url.as_str())
1954                    .header(USER_AGENT, self.hub._user_agent.clone());
1955
1956                if let Some(token) = token.as_ref() {
1957                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1958                }
1959
1960                let request = req_builder
1961                    .header(CONTENT_LENGTH, 0_u64)
1962                    .body(common::to_body::<String>(None));
1963
1964                client.request(request.unwrap()).await
1965            };
1966
1967            match req_result {
1968                Err(err) => {
1969                    if let common::Retry::After(d) = dlg.http_error(&err) {
1970                        sleep(d).await;
1971                        continue;
1972                    }
1973                    dlg.finished(false);
1974                    return Err(common::Error::HttpError(err));
1975                }
1976                Ok(res) => {
1977                    let (mut parts, body) = res.into_parts();
1978                    let mut body = common::Body::new(body);
1979                    if !parts.status.is_success() {
1980                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1981                        let error = serde_json::from_str(&common::to_string(&bytes));
1982                        let response = common::to_response(parts, bytes.into());
1983
1984                        if let common::Retry::After(d) =
1985                            dlg.http_failure(&response, error.as_ref().ok())
1986                        {
1987                            sleep(d).await;
1988                            continue;
1989                        }
1990
1991                        dlg.finished(false);
1992
1993                        return Err(match error {
1994                            Ok(value) => common::Error::BadRequest(value),
1995                            _ => common::Error::Failure(response),
1996                        });
1997                    }
1998                    let response = {
1999                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2000                        let encoded = common::to_string(&bytes);
2001                        match serde_json::from_str(&encoded) {
2002                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2003                            Err(error) => {
2004                                dlg.response_json_decode_error(&encoded, &error);
2005                                return Err(common::Error::JsonDecodeError(
2006                                    encoded.to_string(),
2007                                    error,
2008                                ));
2009                            }
2010                        }
2011                    };
2012
2013                    dlg.finished(true);
2014                    return Ok(response);
2015                }
2016            }
2017        }
2018    }
2019
2020    /// Required. The name of the attachment to get.
2021    ///
2022    /// Sets the *name* path property to the given value.
2023    ///
2024    /// Even though the property as already been set when instantiating this call,
2025    /// we provide this method for API completeness.
2026    pub fn name(mut self, new_value: &str) -> CaseAttachmentGetCall<'a, C> {
2027        self._name = new_value.to_string();
2028        self
2029    }
2030    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2031    /// while executing the actual API request.
2032    ///
2033    /// ````text
2034    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2035    /// ````
2036    ///
2037    /// Sets the *delegate* property to the given value.
2038    pub fn delegate(
2039        mut self,
2040        new_value: &'a mut dyn common::Delegate,
2041    ) -> CaseAttachmentGetCall<'a, C> {
2042        self._delegate = Some(new_value);
2043        self
2044    }
2045
2046    /// Set any additional parameter of the query string used in the request.
2047    /// It should be used to set parameters which are not yet available through their own
2048    /// setters.
2049    ///
2050    /// Please note that this method must not be used to set any of the known parameters
2051    /// which have their own setter method. If done anyway, the request will fail.
2052    ///
2053    /// # Additional Parameters
2054    ///
2055    /// * *$.xgafv* (query-string) - V1 error format.
2056    /// * *access_token* (query-string) - OAuth access token.
2057    /// * *alt* (query-string) - Data format for response.
2058    /// * *callback* (query-string) - JSONP
2059    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2060    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2061    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2062    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2063    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2064    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2065    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2066    pub fn param<T>(mut self, name: T, value: T) -> CaseAttachmentGetCall<'a, C>
2067    where
2068        T: AsRef<str>,
2069    {
2070        self._additional_params
2071            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2072        self
2073    }
2074
2075    /// Identifies the authorization scope for the method you are building.
2076    ///
2077    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2078    /// [`Scope::CloudPlatform`].
2079    ///
2080    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2081    /// tokens for more than one scope.
2082    ///
2083    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2084    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2085    /// sufficient, a read-write scope will do as well.
2086    pub fn add_scope<St>(mut self, scope: St) -> CaseAttachmentGetCall<'a, C>
2087    where
2088        St: AsRef<str>,
2089    {
2090        self._scopes.insert(String::from(scope.as_ref()));
2091        self
2092    }
2093    /// Identifies the authorization scope(s) for the method you are building.
2094    ///
2095    /// See [`Self::add_scope()`] for details.
2096    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseAttachmentGetCall<'a, C>
2097    where
2098        I: IntoIterator<Item = St>,
2099        St: AsRef<str>,
2100    {
2101        self._scopes
2102            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2103        self
2104    }
2105
2106    /// Removes all scopes, and no default scope will be used either.
2107    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2108    /// for details).
2109    pub fn clear_scopes(mut self) -> CaseAttachmentGetCall<'a, C> {
2110        self._scopes.clear();
2111        self
2112    }
2113}
2114
2115/// List all the attachments associated with a support case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/23598314" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case/attachments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .attachments() .list(parent="projects/some-project/cases/43595344") ) print(request.execute()) ```
2116///
2117/// A builder for the *attachments.list* method supported by a *case* resource.
2118/// It is not used directly, but through a [`CaseMethods`] instance.
2119///
2120/// # Example
2121///
2122/// Instantiate a resource method builder
2123///
2124/// ```test_harness,no_run
2125/// # extern crate hyper;
2126/// # extern crate hyper_rustls;
2127/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
2128/// # async fn dox() {
2129/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2130///
2131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2132/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2133/// #     .with_native_roots()
2134/// #     .unwrap()
2135/// #     .https_only()
2136/// #     .enable_http2()
2137/// #     .build();
2138///
2139/// # let executor = hyper_util::rt::TokioExecutor::new();
2140/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2141/// #     secret,
2142/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2143/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2144/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2145/// #     ),
2146/// # ).build().await.unwrap();
2147///
2148/// # let client = hyper_util::client::legacy::Client::builder(
2149/// #     hyper_util::rt::TokioExecutor::new()
2150/// # )
2151/// # .build(
2152/// #     hyper_rustls::HttpsConnectorBuilder::new()
2153/// #         .with_native_roots()
2154/// #         .unwrap()
2155/// #         .https_or_http()
2156/// #         .enable_http2()
2157/// #         .build()
2158/// # );
2159/// # let mut hub = CloudSupport::new(client, auth);
2160/// // You can configure optional parameters by calling the respective setters at will, and
2161/// // execute the final call using `doit()`.
2162/// // Values shown here are possibly random and not representative !
2163/// let result = hub.cases().attachments_list("parent")
2164///              .page_token("amet")
2165///              .page_size(-20)
2166///              .doit().await;
2167/// # }
2168/// ```
2169pub struct CaseAttachmentListCall<'a, C>
2170where
2171    C: 'a,
2172{
2173    hub: &'a CloudSupport<C>,
2174    _parent: String,
2175    _page_token: Option<String>,
2176    _page_size: Option<i32>,
2177    _delegate: Option<&'a mut dyn common::Delegate>,
2178    _additional_params: HashMap<String, String>,
2179    _scopes: BTreeSet<String>,
2180}
2181
2182impl<'a, C> common::CallBuilder for CaseAttachmentListCall<'a, C> {}
2183
2184impl<'a, C> CaseAttachmentListCall<'a, C>
2185where
2186    C: common::Connector,
2187{
2188    /// Perform the operation you have build so far.
2189    pub async fn doit(mut self) -> common::Result<(common::Response, ListAttachmentsResponse)> {
2190        use std::borrow::Cow;
2191        use std::io::{Read, Seek};
2192
2193        use common::{url::Params, ToParts};
2194        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2195
2196        let mut dd = common::DefaultDelegate;
2197        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2198        dlg.begin(common::MethodInfo {
2199            id: "cloudsupport.cases.attachments.list",
2200            http_method: hyper::Method::GET,
2201        });
2202
2203        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2204            if self._additional_params.contains_key(field) {
2205                dlg.finished(false);
2206                return Err(common::Error::FieldClash(field));
2207            }
2208        }
2209
2210        let mut params = Params::with_capacity(5 + self._additional_params.len());
2211        params.push("parent", self._parent);
2212        if let Some(value) = self._page_token.as_ref() {
2213            params.push("pageToken", value);
2214        }
2215        if let Some(value) = self._page_size.as_ref() {
2216            params.push("pageSize", value.to_string());
2217        }
2218
2219        params.extend(self._additional_params.iter());
2220
2221        params.push("alt", "json");
2222        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}/attachments";
2223        if self._scopes.is_empty() {
2224            self._scopes
2225                .insert(Scope::CloudPlatform.as_ref().to_string());
2226        }
2227
2228        #[allow(clippy::single_element_loop)]
2229        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2230            url = params.uri_replacement(url, param_name, find_this, true);
2231        }
2232        {
2233            let to_remove = ["parent"];
2234            params.remove_params(&to_remove);
2235        }
2236
2237        let url = params.parse_with_url(&url);
2238
2239        loop {
2240            let token = match self
2241                .hub
2242                .auth
2243                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2244                .await
2245            {
2246                Ok(token) => token,
2247                Err(e) => match dlg.token(e) {
2248                    Ok(token) => token,
2249                    Err(e) => {
2250                        dlg.finished(false);
2251                        return Err(common::Error::MissingToken(e));
2252                    }
2253                },
2254            };
2255            let mut req_result = {
2256                let client = &self.hub.client;
2257                dlg.pre_request();
2258                let mut req_builder = hyper::Request::builder()
2259                    .method(hyper::Method::GET)
2260                    .uri(url.as_str())
2261                    .header(USER_AGENT, self.hub._user_agent.clone());
2262
2263                if let Some(token) = token.as_ref() {
2264                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2265                }
2266
2267                let request = req_builder
2268                    .header(CONTENT_LENGTH, 0_u64)
2269                    .body(common::to_body::<String>(None));
2270
2271                client.request(request.unwrap()).await
2272            };
2273
2274            match req_result {
2275                Err(err) => {
2276                    if let common::Retry::After(d) = dlg.http_error(&err) {
2277                        sleep(d).await;
2278                        continue;
2279                    }
2280                    dlg.finished(false);
2281                    return Err(common::Error::HttpError(err));
2282                }
2283                Ok(res) => {
2284                    let (mut parts, body) = res.into_parts();
2285                    let mut body = common::Body::new(body);
2286                    if !parts.status.is_success() {
2287                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2288                        let error = serde_json::from_str(&common::to_string(&bytes));
2289                        let response = common::to_response(parts, bytes.into());
2290
2291                        if let common::Retry::After(d) =
2292                            dlg.http_failure(&response, error.as_ref().ok())
2293                        {
2294                            sleep(d).await;
2295                            continue;
2296                        }
2297
2298                        dlg.finished(false);
2299
2300                        return Err(match error {
2301                            Ok(value) => common::Error::BadRequest(value),
2302                            _ => common::Error::Failure(response),
2303                        });
2304                    }
2305                    let response = {
2306                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2307                        let encoded = common::to_string(&bytes);
2308                        match serde_json::from_str(&encoded) {
2309                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2310                            Err(error) => {
2311                                dlg.response_json_decode_error(&encoded, &error);
2312                                return Err(common::Error::JsonDecodeError(
2313                                    encoded.to_string(),
2314                                    error,
2315                                ));
2316                            }
2317                        }
2318                    };
2319
2320                    dlg.finished(true);
2321                    return Ok(response);
2322                }
2323            }
2324        }
2325    }
2326
2327    /// Required. The name of the case for which attachments should be listed.
2328    ///
2329    /// Sets the *parent* path property to the given value.
2330    ///
2331    /// Even though the property as already been set when instantiating this call,
2332    /// we provide this method for API completeness.
2333    pub fn parent(mut self, new_value: &str) -> CaseAttachmentListCall<'a, C> {
2334        self._parent = new_value.to_string();
2335        self
2336    }
2337    /// A token identifying the page of results to return. If unspecified, the first page is retrieved.
2338    ///
2339    /// Sets the *page token* query property to the given value.
2340    pub fn page_token(mut self, new_value: &str) -> CaseAttachmentListCall<'a, C> {
2341        self._page_token = Some(new_value.to_string());
2342        self
2343    }
2344    /// The maximum number of attachments fetched with each request. If not provided, the default is 10. The maximum page size that will be returned is 100. The size of each page can be smaller than the requested page size and can include zero. For example, you could request 100 attachments on one page, receive 0, and then on the next page, receive 90.
2345    ///
2346    /// Sets the *page size* query property to the given value.
2347    pub fn page_size(mut self, new_value: i32) -> CaseAttachmentListCall<'a, C> {
2348        self._page_size = Some(new_value);
2349        self
2350    }
2351    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2352    /// while executing the actual API request.
2353    ///
2354    /// ````text
2355    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2356    /// ````
2357    ///
2358    /// Sets the *delegate* property to the given value.
2359    pub fn delegate(
2360        mut self,
2361        new_value: &'a mut dyn common::Delegate,
2362    ) -> CaseAttachmentListCall<'a, C> {
2363        self._delegate = Some(new_value);
2364        self
2365    }
2366
2367    /// Set any additional parameter of the query string used in the request.
2368    /// It should be used to set parameters which are not yet available through their own
2369    /// setters.
2370    ///
2371    /// Please note that this method must not be used to set any of the known parameters
2372    /// which have their own setter method. If done anyway, the request will fail.
2373    ///
2374    /// # Additional Parameters
2375    ///
2376    /// * *$.xgafv* (query-string) - V1 error format.
2377    /// * *access_token* (query-string) - OAuth access token.
2378    /// * *alt* (query-string) - Data format for response.
2379    /// * *callback* (query-string) - JSONP
2380    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2381    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2382    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2383    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2384    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2385    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2386    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2387    pub fn param<T>(mut self, name: T, value: T) -> CaseAttachmentListCall<'a, C>
2388    where
2389        T: AsRef<str>,
2390    {
2391        self._additional_params
2392            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2393        self
2394    }
2395
2396    /// Identifies the authorization scope for the method you are building.
2397    ///
2398    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2399    /// [`Scope::CloudPlatform`].
2400    ///
2401    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2402    /// tokens for more than one scope.
2403    ///
2404    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2405    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2406    /// sufficient, a read-write scope will do as well.
2407    pub fn add_scope<St>(mut self, scope: St) -> CaseAttachmentListCall<'a, C>
2408    where
2409        St: AsRef<str>,
2410    {
2411        self._scopes.insert(String::from(scope.as_ref()));
2412        self
2413    }
2414    /// Identifies the authorization scope(s) for the method you are building.
2415    ///
2416    /// See [`Self::add_scope()`] for details.
2417    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseAttachmentListCall<'a, C>
2418    where
2419        I: IntoIterator<Item = St>,
2420        St: AsRef<str>,
2421    {
2422        self._scopes
2423            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2424        self
2425    }
2426
2427    /// Removes all scopes, and no default scope will be used either.
2428    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2429    /// for details).
2430    pub fn clear_scopes(mut self) -> CaseAttachmentListCall<'a, C> {
2431        self._scopes.clear();
2432        self
2433    }
2434}
2435
2436/// Add a new comment to a case. The comment must have the following fields set: `body`. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43591344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header 'Content-Type: application/json' \ --data '{ "body": "This is a test comment." }' \ "https://cloudsupport.googleapis.com/v2/$case/comments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .comments() .create( parent="projects/some-project/cases/43595344", body={"body": "This is a test comment."}, ) ) print(request.execute()) ```
2437///
2438/// A builder for the *comments.create* method supported by a *case* resource.
2439/// It is not used directly, but through a [`CaseMethods`] instance.
2440///
2441/// # Example
2442///
2443/// Instantiate a resource method builder
2444///
2445/// ```test_harness,no_run
2446/// # extern crate hyper;
2447/// # extern crate hyper_rustls;
2448/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
2449/// use cloudsupport2_beta::api::Comment;
2450/// # async fn dox() {
2451/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2452///
2453/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2454/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2455/// #     .with_native_roots()
2456/// #     .unwrap()
2457/// #     .https_only()
2458/// #     .enable_http2()
2459/// #     .build();
2460///
2461/// # let executor = hyper_util::rt::TokioExecutor::new();
2462/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2463/// #     secret,
2464/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2465/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2466/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2467/// #     ),
2468/// # ).build().await.unwrap();
2469///
2470/// # let client = hyper_util::client::legacy::Client::builder(
2471/// #     hyper_util::rt::TokioExecutor::new()
2472/// # )
2473/// # .build(
2474/// #     hyper_rustls::HttpsConnectorBuilder::new()
2475/// #         .with_native_roots()
2476/// #         .unwrap()
2477/// #         .https_or_http()
2478/// #         .enable_http2()
2479/// #         .build()
2480/// # );
2481/// # let mut hub = CloudSupport::new(client, auth);
2482/// // As the method needs a request, you would usually fill it with the desired information
2483/// // into the respective structure. Some of the parts shown here might not be applicable !
2484/// // Values shown here are possibly random and not representative !
2485/// let mut req = Comment::default();
2486///
2487/// // You can configure optional parameters by calling the respective setters at will, and
2488/// // execute the final call using `doit()`.
2489/// // Values shown here are possibly random and not representative !
2490/// let result = hub.cases().comments_create(req, "parent")
2491///              .doit().await;
2492/// # }
2493/// ```
2494pub struct CaseCommentCreateCall<'a, C>
2495where
2496    C: 'a,
2497{
2498    hub: &'a CloudSupport<C>,
2499    _request: Comment,
2500    _parent: String,
2501    _delegate: Option<&'a mut dyn common::Delegate>,
2502    _additional_params: HashMap<String, String>,
2503    _scopes: BTreeSet<String>,
2504}
2505
2506impl<'a, C> common::CallBuilder for CaseCommentCreateCall<'a, C> {}
2507
2508impl<'a, C> CaseCommentCreateCall<'a, C>
2509where
2510    C: common::Connector,
2511{
2512    /// Perform the operation you have build so far.
2513    pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
2514        use std::borrow::Cow;
2515        use std::io::{Read, Seek};
2516
2517        use common::{url::Params, ToParts};
2518        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2519
2520        let mut dd = common::DefaultDelegate;
2521        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2522        dlg.begin(common::MethodInfo {
2523            id: "cloudsupport.cases.comments.create",
2524            http_method: hyper::Method::POST,
2525        });
2526
2527        for &field in ["alt", "parent"].iter() {
2528            if self._additional_params.contains_key(field) {
2529                dlg.finished(false);
2530                return Err(common::Error::FieldClash(field));
2531            }
2532        }
2533
2534        let mut params = Params::with_capacity(4 + self._additional_params.len());
2535        params.push("parent", self._parent);
2536
2537        params.extend(self._additional_params.iter());
2538
2539        params.push("alt", "json");
2540        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}/comments";
2541        if self._scopes.is_empty() {
2542            self._scopes
2543                .insert(Scope::CloudPlatform.as_ref().to_string());
2544        }
2545
2546        #[allow(clippy::single_element_loop)]
2547        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2548            url = params.uri_replacement(url, param_name, find_this, true);
2549        }
2550        {
2551            let to_remove = ["parent"];
2552            params.remove_params(&to_remove);
2553        }
2554
2555        let url = params.parse_with_url(&url);
2556
2557        let mut json_mime_type = mime::APPLICATION_JSON;
2558        let mut request_value_reader = {
2559            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2560            common::remove_json_null_values(&mut value);
2561            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2562            serde_json::to_writer(&mut dst, &value).unwrap();
2563            dst
2564        };
2565        let request_size = request_value_reader
2566            .seek(std::io::SeekFrom::End(0))
2567            .unwrap();
2568        request_value_reader
2569            .seek(std::io::SeekFrom::Start(0))
2570            .unwrap();
2571
2572        loop {
2573            let token = match self
2574                .hub
2575                .auth
2576                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2577                .await
2578            {
2579                Ok(token) => token,
2580                Err(e) => match dlg.token(e) {
2581                    Ok(token) => token,
2582                    Err(e) => {
2583                        dlg.finished(false);
2584                        return Err(common::Error::MissingToken(e));
2585                    }
2586                },
2587            };
2588            request_value_reader
2589                .seek(std::io::SeekFrom::Start(0))
2590                .unwrap();
2591            let mut req_result = {
2592                let client = &self.hub.client;
2593                dlg.pre_request();
2594                let mut req_builder = hyper::Request::builder()
2595                    .method(hyper::Method::POST)
2596                    .uri(url.as_str())
2597                    .header(USER_AGENT, self.hub._user_agent.clone());
2598
2599                if let Some(token) = token.as_ref() {
2600                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2601                }
2602
2603                let request = req_builder
2604                    .header(CONTENT_TYPE, json_mime_type.to_string())
2605                    .header(CONTENT_LENGTH, request_size as u64)
2606                    .body(common::to_body(
2607                        request_value_reader.get_ref().clone().into(),
2608                    ));
2609
2610                client.request(request.unwrap()).await
2611            };
2612
2613            match req_result {
2614                Err(err) => {
2615                    if let common::Retry::After(d) = dlg.http_error(&err) {
2616                        sleep(d).await;
2617                        continue;
2618                    }
2619                    dlg.finished(false);
2620                    return Err(common::Error::HttpError(err));
2621                }
2622                Ok(res) => {
2623                    let (mut parts, body) = res.into_parts();
2624                    let mut body = common::Body::new(body);
2625                    if !parts.status.is_success() {
2626                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2627                        let error = serde_json::from_str(&common::to_string(&bytes));
2628                        let response = common::to_response(parts, bytes.into());
2629
2630                        if let common::Retry::After(d) =
2631                            dlg.http_failure(&response, error.as_ref().ok())
2632                        {
2633                            sleep(d).await;
2634                            continue;
2635                        }
2636
2637                        dlg.finished(false);
2638
2639                        return Err(match error {
2640                            Ok(value) => common::Error::BadRequest(value),
2641                            _ => common::Error::Failure(response),
2642                        });
2643                    }
2644                    let response = {
2645                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2646                        let encoded = common::to_string(&bytes);
2647                        match serde_json::from_str(&encoded) {
2648                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2649                            Err(error) => {
2650                                dlg.response_json_decode_error(&encoded, &error);
2651                                return Err(common::Error::JsonDecodeError(
2652                                    encoded.to_string(),
2653                                    error,
2654                                ));
2655                            }
2656                        }
2657                    };
2658
2659                    dlg.finished(true);
2660                    return Ok(response);
2661                }
2662            }
2663        }
2664    }
2665
2666    ///
2667    /// Sets the *request* property to the given value.
2668    ///
2669    /// Even though the property as already been set when instantiating this call,
2670    /// we provide this method for API completeness.
2671    pub fn request(mut self, new_value: Comment) -> CaseCommentCreateCall<'a, C> {
2672        self._request = new_value;
2673        self
2674    }
2675    /// Required. The name of the case to which the comment should be added.
2676    ///
2677    /// Sets the *parent* path property to the given value.
2678    ///
2679    /// Even though the property as already been set when instantiating this call,
2680    /// we provide this method for API completeness.
2681    pub fn parent(mut self, new_value: &str) -> CaseCommentCreateCall<'a, C> {
2682        self._parent = new_value.to_string();
2683        self
2684    }
2685    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2686    /// while executing the actual API request.
2687    ///
2688    /// ````text
2689    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2690    /// ````
2691    ///
2692    /// Sets the *delegate* property to the given value.
2693    pub fn delegate(
2694        mut self,
2695        new_value: &'a mut dyn common::Delegate,
2696    ) -> CaseCommentCreateCall<'a, C> {
2697        self._delegate = Some(new_value);
2698        self
2699    }
2700
2701    /// Set any additional parameter of the query string used in the request.
2702    /// It should be used to set parameters which are not yet available through their own
2703    /// setters.
2704    ///
2705    /// Please note that this method must not be used to set any of the known parameters
2706    /// which have their own setter method. If done anyway, the request will fail.
2707    ///
2708    /// # Additional Parameters
2709    ///
2710    /// * *$.xgafv* (query-string) - V1 error format.
2711    /// * *access_token* (query-string) - OAuth access token.
2712    /// * *alt* (query-string) - Data format for response.
2713    /// * *callback* (query-string) - JSONP
2714    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2715    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2716    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2717    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2718    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2719    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2720    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2721    pub fn param<T>(mut self, name: T, value: T) -> CaseCommentCreateCall<'a, C>
2722    where
2723        T: AsRef<str>,
2724    {
2725        self._additional_params
2726            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2727        self
2728    }
2729
2730    /// Identifies the authorization scope for the method you are building.
2731    ///
2732    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2733    /// [`Scope::CloudPlatform`].
2734    ///
2735    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2736    /// tokens for more than one scope.
2737    ///
2738    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2739    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2740    /// sufficient, a read-write scope will do as well.
2741    pub fn add_scope<St>(mut self, scope: St) -> CaseCommentCreateCall<'a, C>
2742    where
2743        St: AsRef<str>,
2744    {
2745        self._scopes.insert(String::from(scope.as_ref()));
2746        self
2747    }
2748    /// Identifies the authorization scope(s) for the method you are building.
2749    ///
2750    /// See [`Self::add_scope()`] for details.
2751    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseCommentCreateCall<'a, C>
2752    where
2753        I: IntoIterator<Item = St>,
2754        St: AsRef<str>,
2755    {
2756        self._scopes
2757            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2758        self
2759    }
2760
2761    /// Removes all scopes, and no default scope will be used either.
2762    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2763    /// for details).
2764    pub fn clear_scopes(mut self) -> CaseCommentCreateCall<'a, C> {
2765        self._scopes.clear();
2766        self
2767    }
2768}
2769
2770/// Retrieve a comment. EXAMPLES: cURL: ```shell comment="projects/some-project/cases/43595344/comments/234567890" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$comment" ``` Python: ```python import googleapiclient.discovery api_version = "v2beta" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().comments().get( name="projects/some-project/cases/43595344/comments/234567890", ) print(request.execute()) ```
2771///
2772/// A builder for the *comments.get* method supported by a *case* resource.
2773/// It is not used directly, but through a [`CaseMethods`] instance.
2774///
2775/// # Example
2776///
2777/// Instantiate a resource method builder
2778///
2779/// ```test_harness,no_run
2780/// # extern crate hyper;
2781/// # extern crate hyper_rustls;
2782/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
2783/// # async fn dox() {
2784/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2785///
2786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2787/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2788/// #     .with_native_roots()
2789/// #     .unwrap()
2790/// #     .https_only()
2791/// #     .enable_http2()
2792/// #     .build();
2793///
2794/// # let executor = hyper_util::rt::TokioExecutor::new();
2795/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2796/// #     secret,
2797/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2798/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2799/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2800/// #     ),
2801/// # ).build().await.unwrap();
2802///
2803/// # let client = hyper_util::client::legacy::Client::builder(
2804/// #     hyper_util::rt::TokioExecutor::new()
2805/// # )
2806/// # .build(
2807/// #     hyper_rustls::HttpsConnectorBuilder::new()
2808/// #         .with_native_roots()
2809/// #         .unwrap()
2810/// #         .https_or_http()
2811/// #         .enable_http2()
2812/// #         .build()
2813/// # );
2814/// # let mut hub = CloudSupport::new(client, auth);
2815/// // You can configure optional parameters by calling the respective setters at will, and
2816/// // execute the final call using `doit()`.
2817/// // Values shown here are possibly random and not representative !
2818/// let result = hub.cases().comments_get("name")
2819///              .doit().await;
2820/// # }
2821/// ```
2822pub struct CaseCommentGetCall<'a, C>
2823where
2824    C: 'a,
2825{
2826    hub: &'a CloudSupport<C>,
2827    _name: String,
2828    _delegate: Option<&'a mut dyn common::Delegate>,
2829    _additional_params: HashMap<String, String>,
2830    _scopes: BTreeSet<String>,
2831}
2832
2833impl<'a, C> common::CallBuilder for CaseCommentGetCall<'a, C> {}
2834
2835impl<'a, C> CaseCommentGetCall<'a, C>
2836where
2837    C: common::Connector,
2838{
2839    /// Perform the operation you have build so far.
2840    pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
2841        use std::borrow::Cow;
2842        use std::io::{Read, Seek};
2843
2844        use common::{url::Params, ToParts};
2845        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2846
2847        let mut dd = common::DefaultDelegate;
2848        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2849        dlg.begin(common::MethodInfo {
2850            id: "cloudsupport.cases.comments.get",
2851            http_method: hyper::Method::GET,
2852        });
2853
2854        for &field in ["alt", "name"].iter() {
2855            if self._additional_params.contains_key(field) {
2856                dlg.finished(false);
2857                return Err(common::Error::FieldClash(field));
2858            }
2859        }
2860
2861        let mut params = Params::with_capacity(3 + self._additional_params.len());
2862        params.push("name", self._name);
2863
2864        params.extend(self._additional_params.iter());
2865
2866        params.push("alt", "json");
2867        let mut url = self.hub._base_url.clone() + "v2beta/{+name}";
2868        if self._scopes.is_empty() {
2869            self._scopes
2870                .insert(Scope::CloudPlatform.as_ref().to_string());
2871        }
2872
2873        #[allow(clippy::single_element_loop)]
2874        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2875            url = params.uri_replacement(url, param_name, find_this, true);
2876        }
2877        {
2878            let to_remove = ["name"];
2879            params.remove_params(&to_remove);
2880        }
2881
2882        let url = params.parse_with_url(&url);
2883
2884        loop {
2885            let token = match self
2886                .hub
2887                .auth
2888                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2889                .await
2890            {
2891                Ok(token) => token,
2892                Err(e) => match dlg.token(e) {
2893                    Ok(token) => token,
2894                    Err(e) => {
2895                        dlg.finished(false);
2896                        return Err(common::Error::MissingToken(e));
2897                    }
2898                },
2899            };
2900            let mut req_result = {
2901                let client = &self.hub.client;
2902                dlg.pre_request();
2903                let mut req_builder = hyper::Request::builder()
2904                    .method(hyper::Method::GET)
2905                    .uri(url.as_str())
2906                    .header(USER_AGENT, self.hub._user_agent.clone());
2907
2908                if let Some(token) = token.as_ref() {
2909                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2910                }
2911
2912                let request = req_builder
2913                    .header(CONTENT_LENGTH, 0_u64)
2914                    .body(common::to_body::<String>(None));
2915
2916                client.request(request.unwrap()).await
2917            };
2918
2919            match req_result {
2920                Err(err) => {
2921                    if let common::Retry::After(d) = dlg.http_error(&err) {
2922                        sleep(d).await;
2923                        continue;
2924                    }
2925                    dlg.finished(false);
2926                    return Err(common::Error::HttpError(err));
2927                }
2928                Ok(res) => {
2929                    let (mut parts, body) = res.into_parts();
2930                    let mut body = common::Body::new(body);
2931                    if !parts.status.is_success() {
2932                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2933                        let error = serde_json::from_str(&common::to_string(&bytes));
2934                        let response = common::to_response(parts, bytes.into());
2935
2936                        if let common::Retry::After(d) =
2937                            dlg.http_failure(&response, error.as_ref().ok())
2938                        {
2939                            sleep(d).await;
2940                            continue;
2941                        }
2942
2943                        dlg.finished(false);
2944
2945                        return Err(match error {
2946                            Ok(value) => common::Error::BadRequest(value),
2947                            _ => common::Error::Failure(response),
2948                        });
2949                    }
2950                    let response = {
2951                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2952                        let encoded = common::to_string(&bytes);
2953                        match serde_json::from_str(&encoded) {
2954                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2955                            Err(error) => {
2956                                dlg.response_json_decode_error(&encoded, &error);
2957                                return Err(common::Error::JsonDecodeError(
2958                                    encoded.to_string(),
2959                                    error,
2960                                ));
2961                            }
2962                        }
2963                    };
2964
2965                    dlg.finished(true);
2966                    return Ok(response);
2967                }
2968            }
2969        }
2970    }
2971
2972    /// Required. The name of the comment to retrieve.
2973    ///
2974    /// Sets the *name* path property to the given value.
2975    ///
2976    /// Even though the property as already been set when instantiating this call,
2977    /// we provide this method for API completeness.
2978    pub fn name(mut self, new_value: &str) -> CaseCommentGetCall<'a, C> {
2979        self._name = new_value.to_string();
2980        self
2981    }
2982    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2983    /// while executing the actual API request.
2984    ///
2985    /// ````text
2986    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2987    /// ````
2988    ///
2989    /// Sets the *delegate* property to the given value.
2990    pub fn delegate(
2991        mut self,
2992        new_value: &'a mut dyn common::Delegate,
2993    ) -> CaseCommentGetCall<'a, C> {
2994        self._delegate = Some(new_value);
2995        self
2996    }
2997
2998    /// Set any additional parameter of the query string used in the request.
2999    /// It should be used to set parameters which are not yet available through their own
3000    /// setters.
3001    ///
3002    /// Please note that this method must not be used to set any of the known parameters
3003    /// which have their own setter method. If done anyway, the request will fail.
3004    ///
3005    /// # Additional Parameters
3006    ///
3007    /// * *$.xgafv* (query-string) - V1 error format.
3008    /// * *access_token* (query-string) - OAuth access token.
3009    /// * *alt* (query-string) - Data format for response.
3010    /// * *callback* (query-string) - JSONP
3011    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3012    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3013    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3014    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3015    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3016    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3017    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3018    pub fn param<T>(mut self, name: T, value: T) -> CaseCommentGetCall<'a, C>
3019    where
3020        T: AsRef<str>,
3021    {
3022        self._additional_params
3023            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3024        self
3025    }
3026
3027    /// Identifies the authorization scope for the method you are building.
3028    ///
3029    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3030    /// [`Scope::CloudPlatform`].
3031    ///
3032    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3033    /// tokens for more than one scope.
3034    ///
3035    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3036    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3037    /// sufficient, a read-write scope will do as well.
3038    pub fn add_scope<St>(mut self, scope: St) -> CaseCommentGetCall<'a, C>
3039    where
3040        St: AsRef<str>,
3041    {
3042        self._scopes.insert(String::from(scope.as_ref()));
3043        self
3044    }
3045    /// Identifies the authorization scope(s) for the method you are building.
3046    ///
3047    /// See [`Self::add_scope()`] for details.
3048    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseCommentGetCall<'a, C>
3049    where
3050        I: IntoIterator<Item = St>,
3051        St: AsRef<str>,
3052    {
3053        self._scopes
3054            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3055        self
3056    }
3057
3058    /// Removes all scopes, and no default scope will be used either.
3059    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3060    /// for details).
3061    pub fn clear_scopes(mut self) -> CaseCommentGetCall<'a, C> {
3062        self._scopes.clear();
3063        self
3064    }
3065}
3066
3067/// List all the comments associated with a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case/comments" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = ( supportApiService.cases() .comments() .list(parent="projects/some-project/cases/43595344") ) print(request.execute()) ```
3068///
3069/// A builder for the *comments.list* method supported by a *case* resource.
3070/// It is not used directly, but through a [`CaseMethods`] instance.
3071///
3072/// # Example
3073///
3074/// Instantiate a resource method builder
3075///
3076/// ```test_harness,no_run
3077/// # extern crate hyper;
3078/// # extern crate hyper_rustls;
3079/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
3080/// # async fn dox() {
3081/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3082///
3083/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3084/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3085/// #     .with_native_roots()
3086/// #     .unwrap()
3087/// #     .https_only()
3088/// #     .enable_http2()
3089/// #     .build();
3090///
3091/// # let executor = hyper_util::rt::TokioExecutor::new();
3092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3093/// #     secret,
3094/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3095/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3096/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3097/// #     ),
3098/// # ).build().await.unwrap();
3099///
3100/// # let client = hyper_util::client::legacy::Client::builder(
3101/// #     hyper_util::rt::TokioExecutor::new()
3102/// # )
3103/// # .build(
3104/// #     hyper_rustls::HttpsConnectorBuilder::new()
3105/// #         .with_native_roots()
3106/// #         .unwrap()
3107/// #         .https_or_http()
3108/// #         .enable_http2()
3109/// #         .build()
3110/// # );
3111/// # let mut hub = CloudSupport::new(client, auth);
3112/// // You can configure optional parameters by calling the respective setters at will, and
3113/// // execute the final call using `doit()`.
3114/// // Values shown here are possibly random and not representative !
3115/// let result = hub.cases().comments_list("parent")
3116///              .page_token("gubergren")
3117///              .page_size(-16)
3118///              .doit().await;
3119/// # }
3120/// ```
3121pub struct CaseCommentListCall<'a, C>
3122where
3123    C: 'a,
3124{
3125    hub: &'a CloudSupport<C>,
3126    _parent: String,
3127    _page_token: Option<String>,
3128    _page_size: Option<i32>,
3129    _delegate: Option<&'a mut dyn common::Delegate>,
3130    _additional_params: HashMap<String, String>,
3131    _scopes: BTreeSet<String>,
3132}
3133
3134impl<'a, C> common::CallBuilder for CaseCommentListCall<'a, C> {}
3135
3136impl<'a, C> CaseCommentListCall<'a, C>
3137where
3138    C: common::Connector,
3139{
3140    /// Perform the operation you have build so far.
3141    pub async fn doit(mut self) -> common::Result<(common::Response, ListCommentsResponse)> {
3142        use std::borrow::Cow;
3143        use std::io::{Read, Seek};
3144
3145        use common::{url::Params, ToParts};
3146        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3147
3148        let mut dd = common::DefaultDelegate;
3149        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3150        dlg.begin(common::MethodInfo {
3151            id: "cloudsupport.cases.comments.list",
3152            http_method: hyper::Method::GET,
3153        });
3154
3155        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3156            if self._additional_params.contains_key(field) {
3157                dlg.finished(false);
3158                return Err(common::Error::FieldClash(field));
3159            }
3160        }
3161
3162        let mut params = Params::with_capacity(5 + self._additional_params.len());
3163        params.push("parent", self._parent);
3164        if let Some(value) = self._page_token.as_ref() {
3165            params.push("pageToken", value);
3166        }
3167        if let Some(value) = self._page_size.as_ref() {
3168            params.push("pageSize", value.to_string());
3169        }
3170
3171        params.extend(self._additional_params.iter());
3172
3173        params.push("alt", "json");
3174        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}/comments";
3175        if self._scopes.is_empty() {
3176            self._scopes
3177                .insert(Scope::CloudPlatform.as_ref().to_string());
3178        }
3179
3180        #[allow(clippy::single_element_loop)]
3181        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3182            url = params.uri_replacement(url, param_name, find_this, true);
3183        }
3184        {
3185            let to_remove = ["parent"];
3186            params.remove_params(&to_remove);
3187        }
3188
3189        let url = params.parse_with_url(&url);
3190
3191        loop {
3192            let token = match self
3193                .hub
3194                .auth
3195                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3196                .await
3197            {
3198                Ok(token) => token,
3199                Err(e) => match dlg.token(e) {
3200                    Ok(token) => token,
3201                    Err(e) => {
3202                        dlg.finished(false);
3203                        return Err(common::Error::MissingToken(e));
3204                    }
3205                },
3206            };
3207            let mut req_result = {
3208                let client = &self.hub.client;
3209                dlg.pre_request();
3210                let mut req_builder = hyper::Request::builder()
3211                    .method(hyper::Method::GET)
3212                    .uri(url.as_str())
3213                    .header(USER_AGENT, self.hub._user_agent.clone());
3214
3215                if let Some(token) = token.as_ref() {
3216                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3217                }
3218
3219                let request = req_builder
3220                    .header(CONTENT_LENGTH, 0_u64)
3221                    .body(common::to_body::<String>(None));
3222
3223                client.request(request.unwrap()).await
3224            };
3225
3226            match req_result {
3227                Err(err) => {
3228                    if let common::Retry::After(d) = dlg.http_error(&err) {
3229                        sleep(d).await;
3230                        continue;
3231                    }
3232                    dlg.finished(false);
3233                    return Err(common::Error::HttpError(err));
3234                }
3235                Ok(res) => {
3236                    let (mut parts, body) = res.into_parts();
3237                    let mut body = common::Body::new(body);
3238                    if !parts.status.is_success() {
3239                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3240                        let error = serde_json::from_str(&common::to_string(&bytes));
3241                        let response = common::to_response(parts, bytes.into());
3242
3243                        if let common::Retry::After(d) =
3244                            dlg.http_failure(&response, error.as_ref().ok())
3245                        {
3246                            sleep(d).await;
3247                            continue;
3248                        }
3249
3250                        dlg.finished(false);
3251
3252                        return Err(match error {
3253                            Ok(value) => common::Error::BadRequest(value),
3254                            _ => common::Error::Failure(response),
3255                        });
3256                    }
3257                    let response = {
3258                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3259                        let encoded = common::to_string(&bytes);
3260                        match serde_json::from_str(&encoded) {
3261                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3262                            Err(error) => {
3263                                dlg.response_json_decode_error(&encoded, &error);
3264                                return Err(common::Error::JsonDecodeError(
3265                                    encoded.to_string(),
3266                                    error,
3267                                ));
3268                            }
3269                        }
3270                    };
3271
3272                    dlg.finished(true);
3273                    return Ok(response);
3274                }
3275            }
3276        }
3277    }
3278
3279    /// Required. The name of the case for which to list comments.
3280    ///
3281    /// Sets the *parent* path property to the given value.
3282    ///
3283    /// Even though the property as already been set when instantiating this call,
3284    /// we provide this method for API completeness.
3285    pub fn parent(mut self, new_value: &str) -> CaseCommentListCall<'a, C> {
3286        self._parent = new_value.to_string();
3287        self
3288    }
3289    /// A token identifying the page of results to return. If unspecified, the first page is returned.
3290    ///
3291    /// Sets the *page token* query property to the given value.
3292    pub fn page_token(mut self, new_value: &str) -> CaseCommentListCall<'a, C> {
3293        self._page_token = Some(new_value.to_string());
3294        self
3295    }
3296    /// The maximum number of comments to fetch. Defaults to 10.
3297    ///
3298    /// Sets the *page size* query property to the given value.
3299    pub fn page_size(mut self, new_value: i32) -> CaseCommentListCall<'a, C> {
3300        self._page_size = Some(new_value);
3301        self
3302    }
3303    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3304    /// while executing the actual API request.
3305    ///
3306    /// ````text
3307    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3308    /// ````
3309    ///
3310    /// Sets the *delegate* property to the given value.
3311    pub fn delegate(
3312        mut self,
3313        new_value: &'a mut dyn common::Delegate,
3314    ) -> CaseCommentListCall<'a, C> {
3315        self._delegate = Some(new_value);
3316        self
3317    }
3318
3319    /// Set any additional parameter of the query string used in the request.
3320    /// It should be used to set parameters which are not yet available through their own
3321    /// setters.
3322    ///
3323    /// Please note that this method must not be used to set any of the known parameters
3324    /// which have their own setter method. If done anyway, the request will fail.
3325    ///
3326    /// # Additional Parameters
3327    ///
3328    /// * *$.xgafv* (query-string) - V1 error format.
3329    /// * *access_token* (query-string) - OAuth access token.
3330    /// * *alt* (query-string) - Data format for response.
3331    /// * *callback* (query-string) - JSONP
3332    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3333    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3334    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3335    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3336    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3337    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3338    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3339    pub fn param<T>(mut self, name: T, value: T) -> CaseCommentListCall<'a, C>
3340    where
3341        T: AsRef<str>,
3342    {
3343        self._additional_params
3344            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3345        self
3346    }
3347
3348    /// Identifies the authorization scope for the method you are building.
3349    ///
3350    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3351    /// [`Scope::CloudPlatform`].
3352    ///
3353    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3354    /// tokens for more than one scope.
3355    ///
3356    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3357    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3358    /// sufficient, a read-write scope will do as well.
3359    pub fn add_scope<St>(mut self, scope: St) -> CaseCommentListCall<'a, C>
3360    where
3361        St: AsRef<str>,
3362    {
3363        self._scopes.insert(String::from(scope.as_ref()));
3364        self
3365    }
3366    /// Identifies the authorization scope(s) for the method you are building.
3367    ///
3368    /// See [`Self::add_scope()`] for details.
3369    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseCommentListCall<'a, C>
3370    where
3371        I: IntoIterator<Item = St>,
3372        St: AsRef<str>,
3373    {
3374        self._scopes
3375            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3376        self
3377    }
3378
3379    /// Removes all scopes, and no default scope will be used either.
3380    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3381    /// for details).
3382    pub fn clear_scopes(mut self) -> CaseCommentListCall<'a, C> {
3383        self._scopes.clear();
3384        self
3385    }
3386}
3387
3388/// Close a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case:close" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().close( name="projects/some-project/cases/43595344" ) print(request.execute()) ```
3389///
3390/// A builder for the *close* method supported by a *case* resource.
3391/// It is not used directly, but through a [`CaseMethods`] instance.
3392///
3393/// # Example
3394///
3395/// Instantiate a resource method builder
3396///
3397/// ```test_harness,no_run
3398/// # extern crate hyper;
3399/// # extern crate hyper_rustls;
3400/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
3401/// use cloudsupport2_beta::api::CloseCaseRequest;
3402/// # async fn dox() {
3403/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3404///
3405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3407/// #     .with_native_roots()
3408/// #     .unwrap()
3409/// #     .https_only()
3410/// #     .enable_http2()
3411/// #     .build();
3412///
3413/// # let executor = hyper_util::rt::TokioExecutor::new();
3414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3415/// #     secret,
3416/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3417/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3418/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3419/// #     ),
3420/// # ).build().await.unwrap();
3421///
3422/// # let client = hyper_util::client::legacy::Client::builder(
3423/// #     hyper_util::rt::TokioExecutor::new()
3424/// # )
3425/// # .build(
3426/// #     hyper_rustls::HttpsConnectorBuilder::new()
3427/// #         .with_native_roots()
3428/// #         .unwrap()
3429/// #         .https_or_http()
3430/// #         .enable_http2()
3431/// #         .build()
3432/// # );
3433/// # let mut hub = CloudSupport::new(client, auth);
3434/// // As the method needs a request, you would usually fill it with the desired information
3435/// // into the respective structure. Some of the parts shown here might not be applicable !
3436/// // Values shown here are possibly random and not representative !
3437/// let mut req = CloseCaseRequest::default();
3438///
3439/// // You can configure optional parameters by calling the respective setters at will, and
3440/// // execute the final call using `doit()`.
3441/// // Values shown here are possibly random and not representative !
3442/// let result = hub.cases().close(req, "name")
3443///              .doit().await;
3444/// # }
3445/// ```
3446pub struct CaseCloseCall<'a, C>
3447where
3448    C: 'a,
3449{
3450    hub: &'a CloudSupport<C>,
3451    _request: CloseCaseRequest,
3452    _name: String,
3453    _delegate: Option<&'a mut dyn common::Delegate>,
3454    _additional_params: HashMap<String, String>,
3455    _scopes: BTreeSet<String>,
3456}
3457
3458impl<'a, C> common::CallBuilder for CaseCloseCall<'a, C> {}
3459
3460impl<'a, C> CaseCloseCall<'a, C>
3461where
3462    C: common::Connector,
3463{
3464    /// Perform the operation you have build so far.
3465    pub async fn doit(mut self) -> common::Result<(common::Response, Case)> {
3466        use std::borrow::Cow;
3467        use std::io::{Read, Seek};
3468
3469        use common::{url::Params, ToParts};
3470        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3471
3472        let mut dd = common::DefaultDelegate;
3473        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3474        dlg.begin(common::MethodInfo {
3475            id: "cloudsupport.cases.close",
3476            http_method: hyper::Method::POST,
3477        });
3478
3479        for &field in ["alt", "name"].iter() {
3480            if self._additional_params.contains_key(field) {
3481                dlg.finished(false);
3482                return Err(common::Error::FieldClash(field));
3483            }
3484        }
3485
3486        let mut params = Params::with_capacity(4 + self._additional_params.len());
3487        params.push("name", self._name);
3488
3489        params.extend(self._additional_params.iter());
3490
3491        params.push("alt", "json");
3492        let mut url = self.hub._base_url.clone() + "v2beta/{+name}:close";
3493        if self._scopes.is_empty() {
3494            self._scopes
3495                .insert(Scope::CloudPlatform.as_ref().to_string());
3496        }
3497
3498        #[allow(clippy::single_element_loop)]
3499        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3500            url = params.uri_replacement(url, param_name, find_this, true);
3501        }
3502        {
3503            let to_remove = ["name"];
3504            params.remove_params(&to_remove);
3505        }
3506
3507        let url = params.parse_with_url(&url);
3508
3509        let mut json_mime_type = mime::APPLICATION_JSON;
3510        let mut request_value_reader = {
3511            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3512            common::remove_json_null_values(&mut value);
3513            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3514            serde_json::to_writer(&mut dst, &value).unwrap();
3515            dst
3516        };
3517        let request_size = request_value_reader
3518            .seek(std::io::SeekFrom::End(0))
3519            .unwrap();
3520        request_value_reader
3521            .seek(std::io::SeekFrom::Start(0))
3522            .unwrap();
3523
3524        loop {
3525            let token = match self
3526                .hub
3527                .auth
3528                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3529                .await
3530            {
3531                Ok(token) => token,
3532                Err(e) => match dlg.token(e) {
3533                    Ok(token) => token,
3534                    Err(e) => {
3535                        dlg.finished(false);
3536                        return Err(common::Error::MissingToken(e));
3537                    }
3538                },
3539            };
3540            request_value_reader
3541                .seek(std::io::SeekFrom::Start(0))
3542                .unwrap();
3543            let mut req_result = {
3544                let client = &self.hub.client;
3545                dlg.pre_request();
3546                let mut req_builder = hyper::Request::builder()
3547                    .method(hyper::Method::POST)
3548                    .uri(url.as_str())
3549                    .header(USER_AGENT, self.hub._user_agent.clone());
3550
3551                if let Some(token) = token.as_ref() {
3552                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3553                }
3554
3555                let request = req_builder
3556                    .header(CONTENT_TYPE, json_mime_type.to_string())
3557                    .header(CONTENT_LENGTH, request_size as u64)
3558                    .body(common::to_body(
3559                        request_value_reader.get_ref().clone().into(),
3560                    ));
3561
3562                client.request(request.unwrap()).await
3563            };
3564
3565            match req_result {
3566                Err(err) => {
3567                    if let common::Retry::After(d) = dlg.http_error(&err) {
3568                        sleep(d).await;
3569                        continue;
3570                    }
3571                    dlg.finished(false);
3572                    return Err(common::Error::HttpError(err));
3573                }
3574                Ok(res) => {
3575                    let (mut parts, body) = res.into_parts();
3576                    let mut body = common::Body::new(body);
3577                    if !parts.status.is_success() {
3578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3579                        let error = serde_json::from_str(&common::to_string(&bytes));
3580                        let response = common::to_response(parts, bytes.into());
3581
3582                        if let common::Retry::After(d) =
3583                            dlg.http_failure(&response, error.as_ref().ok())
3584                        {
3585                            sleep(d).await;
3586                            continue;
3587                        }
3588
3589                        dlg.finished(false);
3590
3591                        return Err(match error {
3592                            Ok(value) => common::Error::BadRequest(value),
3593                            _ => common::Error::Failure(response),
3594                        });
3595                    }
3596                    let response = {
3597                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3598                        let encoded = common::to_string(&bytes);
3599                        match serde_json::from_str(&encoded) {
3600                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3601                            Err(error) => {
3602                                dlg.response_json_decode_error(&encoded, &error);
3603                                return Err(common::Error::JsonDecodeError(
3604                                    encoded.to_string(),
3605                                    error,
3606                                ));
3607                            }
3608                        }
3609                    };
3610
3611                    dlg.finished(true);
3612                    return Ok(response);
3613                }
3614            }
3615        }
3616    }
3617
3618    ///
3619    /// Sets the *request* property to the given value.
3620    ///
3621    /// Even though the property as already been set when instantiating this call,
3622    /// we provide this method for API completeness.
3623    pub fn request(mut self, new_value: CloseCaseRequest) -> CaseCloseCall<'a, C> {
3624        self._request = new_value;
3625        self
3626    }
3627    /// Required. The name of the case to close.
3628    ///
3629    /// Sets the *name* path property to the given value.
3630    ///
3631    /// Even though the property as already been set when instantiating this call,
3632    /// we provide this method for API completeness.
3633    pub fn name(mut self, new_value: &str) -> CaseCloseCall<'a, C> {
3634        self._name = new_value.to_string();
3635        self
3636    }
3637    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3638    /// while executing the actual API request.
3639    ///
3640    /// ````text
3641    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3642    /// ````
3643    ///
3644    /// Sets the *delegate* property to the given value.
3645    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseCloseCall<'a, C> {
3646        self._delegate = Some(new_value);
3647        self
3648    }
3649
3650    /// Set any additional parameter of the query string used in the request.
3651    /// It should be used to set parameters which are not yet available through their own
3652    /// setters.
3653    ///
3654    /// Please note that this method must not be used to set any of the known parameters
3655    /// which have their own setter method. If done anyway, the request will fail.
3656    ///
3657    /// # Additional Parameters
3658    ///
3659    /// * *$.xgafv* (query-string) - V1 error format.
3660    /// * *access_token* (query-string) - OAuth access token.
3661    /// * *alt* (query-string) - Data format for response.
3662    /// * *callback* (query-string) - JSONP
3663    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3664    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3665    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3666    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3667    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3668    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3669    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3670    pub fn param<T>(mut self, name: T, value: T) -> CaseCloseCall<'a, C>
3671    where
3672        T: AsRef<str>,
3673    {
3674        self._additional_params
3675            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3676        self
3677    }
3678
3679    /// Identifies the authorization scope for the method you are building.
3680    ///
3681    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3682    /// [`Scope::CloudPlatform`].
3683    ///
3684    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3685    /// tokens for more than one scope.
3686    ///
3687    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3688    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3689    /// sufficient, a read-write scope will do as well.
3690    pub fn add_scope<St>(mut self, scope: St) -> CaseCloseCall<'a, C>
3691    where
3692        St: AsRef<str>,
3693    {
3694        self._scopes.insert(String::from(scope.as_ref()));
3695        self
3696    }
3697    /// Identifies the authorization scope(s) for the method you are building.
3698    ///
3699    /// See [`Self::add_scope()`] for details.
3700    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseCloseCall<'a, C>
3701    where
3702        I: IntoIterator<Item = St>,
3703        St: AsRef<str>,
3704    {
3705        self._scopes
3706            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3707        self
3708    }
3709
3710    /// Removes all scopes, and no default scope will be used either.
3711    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3712    /// for details).
3713    pub fn clear_scopes(mut self) -> CaseCloseCall<'a, C> {
3714        self._scopes.clear();
3715        self
3716    }
3717}
3718
3719/// Create a new case and associate it with a parent. It must have the following fields set: `display_name`, `description`, `classification`, and `priority`. If you're just testing the API and don't want to route your case to an agent, set `testCase=true`. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header 'Content-Type: application/json' \ --data '{ "display_name": "Test case created by me.", "description": "a random test case, feel free to close", "classification": { "id": "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" }, "time_zone": "-07:00", "subscriber_email_addresses": [ "foo@domain.com", "bar@domain.com" ], "testCase": true, "priority": "P3" }' \ "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().create( parent="projects/some-project", body={ "displayName": "A Test Case", "description": "This is a test case.", "testCase": True, "priority": "P2", "classification": { "id": "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" }, }, ) print(request.execute()) ```
3720///
3721/// A builder for the *create* method supported by a *case* resource.
3722/// It is not used directly, but through a [`CaseMethods`] instance.
3723///
3724/// # Example
3725///
3726/// Instantiate a resource method builder
3727///
3728/// ```test_harness,no_run
3729/// # extern crate hyper;
3730/// # extern crate hyper_rustls;
3731/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
3732/// use cloudsupport2_beta::api::Case;
3733/// # async fn dox() {
3734/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3735///
3736/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3737/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3738/// #     .with_native_roots()
3739/// #     .unwrap()
3740/// #     .https_only()
3741/// #     .enable_http2()
3742/// #     .build();
3743///
3744/// # let executor = hyper_util::rt::TokioExecutor::new();
3745/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3746/// #     secret,
3747/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3748/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3749/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3750/// #     ),
3751/// # ).build().await.unwrap();
3752///
3753/// # let client = hyper_util::client::legacy::Client::builder(
3754/// #     hyper_util::rt::TokioExecutor::new()
3755/// # )
3756/// # .build(
3757/// #     hyper_rustls::HttpsConnectorBuilder::new()
3758/// #         .with_native_roots()
3759/// #         .unwrap()
3760/// #         .https_or_http()
3761/// #         .enable_http2()
3762/// #         .build()
3763/// # );
3764/// # let mut hub = CloudSupport::new(client, auth);
3765/// // As the method needs a request, you would usually fill it with the desired information
3766/// // into the respective structure. Some of the parts shown here might not be applicable !
3767/// // Values shown here are possibly random and not representative !
3768/// let mut req = Case::default();
3769///
3770/// // You can configure optional parameters by calling the respective setters at will, and
3771/// // execute the final call using `doit()`.
3772/// // Values shown here are possibly random and not representative !
3773/// let result = hub.cases().create(req, "parent")
3774///              .doit().await;
3775/// # }
3776/// ```
3777pub struct CaseCreateCall<'a, C>
3778where
3779    C: 'a,
3780{
3781    hub: &'a CloudSupport<C>,
3782    _request: Case,
3783    _parent: String,
3784    _delegate: Option<&'a mut dyn common::Delegate>,
3785    _additional_params: HashMap<String, String>,
3786    _scopes: BTreeSet<String>,
3787}
3788
3789impl<'a, C> common::CallBuilder for CaseCreateCall<'a, C> {}
3790
3791impl<'a, C> CaseCreateCall<'a, C>
3792where
3793    C: common::Connector,
3794{
3795    /// Perform the operation you have build so far.
3796    pub async fn doit(mut self) -> common::Result<(common::Response, Case)> {
3797        use std::borrow::Cow;
3798        use std::io::{Read, Seek};
3799
3800        use common::{url::Params, ToParts};
3801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3802
3803        let mut dd = common::DefaultDelegate;
3804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3805        dlg.begin(common::MethodInfo {
3806            id: "cloudsupport.cases.create",
3807            http_method: hyper::Method::POST,
3808        });
3809
3810        for &field in ["alt", "parent"].iter() {
3811            if self._additional_params.contains_key(field) {
3812                dlg.finished(false);
3813                return Err(common::Error::FieldClash(field));
3814            }
3815        }
3816
3817        let mut params = Params::with_capacity(4 + self._additional_params.len());
3818        params.push("parent", self._parent);
3819
3820        params.extend(self._additional_params.iter());
3821
3822        params.push("alt", "json");
3823        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}/cases";
3824        if self._scopes.is_empty() {
3825            self._scopes
3826                .insert(Scope::CloudPlatform.as_ref().to_string());
3827        }
3828
3829        #[allow(clippy::single_element_loop)]
3830        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3831            url = params.uri_replacement(url, param_name, find_this, true);
3832        }
3833        {
3834            let to_remove = ["parent"];
3835            params.remove_params(&to_remove);
3836        }
3837
3838        let url = params.parse_with_url(&url);
3839
3840        let mut json_mime_type = mime::APPLICATION_JSON;
3841        let mut request_value_reader = {
3842            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3843            common::remove_json_null_values(&mut value);
3844            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3845            serde_json::to_writer(&mut dst, &value).unwrap();
3846            dst
3847        };
3848        let request_size = request_value_reader
3849            .seek(std::io::SeekFrom::End(0))
3850            .unwrap();
3851        request_value_reader
3852            .seek(std::io::SeekFrom::Start(0))
3853            .unwrap();
3854
3855        loop {
3856            let token = match self
3857                .hub
3858                .auth
3859                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3860                .await
3861            {
3862                Ok(token) => token,
3863                Err(e) => match dlg.token(e) {
3864                    Ok(token) => token,
3865                    Err(e) => {
3866                        dlg.finished(false);
3867                        return Err(common::Error::MissingToken(e));
3868                    }
3869                },
3870            };
3871            request_value_reader
3872                .seek(std::io::SeekFrom::Start(0))
3873                .unwrap();
3874            let mut req_result = {
3875                let client = &self.hub.client;
3876                dlg.pre_request();
3877                let mut req_builder = hyper::Request::builder()
3878                    .method(hyper::Method::POST)
3879                    .uri(url.as_str())
3880                    .header(USER_AGENT, self.hub._user_agent.clone());
3881
3882                if let Some(token) = token.as_ref() {
3883                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3884                }
3885
3886                let request = req_builder
3887                    .header(CONTENT_TYPE, json_mime_type.to_string())
3888                    .header(CONTENT_LENGTH, request_size as u64)
3889                    .body(common::to_body(
3890                        request_value_reader.get_ref().clone().into(),
3891                    ));
3892
3893                client.request(request.unwrap()).await
3894            };
3895
3896            match req_result {
3897                Err(err) => {
3898                    if let common::Retry::After(d) = dlg.http_error(&err) {
3899                        sleep(d).await;
3900                        continue;
3901                    }
3902                    dlg.finished(false);
3903                    return Err(common::Error::HttpError(err));
3904                }
3905                Ok(res) => {
3906                    let (mut parts, body) = res.into_parts();
3907                    let mut body = common::Body::new(body);
3908                    if !parts.status.is_success() {
3909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3910                        let error = serde_json::from_str(&common::to_string(&bytes));
3911                        let response = common::to_response(parts, bytes.into());
3912
3913                        if let common::Retry::After(d) =
3914                            dlg.http_failure(&response, error.as_ref().ok())
3915                        {
3916                            sleep(d).await;
3917                            continue;
3918                        }
3919
3920                        dlg.finished(false);
3921
3922                        return Err(match error {
3923                            Ok(value) => common::Error::BadRequest(value),
3924                            _ => common::Error::Failure(response),
3925                        });
3926                    }
3927                    let response = {
3928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3929                        let encoded = common::to_string(&bytes);
3930                        match serde_json::from_str(&encoded) {
3931                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3932                            Err(error) => {
3933                                dlg.response_json_decode_error(&encoded, &error);
3934                                return Err(common::Error::JsonDecodeError(
3935                                    encoded.to_string(),
3936                                    error,
3937                                ));
3938                            }
3939                        }
3940                    };
3941
3942                    dlg.finished(true);
3943                    return Ok(response);
3944                }
3945            }
3946        }
3947    }
3948
3949    ///
3950    /// Sets the *request* property to the given value.
3951    ///
3952    /// Even though the property as already been set when instantiating this call,
3953    /// we provide this method for API completeness.
3954    pub fn request(mut self, new_value: Case) -> CaseCreateCall<'a, C> {
3955        self._request = new_value;
3956        self
3957    }
3958    /// Required. The name of the parent under which the case should be created.
3959    ///
3960    /// Sets the *parent* path property to the given value.
3961    ///
3962    /// Even though the property as already been set when instantiating this call,
3963    /// we provide this method for API completeness.
3964    pub fn parent(mut self, new_value: &str) -> CaseCreateCall<'a, C> {
3965        self._parent = new_value.to_string();
3966        self
3967    }
3968    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3969    /// while executing the actual API request.
3970    ///
3971    /// ````text
3972    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3973    /// ````
3974    ///
3975    /// Sets the *delegate* property to the given value.
3976    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseCreateCall<'a, C> {
3977        self._delegate = Some(new_value);
3978        self
3979    }
3980
3981    /// Set any additional parameter of the query string used in the request.
3982    /// It should be used to set parameters which are not yet available through their own
3983    /// setters.
3984    ///
3985    /// Please note that this method must not be used to set any of the known parameters
3986    /// which have their own setter method. If done anyway, the request will fail.
3987    ///
3988    /// # Additional Parameters
3989    ///
3990    /// * *$.xgafv* (query-string) - V1 error format.
3991    /// * *access_token* (query-string) - OAuth access token.
3992    /// * *alt* (query-string) - Data format for response.
3993    /// * *callback* (query-string) - JSONP
3994    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3995    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3996    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3997    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3998    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3999    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4000    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4001    pub fn param<T>(mut self, name: T, value: T) -> CaseCreateCall<'a, C>
4002    where
4003        T: AsRef<str>,
4004    {
4005        self._additional_params
4006            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4007        self
4008    }
4009
4010    /// Identifies the authorization scope for the method you are building.
4011    ///
4012    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4013    /// [`Scope::CloudPlatform`].
4014    ///
4015    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4016    /// tokens for more than one scope.
4017    ///
4018    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4019    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4020    /// sufficient, a read-write scope will do as well.
4021    pub fn add_scope<St>(mut self, scope: St) -> CaseCreateCall<'a, C>
4022    where
4023        St: AsRef<str>,
4024    {
4025        self._scopes.insert(String::from(scope.as_ref()));
4026        self
4027    }
4028    /// Identifies the authorization scope(s) for the method you are building.
4029    ///
4030    /// See [`Self::add_scope()`] for details.
4031    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseCreateCall<'a, C>
4032    where
4033        I: IntoIterator<Item = St>,
4034        St: AsRef<str>,
4035    {
4036        self._scopes
4037            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4038        self
4039    }
4040
4041    /// Removes all scopes, and no default scope will be used either.
4042    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4043    /// for details).
4044    pub fn clear_scopes(mut self) -> CaseCreateCall<'a, C> {
4045        self._scopes.clear();
4046        self
4047    }
4048}
4049
4050/// Escalate a case, starting the Google Cloud Support escalation management process. This operation is only available for some support services. Go to https://cloud.google.com/support and look for 'Technical support escalations' in the feature list to find out which ones let you do that. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request POST \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header "Content-Type: application/json" \ --data '{ "escalation": { "reason": "BUSINESS_IMPACT", "justification": "This is a test escalation." } }' \ "https://cloudsupport.googleapis.com/v2/$case:escalate" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().escalate( name="projects/some-project/cases/43595344", body={ "escalation": { "reason": "BUSINESS_IMPACT", "justification": "This is a test escalation.", }, }, ) print(request.execute()) ```
4051///
4052/// A builder for the *escalate* method supported by a *case* resource.
4053/// It is not used directly, but through a [`CaseMethods`] instance.
4054///
4055/// # Example
4056///
4057/// Instantiate a resource method builder
4058///
4059/// ```test_harness,no_run
4060/// # extern crate hyper;
4061/// # extern crate hyper_rustls;
4062/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
4063/// use cloudsupport2_beta::api::EscalateCaseRequest;
4064/// # async fn dox() {
4065/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4066///
4067/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4068/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4069/// #     .with_native_roots()
4070/// #     .unwrap()
4071/// #     .https_only()
4072/// #     .enable_http2()
4073/// #     .build();
4074///
4075/// # let executor = hyper_util::rt::TokioExecutor::new();
4076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4077/// #     secret,
4078/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4079/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4080/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4081/// #     ),
4082/// # ).build().await.unwrap();
4083///
4084/// # let client = hyper_util::client::legacy::Client::builder(
4085/// #     hyper_util::rt::TokioExecutor::new()
4086/// # )
4087/// # .build(
4088/// #     hyper_rustls::HttpsConnectorBuilder::new()
4089/// #         .with_native_roots()
4090/// #         .unwrap()
4091/// #         .https_or_http()
4092/// #         .enable_http2()
4093/// #         .build()
4094/// # );
4095/// # let mut hub = CloudSupport::new(client, auth);
4096/// // As the method needs a request, you would usually fill it with the desired information
4097/// // into the respective structure. Some of the parts shown here might not be applicable !
4098/// // Values shown here are possibly random and not representative !
4099/// let mut req = EscalateCaseRequest::default();
4100///
4101/// // You can configure optional parameters by calling the respective setters at will, and
4102/// // execute the final call using `doit()`.
4103/// // Values shown here are possibly random and not representative !
4104/// let result = hub.cases().escalate(req, "name")
4105///              .doit().await;
4106/// # }
4107/// ```
4108pub struct CaseEscalateCall<'a, C>
4109where
4110    C: 'a,
4111{
4112    hub: &'a CloudSupport<C>,
4113    _request: EscalateCaseRequest,
4114    _name: String,
4115    _delegate: Option<&'a mut dyn common::Delegate>,
4116    _additional_params: HashMap<String, String>,
4117    _scopes: BTreeSet<String>,
4118}
4119
4120impl<'a, C> common::CallBuilder for CaseEscalateCall<'a, C> {}
4121
4122impl<'a, C> CaseEscalateCall<'a, C>
4123where
4124    C: common::Connector,
4125{
4126    /// Perform the operation you have build so far.
4127    pub async fn doit(mut self) -> common::Result<(common::Response, Case)> {
4128        use std::borrow::Cow;
4129        use std::io::{Read, Seek};
4130
4131        use common::{url::Params, ToParts};
4132        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4133
4134        let mut dd = common::DefaultDelegate;
4135        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4136        dlg.begin(common::MethodInfo {
4137            id: "cloudsupport.cases.escalate",
4138            http_method: hyper::Method::POST,
4139        });
4140
4141        for &field in ["alt", "name"].iter() {
4142            if self._additional_params.contains_key(field) {
4143                dlg.finished(false);
4144                return Err(common::Error::FieldClash(field));
4145            }
4146        }
4147
4148        let mut params = Params::with_capacity(4 + self._additional_params.len());
4149        params.push("name", self._name);
4150
4151        params.extend(self._additional_params.iter());
4152
4153        params.push("alt", "json");
4154        let mut url = self.hub._base_url.clone() + "v2beta/{+name}:escalate";
4155        if self._scopes.is_empty() {
4156            self._scopes
4157                .insert(Scope::CloudPlatform.as_ref().to_string());
4158        }
4159
4160        #[allow(clippy::single_element_loop)]
4161        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4162            url = params.uri_replacement(url, param_name, find_this, true);
4163        }
4164        {
4165            let to_remove = ["name"];
4166            params.remove_params(&to_remove);
4167        }
4168
4169        let url = params.parse_with_url(&url);
4170
4171        let mut json_mime_type = mime::APPLICATION_JSON;
4172        let mut request_value_reader = {
4173            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4174            common::remove_json_null_values(&mut value);
4175            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4176            serde_json::to_writer(&mut dst, &value).unwrap();
4177            dst
4178        };
4179        let request_size = request_value_reader
4180            .seek(std::io::SeekFrom::End(0))
4181            .unwrap();
4182        request_value_reader
4183            .seek(std::io::SeekFrom::Start(0))
4184            .unwrap();
4185
4186        loop {
4187            let token = match self
4188                .hub
4189                .auth
4190                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4191                .await
4192            {
4193                Ok(token) => token,
4194                Err(e) => match dlg.token(e) {
4195                    Ok(token) => token,
4196                    Err(e) => {
4197                        dlg.finished(false);
4198                        return Err(common::Error::MissingToken(e));
4199                    }
4200                },
4201            };
4202            request_value_reader
4203                .seek(std::io::SeekFrom::Start(0))
4204                .unwrap();
4205            let mut req_result = {
4206                let client = &self.hub.client;
4207                dlg.pre_request();
4208                let mut req_builder = hyper::Request::builder()
4209                    .method(hyper::Method::POST)
4210                    .uri(url.as_str())
4211                    .header(USER_AGENT, self.hub._user_agent.clone());
4212
4213                if let Some(token) = token.as_ref() {
4214                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4215                }
4216
4217                let request = req_builder
4218                    .header(CONTENT_TYPE, json_mime_type.to_string())
4219                    .header(CONTENT_LENGTH, request_size as u64)
4220                    .body(common::to_body(
4221                        request_value_reader.get_ref().clone().into(),
4222                    ));
4223
4224                client.request(request.unwrap()).await
4225            };
4226
4227            match req_result {
4228                Err(err) => {
4229                    if let common::Retry::After(d) = dlg.http_error(&err) {
4230                        sleep(d).await;
4231                        continue;
4232                    }
4233                    dlg.finished(false);
4234                    return Err(common::Error::HttpError(err));
4235                }
4236                Ok(res) => {
4237                    let (mut parts, body) = res.into_parts();
4238                    let mut body = common::Body::new(body);
4239                    if !parts.status.is_success() {
4240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4241                        let error = serde_json::from_str(&common::to_string(&bytes));
4242                        let response = common::to_response(parts, bytes.into());
4243
4244                        if let common::Retry::After(d) =
4245                            dlg.http_failure(&response, error.as_ref().ok())
4246                        {
4247                            sleep(d).await;
4248                            continue;
4249                        }
4250
4251                        dlg.finished(false);
4252
4253                        return Err(match error {
4254                            Ok(value) => common::Error::BadRequest(value),
4255                            _ => common::Error::Failure(response),
4256                        });
4257                    }
4258                    let response = {
4259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4260                        let encoded = common::to_string(&bytes);
4261                        match serde_json::from_str(&encoded) {
4262                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4263                            Err(error) => {
4264                                dlg.response_json_decode_error(&encoded, &error);
4265                                return Err(common::Error::JsonDecodeError(
4266                                    encoded.to_string(),
4267                                    error,
4268                                ));
4269                            }
4270                        }
4271                    };
4272
4273                    dlg.finished(true);
4274                    return Ok(response);
4275                }
4276            }
4277        }
4278    }
4279
4280    ///
4281    /// Sets the *request* property to the given value.
4282    ///
4283    /// Even though the property as already been set when instantiating this call,
4284    /// we provide this method for API completeness.
4285    pub fn request(mut self, new_value: EscalateCaseRequest) -> CaseEscalateCall<'a, C> {
4286        self._request = new_value;
4287        self
4288    }
4289    /// Required. The name of the case to be escalated.
4290    ///
4291    /// Sets the *name* path property to the given value.
4292    ///
4293    /// Even though the property as already been set when instantiating this call,
4294    /// we provide this method for API completeness.
4295    pub fn name(mut self, new_value: &str) -> CaseEscalateCall<'a, C> {
4296        self._name = new_value.to_string();
4297        self
4298    }
4299    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4300    /// while executing the actual API request.
4301    ///
4302    /// ````text
4303    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4304    /// ````
4305    ///
4306    /// Sets the *delegate* property to the given value.
4307    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseEscalateCall<'a, C> {
4308        self._delegate = Some(new_value);
4309        self
4310    }
4311
4312    /// Set any additional parameter of the query string used in the request.
4313    /// It should be used to set parameters which are not yet available through their own
4314    /// setters.
4315    ///
4316    /// Please note that this method must not be used to set any of the known parameters
4317    /// which have their own setter method. If done anyway, the request will fail.
4318    ///
4319    /// # Additional Parameters
4320    ///
4321    /// * *$.xgafv* (query-string) - V1 error format.
4322    /// * *access_token* (query-string) - OAuth access token.
4323    /// * *alt* (query-string) - Data format for response.
4324    /// * *callback* (query-string) - JSONP
4325    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4326    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4327    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4328    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4329    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4330    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4331    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4332    pub fn param<T>(mut self, name: T, value: T) -> CaseEscalateCall<'a, C>
4333    where
4334        T: AsRef<str>,
4335    {
4336        self._additional_params
4337            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4338        self
4339    }
4340
4341    /// Identifies the authorization scope for the method you are building.
4342    ///
4343    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4344    /// [`Scope::CloudPlatform`].
4345    ///
4346    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4347    /// tokens for more than one scope.
4348    ///
4349    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4350    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4351    /// sufficient, a read-write scope will do as well.
4352    pub fn add_scope<St>(mut self, scope: St) -> CaseEscalateCall<'a, C>
4353    where
4354        St: AsRef<str>,
4355    {
4356        self._scopes.insert(String::from(scope.as_ref()));
4357        self
4358    }
4359    /// Identifies the authorization scope(s) for the method you are building.
4360    ///
4361    /// See [`Self::add_scope()`] for details.
4362    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseEscalateCall<'a, C>
4363    where
4364        I: IntoIterator<Item = St>,
4365        St: AsRef<str>,
4366    {
4367        self._scopes
4368            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4369        self
4370    }
4371
4372    /// Removes all scopes, and no default scope will be used either.
4373    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4374    /// for details).
4375    pub fn clear_scopes(mut self) -> CaseEscalateCall<'a, C> {
4376        self._scopes.clear();
4377        self
4378    }
4379}
4380
4381/// Retrieve a case. EXAMPLES: cURL: ```shell case="projects/some-project/cases/16033687" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$case" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().get( name="projects/some-project/cases/43595344", ) print(request.execute()) ```
4382///
4383/// A builder for the *get* method supported by a *case* resource.
4384/// It is not used directly, but through a [`CaseMethods`] instance.
4385///
4386/// # Example
4387///
4388/// Instantiate a resource method builder
4389///
4390/// ```test_harness,no_run
4391/// # extern crate hyper;
4392/// # extern crate hyper_rustls;
4393/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
4394/// # async fn dox() {
4395/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4396///
4397/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4398/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4399/// #     .with_native_roots()
4400/// #     .unwrap()
4401/// #     .https_only()
4402/// #     .enable_http2()
4403/// #     .build();
4404///
4405/// # let executor = hyper_util::rt::TokioExecutor::new();
4406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4407/// #     secret,
4408/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4409/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4410/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4411/// #     ),
4412/// # ).build().await.unwrap();
4413///
4414/// # let client = hyper_util::client::legacy::Client::builder(
4415/// #     hyper_util::rt::TokioExecutor::new()
4416/// # )
4417/// # .build(
4418/// #     hyper_rustls::HttpsConnectorBuilder::new()
4419/// #         .with_native_roots()
4420/// #         .unwrap()
4421/// #         .https_or_http()
4422/// #         .enable_http2()
4423/// #         .build()
4424/// # );
4425/// # let mut hub = CloudSupport::new(client, auth);
4426/// // You can configure optional parameters by calling the respective setters at will, and
4427/// // execute the final call using `doit()`.
4428/// // Values shown here are possibly random and not representative !
4429/// let result = hub.cases().get("name")
4430///              .doit().await;
4431/// # }
4432/// ```
4433pub struct CaseGetCall<'a, C>
4434where
4435    C: 'a,
4436{
4437    hub: &'a CloudSupport<C>,
4438    _name: String,
4439    _delegate: Option<&'a mut dyn common::Delegate>,
4440    _additional_params: HashMap<String, String>,
4441    _scopes: BTreeSet<String>,
4442}
4443
4444impl<'a, C> common::CallBuilder for CaseGetCall<'a, C> {}
4445
4446impl<'a, C> CaseGetCall<'a, C>
4447where
4448    C: common::Connector,
4449{
4450    /// Perform the operation you have build so far.
4451    pub async fn doit(mut self) -> common::Result<(common::Response, Case)> {
4452        use std::borrow::Cow;
4453        use std::io::{Read, Seek};
4454
4455        use common::{url::Params, ToParts};
4456        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4457
4458        let mut dd = common::DefaultDelegate;
4459        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4460        dlg.begin(common::MethodInfo {
4461            id: "cloudsupport.cases.get",
4462            http_method: hyper::Method::GET,
4463        });
4464
4465        for &field in ["alt", "name"].iter() {
4466            if self._additional_params.contains_key(field) {
4467                dlg.finished(false);
4468                return Err(common::Error::FieldClash(field));
4469            }
4470        }
4471
4472        let mut params = Params::with_capacity(3 + self._additional_params.len());
4473        params.push("name", self._name);
4474
4475        params.extend(self._additional_params.iter());
4476
4477        params.push("alt", "json");
4478        let mut url = self.hub._base_url.clone() + "v2beta/{+name}";
4479        if self._scopes.is_empty() {
4480            self._scopes
4481                .insert(Scope::CloudPlatform.as_ref().to_string());
4482        }
4483
4484        #[allow(clippy::single_element_loop)]
4485        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4486            url = params.uri_replacement(url, param_name, find_this, true);
4487        }
4488        {
4489            let to_remove = ["name"];
4490            params.remove_params(&to_remove);
4491        }
4492
4493        let url = params.parse_with_url(&url);
4494
4495        loop {
4496            let token = match self
4497                .hub
4498                .auth
4499                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4500                .await
4501            {
4502                Ok(token) => token,
4503                Err(e) => match dlg.token(e) {
4504                    Ok(token) => token,
4505                    Err(e) => {
4506                        dlg.finished(false);
4507                        return Err(common::Error::MissingToken(e));
4508                    }
4509                },
4510            };
4511            let mut req_result = {
4512                let client = &self.hub.client;
4513                dlg.pre_request();
4514                let mut req_builder = hyper::Request::builder()
4515                    .method(hyper::Method::GET)
4516                    .uri(url.as_str())
4517                    .header(USER_AGENT, self.hub._user_agent.clone());
4518
4519                if let Some(token) = token.as_ref() {
4520                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4521                }
4522
4523                let request = req_builder
4524                    .header(CONTENT_LENGTH, 0_u64)
4525                    .body(common::to_body::<String>(None));
4526
4527                client.request(request.unwrap()).await
4528            };
4529
4530            match req_result {
4531                Err(err) => {
4532                    if let common::Retry::After(d) = dlg.http_error(&err) {
4533                        sleep(d).await;
4534                        continue;
4535                    }
4536                    dlg.finished(false);
4537                    return Err(common::Error::HttpError(err));
4538                }
4539                Ok(res) => {
4540                    let (mut parts, body) = res.into_parts();
4541                    let mut body = common::Body::new(body);
4542                    if !parts.status.is_success() {
4543                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4544                        let error = serde_json::from_str(&common::to_string(&bytes));
4545                        let response = common::to_response(parts, bytes.into());
4546
4547                        if let common::Retry::After(d) =
4548                            dlg.http_failure(&response, error.as_ref().ok())
4549                        {
4550                            sleep(d).await;
4551                            continue;
4552                        }
4553
4554                        dlg.finished(false);
4555
4556                        return Err(match error {
4557                            Ok(value) => common::Error::BadRequest(value),
4558                            _ => common::Error::Failure(response),
4559                        });
4560                    }
4561                    let response = {
4562                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4563                        let encoded = common::to_string(&bytes);
4564                        match serde_json::from_str(&encoded) {
4565                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4566                            Err(error) => {
4567                                dlg.response_json_decode_error(&encoded, &error);
4568                                return Err(common::Error::JsonDecodeError(
4569                                    encoded.to_string(),
4570                                    error,
4571                                ));
4572                            }
4573                        }
4574                    };
4575
4576                    dlg.finished(true);
4577                    return Ok(response);
4578                }
4579            }
4580        }
4581    }
4582
4583    /// Required. The full name of a case to be retrieved.
4584    ///
4585    /// Sets the *name* path property to the given value.
4586    ///
4587    /// Even though the property as already been set when instantiating this call,
4588    /// we provide this method for API completeness.
4589    pub fn name(mut self, new_value: &str) -> CaseGetCall<'a, C> {
4590        self._name = new_value.to_string();
4591        self
4592    }
4593    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4594    /// while executing the actual API request.
4595    ///
4596    /// ````text
4597    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4598    /// ````
4599    ///
4600    /// Sets the *delegate* property to the given value.
4601    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseGetCall<'a, C> {
4602        self._delegate = Some(new_value);
4603        self
4604    }
4605
4606    /// Set any additional parameter of the query string used in the request.
4607    /// It should be used to set parameters which are not yet available through their own
4608    /// setters.
4609    ///
4610    /// Please note that this method must not be used to set any of the known parameters
4611    /// which have their own setter method. If done anyway, the request will fail.
4612    ///
4613    /// # Additional Parameters
4614    ///
4615    /// * *$.xgafv* (query-string) - V1 error format.
4616    /// * *access_token* (query-string) - OAuth access token.
4617    /// * *alt* (query-string) - Data format for response.
4618    /// * *callback* (query-string) - JSONP
4619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4620    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4621    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4622    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4623    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4624    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4625    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4626    pub fn param<T>(mut self, name: T, value: T) -> CaseGetCall<'a, C>
4627    where
4628        T: AsRef<str>,
4629    {
4630        self._additional_params
4631            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4632        self
4633    }
4634
4635    /// Identifies the authorization scope for the method you are building.
4636    ///
4637    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4638    /// [`Scope::CloudPlatform`].
4639    ///
4640    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4641    /// tokens for more than one scope.
4642    ///
4643    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4644    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4645    /// sufficient, a read-write scope will do as well.
4646    pub fn add_scope<St>(mut self, scope: St) -> CaseGetCall<'a, C>
4647    where
4648        St: AsRef<str>,
4649    {
4650        self._scopes.insert(String::from(scope.as_ref()));
4651        self
4652    }
4653    /// Identifies the authorization scope(s) for the method you are building.
4654    ///
4655    /// See [`Self::add_scope()`] for details.
4656    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseGetCall<'a, C>
4657    where
4658        I: IntoIterator<Item = St>,
4659        St: AsRef<str>,
4660    {
4661        self._scopes
4662            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4663        self
4664    }
4665
4666    /// Removes all scopes, and no default scope will be used either.
4667    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4668    /// for details).
4669    pub fn clear_scopes(mut self) -> CaseGetCall<'a, C> {
4670        self._scopes.clear();
4671        self
4672    }
4673}
4674
4675/// Retrieve all cases under a parent, but not its children. For example, listing cases under an organization only returns the cases that are directly parented by that organization. To retrieve cases under an organization and its projects, use `cases.search`. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().list(parent="projects/some-project") print(request.execute()) ```
4676///
4677/// A builder for the *list* method supported by a *case* resource.
4678/// It is not used directly, but through a [`CaseMethods`] instance.
4679///
4680/// # Example
4681///
4682/// Instantiate a resource method builder
4683///
4684/// ```test_harness,no_run
4685/// # extern crate hyper;
4686/// # extern crate hyper_rustls;
4687/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
4688/// # async fn dox() {
4689/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4690///
4691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4693/// #     .with_native_roots()
4694/// #     .unwrap()
4695/// #     .https_only()
4696/// #     .enable_http2()
4697/// #     .build();
4698///
4699/// # let executor = hyper_util::rt::TokioExecutor::new();
4700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4701/// #     secret,
4702/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4703/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4704/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4705/// #     ),
4706/// # ).build().await.unwrap();
4707///
4708/// # let client = hyper_util::client::legacy::Client::builder(
4709/// #     hyper_util::rt::TokioExecutor::new()
4710/// # )
4711/// # .build(
4712/// #     hyper_rustls::HttpsConnectorBuilder::new()
4713/// #         .with_native_roots()
4714/// #         .unwrap()
4715/// #         .https_or_http()
4716/// #         .enable_http2()
4717/// #         .build()
4718/// # );
4719/// # let mut hub = CloudSupport::new(client, auth);
4720/// // You can configure optional parameters by calling the respective setters at will, and
4721/// // execute the final call using `doit()`.
4722/// // Values shown here are possibly random and not representative !
4723/// let result = hub.cases().list("parent")
4724///              .product_line("ea")
4725///              .page_token("dolor")
4726///              .page_size(-56)
4727///              .filter("eos")
4728///              .doit().await;
4729/// # }
4730/// ```
4731pub struct CaseListCall<'a, C>
4732where
4733    C: 'a,
4734{
4735    hub: &'a CloudSupport<C>,
4736    _parent: String,
4737    _product_line: Option<String>,
4738    _page_token: Option<String>,
4739    _page_size: Option<i32>,
4740    _filter: Option<String>,
4741    _delegate: Option<&'a mut dyn common::Delegate>,
4742    _additional_params: HashMap<String, String>,
4743    _scopes: BTreeSet<String>,
4744}
4745
4746impl<'a, C> common::CallBuilder for CaseListCall<'a, C> {}
4747
4748impl<'a, C> CaseListCall<'a, C>
4749where
4750    C: common::Connector,
4751{
4752    /// Perform the operation you have build so far.
4753    pub async fn doit(mut self) -> common::Result<(common::Response, ListCasesResponse)> {
4754        use std::borrow::Cow;
4755        use std::io::{Read, Seek};
4756
4757        use common::{url::Params, ToParts};
4758        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4759
4760        let mut dd = common::DefaultDelegate;
4761        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4762        dlg.begin(common::MethodInfo {
4763            id: "cloudsupport.cases.list",
4764            http_method: hyper::Method::GET,
4765        });
4766
4767        for &field in [
4768            "alt",
4769            "parent",
4770            "productLine",
4771            "pageToken",
4772            "pageSize",
4773            "filter",
4774        ]
4775        .iter()
4776        {
4777            if self._additional_params.contains_key(field) {
4778                dlg.finished(false);
4779                return Err(common::Error::FieldClash(field));
4780            }
4781        }
4782
4783        let mut params = Params::with_capacity(7 + self._additional_params.len());
4784        params.push("parent", self._parent);
4785        if let Some(value) = self._product_line.as_ref() {
4786            params.push("productLine", value);
4787        }
4788        if let Some(value) = self._page_token.as_ref() {
4789            params.push("pageToken", value);
4790        }
4791        if let Some(value) = self._page_size.as_ref() {
4792            params.push("pageSize", value.to_string());
4793        }
4794        if let Some(value) = self._filter.as_ref() {
4795            params.push("filter", value);
4796        }
4797
4798        params.extend(self._additional_params.iter());
4799
4800        params.push("alt", "json");
4801        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}/cases";
4802        if self._scopes.is_empty() {
4803            self._scopes
4804                .insert(Scope::CloudPlatform.as_ref().to_string());
4805        }
4806
4807        #[allow(clippy::single_element_loop)]
4808        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4809            url = params.uri_replacement(url, param_name, find_this, true);
4810        }
4811        {
4812            let to_remove = ["parent"];
4813            params.remove_params(&to_remove);
4814        }
4815
4816        let url = params.parse_with_url(&url);
4817
4818        loop {
4819            let token = match self
4820                .hub
4821                .auth
4822                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4823                .await
4824            {
4825                Ok(token) => token,
4826                Err(e) => match dlg.token(e) {
4827                    Ok(token) => token,
4828                    Err(e) => {
4829                        dlg.finished(false);
4830                        return Err(common::Error::MissingToken(e));
4831                    }
4832                },
4833            };
4834            let mut req_result = {
4835                let client = &self.hub.client;
4836                dlg.pre_request();
4837                let mut req_builder = hyper::Request::builder()
4838                    .method(hyper::Method::GET)
4839                    .uri(url.as_str())
4840                    .header(USER_AGENT, self.hub._user_agent.clone());
4841
4842                if let Some(token) = token.as_ref() {
4843                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4844                }
4845
4846                let request = req_builder
4847                    .header(CONTENT_LENGTH, 0_u64)
4848                    .body(common::to_body::<String>(None));
4849
4850                client.request(request.unwrap()).await
4851            };
4852
4853            match req_result {
4854                Err(err) => {
4855                    if let common::Retry::After(d) = dlg.http_error(&err) {
4856                        sleep(d).await;
4857                        continue;
4858                    }
4859                    dlg.finished(false);
4860                    return Err(common::Error::HttpError(err));
4861                }
4862                Ok(res) => {
4863                    let (mut parts, body) = res.into_parts();
4864                    let mut body = common::Body::new(body);
4865                    if !parts.status.is_success() {
4866                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4867                        let error = serde_json::from_str(&common::to_string(&bytes));
4868                        let response = common::to_response(parts, bytes.into());
4869
4870                        if let common::Retry::After(d) =
4871                            dlg.http_failure(&response, error.as_ref().ok())
4872                        {
4873                            sleep(d).await;
4874                            continue;
4875                        }
4876
4877                        dlg.finished(false);
4878
4879                        return Err(match error {
4880                            Ok(value) => common::Error::BadRequest(value),
4881                            _ => common::Error::Failure(response),
4882                        });
4883                    }
4884                    let response = {
4885                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4886                        let encoded = common::to_string(&bytes);
4887                        match serde_json::from_str(&encoded) {
4888                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4889                            Err(error) => {
4890                                dlg.response_json_decode_error(&encoded, &error);
4891                                return Err(common::Error::JsonDecodeError(
4892                                    encoded.to_string(),
4893                                    error,
4894                                ));
4895                            }
4896                        }
4897                    };
4898
4899                    dlg.finished(true);
4900                    return Ok(response);
4901                }
4902            }
4903        }
4904    }
4905
4906    /// Required. The name of a parent to list cases under.
4907    ///
4908    /// Sets the *parent* path property to the given value.
4909    ///
4910    /// Even though the property as already been set when instantiating this call,
4911    /// we provide this method for API completeness.
4912    pub fn parent(mut self, new_value: &str) -> CaseListCall<'a, C> {
4913        self._parent = new_value.to_string();
4914        self
4915    }
4916    /// The product line to request cases for. If unspecified, only Google Cloud cases will be returned.
4917    ///
4918    /// Sets the *product line* query property to the given value.
4919    pub fn product_line(mut self, new_value: &str) -> CaseListCall<'a, C> {
4920        self._product_line = Some(new_value.to_string());
4921        self
4922    }
4923    /// A token identifying the page of results to return. If unspecified, the first page is retrieved.
4924    ///
4925    /// Sets the *page token* query property to the given value.
4926    pub fn page_token(mut self, new_value: &str) -> CaseListCall<'a, C> {
4927        self._page_token = Some(new_value.to_string());
4928        self
4929    }
4930    /// The maximum number of cases fetched with each request. Defaults to 10.
4931    ///
4932    /// Sets the *page size* query property to the given value.
4933    pub fn page_size(mut self, new_value: i32) -> CaseListCall<'a, C> {
4934        self._page_size = Some(new_value);
4935        self
4936    }
4937    /// An expression used to filter cases. If it's an empty string, then no filtering happens. Otherwise, the endpoint returns the cases that match the filter. Expressions use the following fields separated by `AND` and specified with `=`: - `state`: Can be `OPEN` or `CLOSED`. - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You can specify multiple values for priority using the `OR` operator. For example, `priority=P1 OR priority=P2`. - `creator.email`: The email address of the case creator. EXAMPLES: - `state=CLOSED` - `state=OPEN AND creator.email="tester@example.com"` - `state=OPEN AND (priority=P0 OR priority=P1)`
4938    ///
4939    /// Sets the *filter* query property to the given value.
4940    pub fn filter(mut self, new_value: &str) -> CaseListCall<'a, C> {
4941        self._filter = Some(new_value.to_string());
4942        self
4943    }
4944    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4945    /// while executing the actual API request.
4946    ///
4947    /// ````text
4948    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4949    /// ````
4950    ///
4951    /// Sets the *delegate* property to the given value.
4952    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseListCall<'a, C> {
4953        self._delegate = Some(new_value);
4954        self
4955    }
4956
4957    /// Set any additional parameter of the query string used in the request.
4958    /// It should be used to set parameters which are not yet available through their own
4959    /// setters.
4960    ///
4961    /// Please note that this method must not be used to set any of the known parameters
4962    /// which have their own setter method. If done anyway, the request will fail.
4963    ///
4964    /// # Additional Parameters
4965    ///
4966    /// * *$.xgafv* (query-string) - V1 error format.
4967    /// * *access_token* (query-string) - OAuth access token.
4968    /// * *alt* (query-string) - Data format for response.
4969    /// * *callback* (query-string) - JSONP
4970    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4971    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4972    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4973    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4974    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4975    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4976    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4977    pub fn param<T>(mut self, name: T, value: T) -> CaseListCall<'a, C>
4978    where
4979        T: AsRef<str>,
4980    {
4981        self._additional_params
4982            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4983        self
4984    }
4985
4986    /// Identifies the authorization scope for the method you are building.
4987    ///
4988    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4989    /// [`Scope::CloudPlatform`].
4990    ///
4991    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4992    /// tokens for more than one scope.
4993    ///
4994    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4995    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4996    /// sufficient, a read-write scope will do as well.
4997    pub fn add_scope<St>(mut self, scope: St) -> CaseListCall<'a, C>
4998    where
4999        St: AsRef<str>,
5000    {
5001        self._scopes.insert(String::from(scope.as_ref()));
5002        self
5003    }
5004    /// Identifies the authorization scope(s) for the method you are building.
5005    ///
5006    /// See [`Self::add_scope()`] for details.
5007    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseListCall<'a, C>
5008    where
5009        I: IntoIterator<Item = St>,
5010        St: AsRef<str>,
5011    {
5012        self._scopes
5013            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5014        self
5015    }
5016
5017    /// Removes all scopes, and no default scope will be used either.
5018    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5019    /// for details).
5020    pub fn clear_scopes(mut self) -> CaseListCall<'a, C> {
5021        self._scopes.clear();
5022        self
5023    }
5024}
5025
5026/// Update a case. Only some fields can be updated. EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ --request PATCH \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --header "Content-Type: application/json" \ --data '{ "priority": "P1" }' \ "https://cloudsupport.googleapis.com/v2/$case?updateMask=priority" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().patch( name="projects/some-project/cases/43112854", body={ "displayName": "This is Now a New Title", "priority": "P2", }, ) print(request.execute()) ```
5027///
5028/// A builder for the *patch* method supported by a *case* resource.
5029/// It is not used directly, but through a [`CaseMethods`] instance.
5030///
5031/// # Example
5032///
5033/// Instantiate a resource method builder
5034///
5035/// ```test_harness,no_run
5036/// # extern crate hyper;
5037/// # extern crate hyper_rustls;
5038/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
5039/// use cloudsupport2_beta::api::Case;
5040/// # async fn dox() {
5041/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5042///
5043/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5044/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5045/// #     .with_native_roots()
5046/// #     .unwrap()
5047/// #     .https_only()
5048/// #     .enable_http2()
5049/// #     .build();
5050///
5051/// # let executor = hyper_util::rt::TokioExecutor::new();
5052/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5053/// #     secret,
5054/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5055/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5056/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5057/// #     ),
5058/// # ).build().await.unwrap();
5059///
5060/// # let client = hyper_util::client::legacy::Client::builder(
5061/// #     hyper_util::rt::TokioExecutor::new()
5062/// # )
5063/// # .build(
5064/// #     hyper_rustls::HttpsConnectorBuilder::new()
5065/// #         .with_native_roots()
5066/// #         .unwrap()
5067/// #         .https_or_http()
5068/// #         .enable_http2()
5069/// #         .build()
5070/// # );
5071/// # let mut hub = CloudSupport::new(client, auth);
5072/// // As the method needs a request, you would usually fill it with the desired information
5073/// // into the respective structure. Some of the parts shown here might not be applicable !
5074/// // Values shown here are possibly random and not representative !
5075/// let mut req = Case::default();
5076///
5077/// // You can configure optional parameters by calling the respective setters at will, and
5078/// // execute the final call using `doit()`.
5079/// // Values shown here are possibly random and not representative !
5080/// let result = hub.cases().patch(req, "name")
5081///              .update_mask(FieldMask::new::<&str>(&[]))
5082///              .doit().await;
5083/// # }
5084/// ```
5085pub struct CasePatchCall<'a, C>
5086where
5087    C: 'a,
5088{
5089    hub: &'a CloudSupport<C>,
5090    _request: Case,
5091    _name: String,
5092    _update_mask: Option<common::FieldMask>,
5093    _delegate: Option<&'a mut dyn common::Delegate>,
5094    _additional_params: HashMap<String, String>,
5095    _scopes: BTreeSet<String>,
5096}
5097
5098impl<'a, C> common::CallBuilder for CasePatchCall<'a, C> {}
5099
5100impl<'a, C> CasePatchCall<'a, C>
5101where
5102    C: common::Connector,
5103{
5104    /// Perform the operation you have build so far.
5105    pub async fn doit(mut self) -> common::Result<(common::Response, Case)> {
5106        use std::borrow::Cow;
5107        use std::io::{Read, Seek};
5108
5109        use common::{url::Params, ToParts};
5110        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5111
5112        let mut dd = common::DefaultDelegate;
5113        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5114        dlg.begin(common::MethodInfo {
5115            id: "cloudsupport.cases.patch",
5116            http_method: hyper::Method::PATCH,
5117        });
5118
5119        for &field in ["alt", "name", "updateMask"].iter() {
5120            if self._additional_params.contains_key(field) {
5121                dlg.finished(false);
5122                return Err(common::Error::FieldClash(field));
5123            }
5124        }
5125
5126        let mut params = Params::with_capacity(5 + self._additional_params.len());
5127        params.push("name", self._name);
5128        if let Some(value) = self._update_mask.as_ref() {
5129            params.push("updateMask", value.to_string());
5130        }
5131
5132        params.extend(self._additional_params.iter());
5133
5134        params.push("alt", "json");
5135        let mut url = self.hub._base_url.clone() + "v2beta/{+name}";
5136        if self._scopes.is_empty() {
5137            self._scopes
5138                .insert(Scope::CloudPlatform.as_ref().to_string());
5139        }
5140
5141        #[allow(clippy::single_element_loop)]
5142        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5143            url = params.uri_replacement(url, param_name, find_this, true);
5144        }
5145        {
5146            let to_remove = ["name"];
5147            params.remove_params(&to_remove);
5148        }
5149
5150        let url = params.parse_with_url(&url);
5151
5152        let mut json_mime_type = mime::APPLICATION_JSON;
5153        let mut request_value_reader = {
5154            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5155            common::remove_json_null_values(&mut value);
5156            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5157            serde_json::to_writer(&mut dst, &value).unwrap();
5158            dst
5159        };
5160        let request_size = request_value_reader
5161            .seek(std::io::SeekFrom::End(0))
5162            .unwrap();
5163        request_value_reader
5164            .seek(std::io::SeekFrom::Start(0))
5165            .unwrap();
5166
5167        loop {
5168            let token = match self
5169                .hub
5170                .auth
5171                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5172                .await
5173            {
5174                Ok(token) => token,
5175                Err(e) => match dlg.token(e) {
5176                    Ok(token) => token,
5177                    Err(e) => {
5178                        dlg.finished(false);
5179                        return Err(common::Error::MissingToken(e));
5180                    }
5181                },
5182            };
5183            request_value_reader
5184                .seek(std::io::SeekFrom::Start(0))
5185                .unwrap();
5186            let mut req_result = {
5187                let client = &self.hub.client;
5188                dlg.pre_request();
5189                let mut req_builder = hyper::Request::builder()
5190                    .method(hyper::Method::PATCH)
5191                    .uri(url.as_str())
5192                    .header(USER_AGENT, self.hub._user_agent.clone());
5193
5194                if let Some(token) = token.as_ref() {
5195                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5196                }
5197
5198                let request = req_builder
5199                    .header(CONTENT_TYPE, json_mime_type.to_string())
5200                    .header(CONTENT_LENGTH, request_size as u64)
5201                    .body(common::to_body(
5202                        request_value_reader.get_ref().clone().into(),
5203                    ));
5204
5205                client.request(request.unwrap()).await
5206            };
5207
5208            match req_result {
5209                Err(err) => {
5210                    if let common::Retry::After(d) = dlg.http_error(&err) {
5211                        sleep(d).await;
5212                        continue;
5213                    }
5214                    dlg.finished(false);
5215                    return Err(common::Error::HttpError(err));
5216                }
5217                Ok(res) => {
5218                    let (mut parts, body) = res.into_parts();
5219                    let mut body = common::Body::new(body);
5220                    if !parts.status.is_success() {
5221                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5222                        let error = serde_json::from_str(&common::to_string(&bytes));
5223                        let response = common::to_response(parts, bytes.into());
5224
5225                        if let common::Retry::After(d) =
5226                            dlg.http_failure(&response, error.as_ref().ok())
5227                        {
5228                            sleep(d).await;
5229                            continue;
5230                        }
5231
5232                        dlg.finished(false);
5233
5234                        return Err(match error {
5235                            Ok(value) => common::Error::BadRequest(value),
5236                            _ => common::Error::Failure(response),
5237                        });
5238                    }
5239                    let response = {
5240                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5241                        let encoded = common::to_string(&bytes);
5242                        match serde_json::from_str(&encoded) {
5243                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5244                            Err(error) => {
5245                                dlg.response_json_decode_error(&encoded, &error);
5246                                return Err(common::Error::JsonDecodeError(
5247                                    encoded.to_string(),
5248                                    error,
5249                                ));
5250                            }
5251                        }
5252                    };
5253
5254                    dlg.finished(true);
5255                    return Ok(response);
5256                }
5257            }
5258        }
5259    }
5260
5261    ///
5262    /// Sets the *request* property to the given value.
5263    ///
5264    /// Even though the property as already been set when instantiating this call,
5265    /// we provide this method for API completeness.
5266    pub fn request(mut self, new_value: Case) -> CasePatchCall<'a, C> {
5267        self._request = new_value;
5268        self
5269    }
5270    /// Identifier. The resource name for the case.
5271    ///
5272    /// Sets the *name* path property to the given value.
5273    ///
5274    /// Even though the property as already been set when instantiating this call,
5275    /// we provide this method for API completeness.
5276    pub fn name(mut self, new_value: &str) -> CasePatchCall<'a, C> {
5277        self._name = new_value.to_string();
5278        self
5279    }
5280    /// A list of attributes of the case that should be updated. Supported values are `priority`, `display_name`, and `subscriber_email_addresses`. If no fields are specified, all supported fields are updated. Be careful - if you do not provide a field mask, then you might accidentally clear some fields. For example, if you leave the field mask empty and do not provide a value for `subscriber_email_addresses`, then `subscriber_email_addresses` is updated to empty.
5281    ///
5282    /// Sets the *update mask* query property to the given value.
5283    pub fn update_mask(mut self, new_value: common::FieldMask) -> CasePatchCall<'a, C> {
5284        self._update_mask = Some(new_value);
5285        self
5286    }
5287    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5288    /// while executing the actual API request.
5289    ///
5290    /// ````text
5291    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5292    /// ````
5293    ///
5294    /// Sets the *delegate* property to the given value.
5295    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CasePatchCall<'a, C> {
5296        self._delegate = Some(new_value);
5297        self
5298    }
5299
5300    /// Set any additional parameter of the query string used in the request.
5301    /// It should be used to set parameters which are not yet available through their own
5302    /// setters.
5303    ///
5304    /// Please note that this method must not be used to set any of the known parameters
5305    /// which have their own setter method. If done anyway, the request will fail.
5306    ///
5307    /// # Additional Parameters
5308    ///
5309    /// * *$.xgafv* (query-string) - V1 error format.
5310    /// * *access_token* (query-string) - OAuth access token.
5311    /// * *alt* (query-string) - Data format for response.
5312    /// * *callback* (query-string) - JSONP
5313    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5314    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5315    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5316    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5317    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5318    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5319    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5320    pub fn param<T>(mut self, name: T, value: T) -> CasePatchCall<'a, C>
5321    where
5322        T: AsRef<str>,
5323    {
5324        self._additional_params
5325            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5326        self
5327    }
5328
5329    /// Identifies the authorization scope for the method you are building.
5330    ///
5331    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5332    /// [`Scope::CloudPlatform`].
5333    ///
5334    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5335    /// tokens for more than one scope.
5336    ///
5337    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5338    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5339    /// sufficient, a read-write scope will do as well.
5340    pub fn add_scope<St>(mut self, scope: St) -> CasePatchCall<'a, C>
5341    where
5342        St: AsRef<str>,
5343    {
5344        self._scopes.insert(String::from(scope.as_ref()));
5345        self
5346    }
5347    /// Identifies the authorization scope(s) for the method you are building.
5348    ///
5349    /// See [`Self::add_scope()`] for details.
5350    pub fn add_scopes<I, St>(mut self, scopes: I) -> CasePatchCall<'a, C>
5351    where
5352        I: IntoIterator<Item = St>,
5353        St: AsRef<str>,
5354    {
5355        self._scopes
5356            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5357        self
5358    }
5359
5360    /// Removes all scopes, and no default scope will be used either.
5361    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5362    /// for details).
5363    pub fn clear_scopes(mut self) -> CasePatchCall<'a, C> {
5364        self._scopes.clear();
5365        self
5366    }
5367}
5368
5369/// Search for cases using a query. EXAMPLES: cURL: ```shell parent="projects/some-project" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$parent/cases:search" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.cases().search( parent="projects/some-project", query="state=OPEN" ) print(request.execute()) ```
5370///
5371/// A builder for the *search* method supported by a *case* resource.
5372/// It is not used directly, but through a [`CaseMethods`] instance.
5373///
5374/// # Example
5375///
5376/// Instantiate a resource method builder
5377///
5378/// ```test_harness,no_run
5379/// # extern crate hyper;
5380/// # extern crate hyper_rustls;
5381/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
5382/// # async fn dox() {
5383/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5384///
5385/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5386/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5387/// #     .with_native_roots()
5388/// #     .unwrap()
5389/// #     .https_only()
5390/// #     .enable_http2()
5391/// #     .build();
5392///
5393/// # let executor = hyper_util::rt::TokioExecutor::new();
5394/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5395/// #     secret,
5396/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5397/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5398/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5399/// #     ),
5400/// # ).build().await.unwrap();
5401///
5402/// # let client = hyper_util::client::legacy::Client::builder(
5403/// #     hyper_util::rt::TokioExecutor::new()
5404/// # )
5405/// # .build(
5406/// #     hyper_rustls::HttpsConnectorBuilder::new()
5407/// #         .with_native_roots()
5408/// #         .unwrap()
5409/// #         .https_or_http()
5410/// #         .enable_http2()
5411/// #         .build()
5412/// # );
5413/// # let mut hub = CloudSupport::new(client, auth);
5414/// // You can configure optional parameters by calling the respective setters at will, and
5415/// // execute the final call using `doit()`.
5416/// // Values shown here are possibly random and not representative !
5417/// let result = hub.cases().search()
5418///              .query("sed")
5419///              .parent("duo")
5420///              .page_token("sed")
5421///              .page_size(-61)
5422///              .doit().await;
5423/// # }
5424/// ```
5425pub struct CaseSearchCall<'a, C>
5426where
5427    C: 'a,
5428{
5429    hub: &'a CloudSupport<C>,
5430    _query: Option<String>,
5431    _parent: Option<String>,
5432    _page_token: Option<String>,
5433    _page_size: Option<i32>,
5434    _delegate: Option<&'a mut dyn common::Delegate>,
5435    _additional_params: HashMap<String, String>,
5436    _scopes: BTreeSet<String>,
5437}
5438
5439impl<'a, C> common::CallBuilder for CaseSearchCall<'a, C> {}
5440
5441impl<'a, C> CaseSearchCall<'a, C>
5442where
5443    C: common::Connector,
5444{
5445    /// Perform the operation you have build so far.
5446    pub async fn doit(mut self) -> common::Result<(common::Response, SearchCasesResponse)> {
5447        use std::borrow::Cow;
5448        use std::io::{Read, Seek};
5449
5450        use common::{url::Params, ToParts};
5451        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5452
5453        let mut dd = common::DefaultDelegate;
5454        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5455        dlg.begin(common::MethodInfo {
5456            id: "cloudsupport.cases.search",
5457            http_method: hyper::Method::GET,
5458        });
5459
5460        for &field in ["alt", "query", "parent", "pageToken", "pageSize"].iter() {
5461            if self._additional_params.contains_key(field) {
5462                dlg.finished(false);
5463                return Err(common::Error::FieldClash(field));
5464            }
5465        }
5466
5467        let mut params = Params::with_capacity(6 + self._additional_params.len());
5468        if let Some(value) = self._query.as_ref() {
5469            params.push("query", value);
5470        }
5471        if let Some(value) = self._parent.as_ref() {
5472            params.push("parent", value);
5473        }
5474        if let Some(value) = self._page_token.as_ref() {
5475            params.push("pageToken", value);
5476        }
5477        if let Some(value) = self._page_size.as_ref() {
5478            params.push("pageSize", value.to_string());
5479        }
5480
5481        params.extend(self._additional_params.iter());
5482
5483        params.push("alt", "json");
5484        let mut url = self.hub._base_url.clone() + "v2beta/cases:search";
5485        if self._scopes.is_empty() {
5486            self._scopes
5487                .insert(Scope::CloudPlatform.as_ref().to_string());
5488        }
5489
5490        let url = params.parse_with_url(&url);
5491
5492        loop {
5493            let token = match self
5494                .hub
5495                .auth
5496                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5497                .await
5498            {
5499                Ok(token) => token,
5500                Err(e) => match dlg.token(e) {
5501                    Ok(token) => token,
5502                    Err(e) => {
5503                        dlg.finished(false);
5504                        return Err(common::Error::MissingToken(e));
5505                    }
5506                },
5507            };
5508            let mut req_result = {
5509                let client = &self.hub.client;
5510                dlg.pre_request();
5511                let mut req_builder = hyper::Request::builder()
5512                    .method(hyper::Method::GET)
5513                    .uri(url.as_str())
5514                    .header(USER_AGENT, self.hub._user_agent.clone());
5515
5516                if let Some(token) = token.as_ref() {
5517                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5518                }
5519
5520                let request = req_builder
5521                    .header(CONTENT_LENGTH, 0_u64)
5522                    .body(common::to_body::<String>(None));
5523
5524                client.request(request.unwrap()).await
5525            };
5526
5527            match req_result {
5528                Err(err) => {
5529                    if let common::Retry::After(d) = dlg.http_error(&err) {
5530                        sleep(d).await;
5531                        continue;
5532                    }
5533                    dlg.finished(false);
5534                    return Err(common::Error::HttpError(err));
5535                }
5536                Ok(res) => {
5537                    let (mut parts, body) = res.into_parts();
5538                    let mut body = common::Body::new(body);
5539                    if !parts.status.is_success() {
5540                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5541                        let error = serde_json::from_str(&common::to_string(&bytes));
5542                        let response = common::to_response(parts, bytes.into());
5543
5544                        if let common::Retry::After(d) =
5545                            dlg.http_failure(&response, error.as_ref().ok())
5546                        {
5547                            sleep(d).await;
5548                            continue;
5549                        }
5550
5551                        dlg.finished(false);
5552
5553                        return Err(match error {
5554                            Ok(value) => common::Error::BadRequest(value),
5555                            _ => common::Error::Failure(response),
5556                        });
5557                    }
5558                    let response = {
5559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5560                        let encoded = common::to_string(&bytes);
5561                        match serde_json::from_str(&encoded) {
5562                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5563                            Err(error) => {
5564                                dlg.response_json_decode_error(&encoded, &error);
5565                                return Err(common::Error::JsonDecodeError(
5566                                    encoded.to_string(),
5567                                    error,
5568                                ));
5569                            }
5570                        }
5571                    };
5572
5573                    dlg.finished(true);
5574                    return Ok(response);
5575                }
5576            }
5577        }
5578    }
5579
5580    /// An expression used to filter cases. Expressions use the following fields separated by `AND` and specified with `=`: - `organization`: An organization name in the form `organizations/`. - `project`: A project name in the form `projects/`. - `state`: Can be `OPEN` or `CLOSED`. - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You can specify multiple values for priority using the `OR` operator. For example, `priority=P1 OR priority=P2`. - `creator.email`: The email address of the case creator. You must specify either `organization` or `project`. To search across `displayName`, `description`, and comments, use a global restriction with no keyword or operator. For example, `"my search"`. To search only cases updated after a certain date, use `update_time` restricted with that particular date, time, and timezone in ISO datetime format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. `update_time` only supports the greater than operator (`>`). Examples: - `organization="organizations/123456789"` - `project="projects/my-project-id"` - `project="projects/123456789"` - `organization="organizations/123456789" AND state=CLOSED` - `project="projects/my-project-id" AND creator.email="tester@example.com"` - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)`
5581    ///
5582    /// Sets the *query* query property to the given value.
5583    pub fn query(mut self, new_value: &str) -> CaseSearchCall<'a, C> {
5584        self._query = Some(new_value.to_string());
5585        self
5586    }
5587    /// The name of the parent resource to search for cases under.
5588    ///
5589    /// Sets the *parent* query property to the given value.
5590    pub fn parent(mut self, new_value: &str) -> CaseSearchCall<'a, C> {
5591        self._parent = Some(new_value.to_string());
5592        self
5593    }
5594    /// A token identifying the page of results to return. If unspecified, the first page is retrieved.
5595    ///
5596    /// Sets the *page token* query property to the given value.
5597    pub fn page_token(mut self, new_value: &str) -> CaseSearchCall<'a, C> {
5598        self._page_token = Some(new_value.to_string());
5599        self
5600    }
5601    /// The maximum number of cases fetched with each request. The default page size is 10.
5602    ///
5603    /// Sets the *page size* query property to the given value.
5604    pub fn page_size(mut self, new_value: i32) -> CaseSearchCall<'a, C> {
5605        self._page_size = Some(new_value);
5606        self
5607    }
5608    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5609    /// while executing the actual API request.
5610    ///
5611    /// ````text
5612    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5613    /// ````
5614    ///
5615    /// Sets the *delegate* property to the given value.
5616    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseSearchCall<'a, C> {
5617        self._delegate = Some(new_value);
5618        self
5619    }
5620
5621    /// Set any additional parameter of the query string used in the request.
5622    /// It should be used to set parameters which are not yet available through their own
5623    /// setters.
5624    ///
5625    /// Please note that this method must not be used to set any of the known parameters
5626    /// which have their own setter method. If done anyway, the request will fail.
5627    ///
5628    /// # Additional Parameters
5629    ///
5630    /// * *$.xgafv* (query-string) - V1 error format.
5631    /// * *access_token* (query-string) - OAuth access token.
5632    /// * *alt* (query-string) - Data format for response.
5633    /// * *callback* (query-string) - JSONP
5634    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5635    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5636    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5637    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5638    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5639    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5640    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5641    pub fn param<T>(mut self, name: T, value: T) -> CaseSearchCall<'a, C>
5642    where
5643        T: AsRef<str>,
5644    {
5645        self._additional_params
5646            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5647        self
5648    }
5649
5650    /// Identifies the authorization scope for the method you are building.
5651    ///
5652    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5653    /// [`Scope::CloudPlatform`].
5654    ///
5655    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5656    /// tokens for more than one scope.
5657    ///
5658    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5659    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5660    /// sufficient, a read-write scope will do as well.
5661    pub fn add_scope<St>(mut self, scope: St) -> CaseSearchCall<'a, C>
5662    where
5663        St: AsRef<str>,
5664    {
5665        self._scopes.insert(String::from(scope.as_ref()));
5666        self
5667    }
5668    /// Identifies the authorization scope(s) for the method you are building.
5669    ///
5670    /// See [`Self::add_scope()`] for details.
5671    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseSearchCall<'a, C>
5672    where
5673        I: IntoIterator<Item = St>,
5674        St: AsRef<str>,
5675    {
5676        self._scopes
5677            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5678        self
5679    }
5680
5681    /// Removes all scopes, and no default scope will be used either.
5682    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5683    /// for details).
5684    pub fn clear_scopes(mut self) -> CaseSearchCall<'a, C> {
5685        self._scopes.clear();
5686        self
5687    }
5688}
5689
5690/// Show items in the feed of this case, including case emails, attachments, and comments.
5691///
5692/// A builder for the *showFeed* method supported by a *case* resource.
5693/// It is not used directly, but through a [`CaseMethods`] instance.
5694///
5695/// # Example
5696///
5697/// Instantiate a resource method builder
5698///
5699/// ```test_harness,no_run
5700/// # extern crate hyper;
5701/// # extern crate hyper_rustls;
5702/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
5703/// # async fn dox() {
5704/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5705///
5706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5707/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5708/// #     .with_native_roots()
5709/// #     .unwrap()
5710/// #     .https_only()
5711/// #     .enable_http2()
5712/// #     .build();
5713///
5714/// # let executor = hyper_util::rt::TokioExecutor::new();
5715/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5716/// #     secret,
5717/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5718/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5719/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5720/// #     ),
5721/// # ).build().await.unwrap();
5722///
5723/// # let client = hyper_util::client::legacy::Client::builder(
5724/// #     hyper_util::rt::TokioExecutor::new()
5725/// # )
5726/// # .build(
5727/// #     hyper_rustls::HttpsConnectorBuilder::new()
5728/// #         .with_native_roots()
5729/// #         .unwrap()
5730/// #         .https_or_http()
5731/// #         .enable_http2()
5732/// #         .build()
5733/// # );
5734/// # let mut hub = CloudSupport::new(client, auth);
5735/// // You can configure optional parameters by calling the respective setters at will, and
5736/// // execute the final call using `doit()`.
5737/// // Values shown here are possibly random and not representative !
5738/// let result = hub.cases().show_feed("parent")
5739///              .page_token("kasd")
5740///              .page_size(-24)
5741///              .order_by("sed")
5742///              .doit().await;
5743/// # }
5744/// ```
5745pub struct CaseShowFeedCall<'a, C>
5746where
5747    C: 'a,
5748{
5749    hub: &'a CloudSupport<C>,
5750    _parent: String,
5751    _page_token: Option<String>,
5752    _page_size: Option<i32>,
5753    _order_by: Option<String>,
5754    _delegate: Option<&'a mut dyn common::Delegate>,
5755    _additional_params: HashMap<String, String>,
5756    _scopes: BTreeSet<String>,
5757}
5758
5759impl<'a, C> common::CallBuilder for CaseShowFeedCall<'a, C> {}
5760
5761impl<'a, C> CaseShowFeedCall<'a, C>
5762where
5763    C: common::Connector,
5764{
5765    /// Perform the operation you have build so far.
5766    pub async fn doit(mut self) -> common::Result<(common::Response, ShowFeedResponse)> {
5767        use std::borrow::Cow;
5768        use std::io::{Read, Seek};
5769
5770        use common::{url::Params, ToParts};
5771        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5772
5773        let mut dd = common::DefaultDelegate;
5774        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5775        dlg.begin(common::MethodInfo {
5776            id: "cloudsupport.cases.showFeed",
5777            http_method: hyper::Method::GET,
5778        });
5779
5780        for &field in ["alt", "parent", "pageToken", "pageSize", "orderBy"].iter() {
5781            if self._additional_params.contains_key(field) {
5782                dlg.finished(false);
5783                return Err(common::Error::FieldClash(field));
5784            }
5785        }
5786
5787        let mut params = Params::with_capacity(6 + self._additional_params.len());
5788        params.push("parent", self._parent);
5789        if let Some(value) = self._page_token.as_ref() {
5790            params.push("pageToken", value);
5791        }
5792        if let Some(value) = self._page_size.as_ref() {
5793            params.push("pageSize", value.to_string());
5794        }
5795        if let Some(value) = self._order_by.as_ref() {
5796            params.push("orderBy", value);
5797        }
5798
5799        params.extend(self._additional_params.iter());
5800
5801        params.push("alt", "json");
5802        let mut url = self.hub._base_url.clone() + "v2beta/{+parent}:showFeed";
5803        if self._scopes.is_empty() {
5804            self._scopes
5805                .insert(Scope::CloudPlatform.as_ref().to_string());
5806        }
5807
5808        #[allow(clippy::single_element_loop)]
5809        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5810            url = params.uri_replacement(url, param_name, find_this, true);
5811        }
5812        {
5813            let to_remove = ["parent"];
5814            params.remove_params(&to_remove);
5815        }
5816
5817        let url = params.parse_with_url(&url);
5818
5819        loop {
5820            let token = match self
5821                .hub
5822                .auth
5823                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5824                .await
5825            {
5826                Ok(token) => token,
5827                Err(e) => match dlg.token(e) {
5828                    Ok(token) => token,
5829                    Err(e) => {
5830                        dlg.finished(false);
5831                        return Err(common::Error::MissingToken(e));
5832                    }
5833                },
5834            };
5835            let mut req_result = {
5836                let client = &self.hub.client;
5837                dlg.pre_request();
5838                let mut req_builder = hyper::Request::builder()
5839                    .method(hyper::Method::GET)
5840                    .uri(url.as_str())
5841                    .header(USER_AGENT, self.hub._user_agent.clone());
5842
5843                if let Some(token) = token.as_ref() {
5844                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5845                }
5846
5847                let request = req_builder
5848                    .header(CONTENT_LENGTH, 0_u64)
5849                    .body(common::to_body::<String>(None));
5850
5851                client.request(request.unwrap()).await
5852            };
5853
5854            match req_result {
5855                Err(err) => {
5856                    if let common::Retry::After(d) = dlg.http_error(&err) {
5857                        sleep(d).await;
5858                        continue;
5859                    }
5860                    dlg.finished(false);
5861                    return Err(common::Error::HttpError(err));
5862                }
5863                Ok(res) => {
5864                    let (mut parts, body) = res.into_parts();
5865                    let mut body = common::Body::new(body);
5866                    if !parts.status.is_success() {
5867                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5868                        let error = serde_json::from_str(&common::to_string(&bytes));
5869                        let response = common::to_response(parts, bytes.into());
5870
5871                        if let common::Retry::After(d) =
5872                            dlg.http_failure(&response, error.as_ref().ok())
5873                        {
5874                            sleep(d).await;
5875                            continue;
5876                        }
5877
5878                        dlg.finished(false);
5879
5880                        return Err(match error {
5881                            Ok(value) => common::Error::BadRequest(value),
5882                            _ => common::Error::Failure(response),
5883                        });
5884                    }
5885                    let response = {
5886                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5887                        let encoded = common::to_string(&bytes);
5888                        match serde_json::from_str(&encoded) {
5889                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5890                            Err(error) => {
5891                                dlg.response_json_decode_error(&encoded, &error);
5892                                return Err(common::Error::JsonDecodeError(
5893                                    encoded.to_string(),
5894                                    error,
5895                                ));
5896                            }
5897                        }
5898                    };
5899
5900                    dlg.finished(true);
5901                    return Ok(response);
5902                }
5903            }
5904        }
5905    }
5906
5907    /// Required. The resource name of the case for which feed items should be listed.
5908    ///
5909    /// Sets the *parent* path property to the given value.
5910    ///
5911    /// Even though the property as already been set when instantiating this call,
5912    /// we provide this method for API completeness.
5913    pub fn parent(mut self, new_value: &str) -> CaseShowFeedCall<'a, C> {
5914        self._parent = new_value.to_string();
5915        self
5916    }
5917    /// Optional. A token identifying the page of results to return. If unspecified, it retrieves the first page.
5918    ///
5919    /// Sets the *page token* query property to the given value.
5920    pub fn page_token(mut self, new_value: &str) -> CaseShowFeedCall<'a, C> {
5921        self._page_token = Some(new_value.to_string());
5922        self
5923    }
5924    /// Optional. The maximum number of feed items fetched with each request.
5925    ///
5926    /// Sets the *page size* query property to the given value.
5927    pub fn page_size(mut self, new_value: i32) -> CaseShowFeedCall<'a, C> {
5928        self._page_size = Some(new_value);
5929        self
5930    }
5931    /// Optional. Field to order feed items by, followed by `asc` or `desc` postfix. The only valid field is `creation_time`. This list is case-insensitive, default sorting order is ascending, and the redundant space characters are insignificant. Example: `creation_time desc`
5932    ///
5933    /// Sets the *order by* query property to the given value.
5934    pub fn order_by(mut self, new_value: &str) -> CaseShowFeedCall<'a, C> {
5935        self._order_by = Some(new_value.to_string());
5936        self
5937    }
5938    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5939    /// while executing the actual API request.
5940    ///
5941    /// ````text
5942    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5943    /// ````
5944    ///
5945    /// Sets the *delegate* property to the given value.
5946    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CaseShowFeedCall<'a, C> {
5947        self._delegate = Some(new_value);
5948        self
5949    }
5950
5951    /// Set any additional parameter of the query string used in the request.
5952    /// It should be used to set parameters which are not yet available through their own
5953    /// setters.
5954    ///
5955    /// Please note that this method must not be used to set any of the known parameters
5956    /// which have their own setter method. If done anyway, the request will fail.
5957    ///
5958    /// # Additional Parameters
5959    ///
5960    /// * *$.xgafv* (query-string) - V1 error format.
5961    /// * *access_token* (query-string) - OAuth access token.
5962    /// * *alt* (query-string) - Data format for response.
5963    /// * *callback* (query-string) - JSONP
5964    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5965    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5966    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5967    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5968    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5969    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5970    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5971    pub fn param<T>(mut self, name: T, value: T) -> CaseShowFeedCall<'a, C>
5972    where
5973        T: AsRef<str>,
5974    {
5975        self._additional_params
5976            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5977        self
5978    }
5979
5980    /// Identifies the authorization scope for the method you are building.
5981    ///
5982    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5983    /// [`Scope::CloudPlatform`].
5984    ///
5985    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5986    /// tokens for more than one scope.
5987    ///
5988    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5989    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5990    /// sufficient, a read-write scope will do as well.
5991    pub fn add_scope<St>(mut self, scope: St) -> CaseShowFeedCall<'a, C>
5992    where
5993        St: AsRef<str>,
5994    {
5995        self._scopes.insert(String::from(scope.as_ref()));
5996        self
5997    }
5998    /// Identifies the authorization scope(s) for the method you are building.
5999    ///
6000    /// See [`Self::add_scope()`] for details.
6001    pub fn add_scopes<I, St>(mut self, scopes: I) -> CaseShowFeedCall<'a, C>
6002    where
6003        I: IntoIterator<Item = St>,
6004        St: AsRef<str>,
6005    {
6006        self._scopes
6007            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6008        self
6009    }
6010
6011    /// Removes all scopes, and no default scope will be used either.
6012    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6013    /// for details).
6014    pub fn clear_scopes(mut self) -> CaseShowFeedCall<'a, C> {
6015        self._scopes.clear();
6016        self
6017    }
6018}
6019
6020/// Download a file attached to a case. When this endpoint is called, no "response body" will be returned. Instead, the attachment's blob will be returned. Note: HTTP requests must append "?alt=media" to the URL. EXAMPLES: cURL: ```shell name="projects/some-project/cases/43594844/attachments/0674M00000WijAnZAJ" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudsupport.googleapis.com/v2/$name:download?alt=media" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) request = supportApiService.media().download( name="projects/some-project/cases/43595344/attachments/0684M00000Pw6pHQAR" ) request.uri = request.uri.split("?")[0] + "?alt=media" print(request.execute()) ```
6021///
6022/// This method supports **media download**. To enable it, adjust the builder like this:
6023/// `.param("alt", "media")`.
6024/// Please note that due to missing multi-part support on the server side, you will only receive the media,
6025/// but not the `Media` structure that you would usually get. The latter will be a default value.
6026///
6027/// A builder for the *download* method supported by a *media* resource.
6028/// It is not used directly, but through a [`MediaMethods`] instance.
6029///
6030/// # Example
6031///
6032/// Instantiate a resource method builder
6033///
6034/// ```test_harness,no_run
6035/// # extern crate hyper;
6036/// # extern crate hyper_rustls;
6037/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
6038/// # async fn dox() {
6039/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6040///
6041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6042/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6043/// #     .with_native_roots()
6044/// #     .unwrap()
6045/// #     .https_only()
6046/// #     .enable_http2()
6047/// #     .build();
6048///
6049/// # let executor = hyper_util::rt::TokioExecutor::new();
6050/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6051/// #     secret,
6052/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6053/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6054/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6055/// #     ),
6056/// # ).build().await.unwrap();
6057///
6058/// # let client = hyper_util::client::legacy::Client::builder(
6059/// #     hyper_util::rt::TokioExecutor::new()
6060/// # )
6061/// # .build(
6062/// #     hyper_rustls::HttpsConnectorBuilder::new()
6063/// #         .with_native_roots()
6064/// #         .unwrap()
6065/// #         .https_or_http()
6066/// #         .enable_http2()
6067/// #         .build()
6068/// # );
6069/// # let mut hub = CloudSupport::new(client, auth);
6070/// // You can configure optional parameters by calling the respective setters at will, and
6071/// // execute the final call using `doit()`.
6072/// // Values shown here are possibly random and not representative !
6073/// let result = hub.media().download("name")
6074///              .doit().await;
6075/// # }
6076/// ```
6077pub struct MediaDownloadCall<'a, C>
6078where
6079    C: 'a,
6080{
6081    hub: &'a CloudSupport<C>,
6082    _name: String,
6083    _delegate: Option<&'a mut dyn common::Delegate>,
6084    _additional_params: HashMap<String, String>,
6085    _scopes: BTreeSet<String>,
6086}
6087
6088impl<'a, C> common::CallBuilder for MediaDownloadCall<'a, C> {}
6089
6090impl<'a, C> MediaDownloadCall<'a, C>
6091where
6092    C: common::Connector,
6093{
6094    /// Perform the operation you have build so far.
6095    pub async fn doit(mut self) -> common::Result<(common::Response, Media)> {
6096        use std::borrow::Cow;
6097        use std::io::{Read, Seek};
6098
6099        use common::{url::Params, ToParts};
6100        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6101
6102        let mut dd = common::DefaultDelegate;
6103        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6104        dlg.begin(common::MethodInfo {
6105            id: "cloudsupport.media.download",
6106            http_method: hyper::Method::GET,
6107        });
6108
6109        for &field in ["name"].iter() {
6110            if self._additional_params.contains_key(field) {
6111                dlg.finished(false);
6112                return Err(common::Error::FieldClash(field));
6113            }
6114        }
6115
6116        let mut params = Params::with_capacity(2 + self._additional_params.len());
6117        params.push("name", self._name);
6118
6119        params.extend(self._additional_params.iter());
6120
6121        let (alt_field_missing, enable_resource_parsing) = {
6122            if let Some(value) = params.get("alt") {
6123                (false, value == "json")
6124            } else {
6125                (true, true)
6126            }
6127        };
6128        if alt_field_missing {
6129            params.push("alt", "json");
6130        }
6131        let mut url = self.hub._base_url.clone() + "v2beta/{+name}:download";
6132        if self._scopes.is_empty() {
6133            self._scopes
6134                .insert(Scope::CloudPlatform.as_ref().to_string());
6135        }
6136
6137        #[allow(clippy::single_element_loop)]
6138        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6139            url = params.uri_replacement(url, param_name, find_this, true);
6140        }
6141        {
6142            let to_remove = ["name"];
6143            params.remove_params(&to_remove);
6144        }
6145
6146        let url = params.parse_with_url(&url);
6147
6148        loop {
6149            let token = match self
6150                .hub
6151                .auth
6152                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6153                .await
6154            {
6155                Ok(token) => token,
6156                Err(e) => match dlg.token(e) {
6157                    Ok(token) => token,
6158                    Err(e) => {
6159                        dlg.finished(false);
6160                        return Err(common::Error::MissingToken(e));
6161                    }
6162                },
6163            };
6164            let mut req_result = {
6165                let client = &self.hub.client;
6166                dlg.pre_request();
6167                let mut req_builder = hyper::Request::builder()
6168                    .method(hyper::Method::GET)
6169                    .uri(url.as_str())
6170                    .header(USER_AGENT, self.hub._user_agent.clone());
6171
6172                if let Some(token) = token.as_ref() {
6173                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6174                }
6175
6176                let request = req_builder
6177                    .header(CONTENT_LENGTH, 0_u64)
6178                    .body(common::to_body::<String>(None));
6179
6180                client.request(request.unwrap()).await
6181            };
6182
6183            match req_result {
6184                Err(err) => {
6185                    if let common::Retry::After(d) = dlg.http_error(&err) {
6186                        sleep(d).await;
6187                        continue;
6188                    }
6189                    dlg.finished(false);
6190                    return Err(common::Error::HttpError(err));
6191                }
6192                Ok(res) => {
6193                    let (mut parts, body) = res.into_parts();
6194                    let mut body = common::Body::new(body);
6195                    if !parts.status.is_success() {
6196                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6197                        let error = serde_json::from_str(&common::to_string(&bytes));
6198                        let response = common::to_response(parts, bytes.into());
6199
6200                        if let common::Retry::After(d) =
6201                            dlg.http_failure(&response, error.as_ref().ok())
6202                        {
6203                            sleep(d).await;
6204                            continue;
6205                        }
6206
6207                        dlg.finished(false);
6208
6209                        return Err(match error {
6210                            Ok(value) => common::Error::BadRequest(value),
6211                            _ => common::Error::Failure(response),
6212                        });
6213                    }
6214                    let response = if enable_resource_parsing {
6215                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6216                        let encoded = common::to_string(&bytes);
6217                        match serde_json::from_str(&encoded) {
6218                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6219                            Err(error) => {
6220                                dlg.response_json_decode_error(&encoded, &error);
6221                                return Err(common::Error::JsonDecodeError(
6222                                    encoded.to_string(),
6223                                    error,
6224                                ));
6225                            }
6226                        }
6227                    } else {
6228                        (
6229                            common::Response::from_parts(parts, body),
6230                            Default::default(),
6231                        )
6232                    };
6233
6234                    dlg.finished(true);
6235                    return Ok(response);
6236                }
6237            }
6238        }
6239    }
6240
6241    /// The name of the file attachment to download.
6242    ///
6243    /// Sets the *name* path property to the given value.
6244    ///
6245    /// Even though the property as already been set when instantiating this call,
6246    /// we provide this method for API completeness.
6247    pub fn name(mut self, new_value: &str) -> MediaDownloadCall<'a, C> {
6248        self._name = new_value.to_string();
6249        self
6250    }
6251    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6252    /// while executing the actual API request.
6253    ///
6254    /// ````text
6255    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6256    /// ````
6257    ///
6258    /// Sets the *delegate* property to the given value.
6259    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MediaDownloadCall<'a, C> {
6260        self._delegate = Some(new_value);
6261        self
6262    }
6263
6264    /// Set any additional parameter of the query string used in the request.
6265    /// It should be used to set parameters which are not yet available through their own
6266    /// setters.
6267    ///
6268    /// Please note that this method must not be used to set any of the known parameters
6269    /// which have their own setter method. If done anyway, the request will fail.
6270    ///
6271    /// # Additional Parameters
6272    ///
6273    /// * *$.xgafv* (query-string) - V1 error format.
6274    /// * *access_token* (query-string) - OAuth access token.
6275    /// * *alt* (query-string) - Data format for response.
6276    /// * *callback* (query-string) - JSONP
6277    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6278    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6279    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6280    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6281    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6282    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6283    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6284    pub fn param<T>(mut self, name: T, value: T) -> MediaDownloadCall<'a, C>
6285    where
6286        T: AsRef<str>,
6287    {
6288        self._additional_params
6289            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6290        self
6291    }
6292
6293    /// Identifies the authorization scope for the method you are building.
6294    ///
6295    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6296    /// [`Scope::CloudPlatform`].
6297    ///
6298    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6299    /// tokens for more than one scope.
6300    ///
6301    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6302    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6303    /// sufficient, a read-write scope will do as well.
6304    pub fn add_scope<St>(mut self, scope: St) -> MediaDownloadCall<'a, C>
6305    where
6306        St: AsRef<str>,
6307    {
6308        self._scopes.insert(String::from(scope.as_ref()));
6309        self
6310    }
6311    /// Identifies the authorization scope(s) for the method you are building.
6312    ///
6313    /// See [`Self::add_scope()`] for details.
6314    pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaDownloadCall<'a, C>
6315    where
6316        I: IntoIterator<Item = St>,
6317        St: AsRef<str>,
6318    {
6319        self._scopes
6320            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6321        self
6322    }
6323
6324    /// Removes all scopes, and no default scope will be used either.
6325    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6326    /// for details).
6327    pub fn clear_scopes(mut self) -> MediaDownloadCall<'a, C> {
6328        self._scopes.clear();
6329        self
6330    }
6331}
6332
6333/// Create a file attachment on a case or Cloud resource. The attachment must have the following fields set: `filename`. EXAMPLES: cURL: ```shell echo "This text is in a file I'm uploading using CSAPI." \ > "./example_file.txt" case="projects/some-project/cases/43594844" curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --data-binary @"./example_file.txt" \ "https://cloudsupport.googleapis.com/upload/v2beta/$case/attachments?attachment.filename=uploaded_via_curl.txt" ``` Python: ```python import googleapiclient.discovery api_version = "v2" supportApiService = googleapiclient.discovery.build( serviceName="cloudsupport", version=api_version, discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", ) file_path = "./example_file.txt" with open(file_path, "w") as file: file.write( "This text is inside a file I'm going to upload using the Cloud Support API.", ) request = supportApiService.media().upload( parent="projects/some-project/cases/43595344", media_body=file_path ) request.uri = request.uri.split("?")[0] + "?attachment.filename=uploaded_via_python.txt" print(request.execute()) ```
6334///
6335/// A builder for the *upload* method supported by a *media* resource.
6336/// It is not used directly, but through a [`MediaMethods`] instance.
6337///
6338/// # Example
6339///
6340/// Instantiate a resource method builder
6341///
6342/// ```test_harness,no_run
6343/// # extern crate hyper;
6344/// # extern crate hyper_rustls;
6345/// # extern crate google_cloudsupport2_beta as cloudsupport2_beta;
6346/// use cloudsupport2_beta::api::CreateAttachmentRequest;
6347/// use std::fs;
6348/// # async fn dox() {
6349/// # use cloudsupport2_beta::{CloudSupport, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6350///
6351/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6352/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6353/// #     .with_native_roots()
6354/// #     .unwrap()
6355/// #     .https_only()
6356/// #     .enable_http2()
6357/// #     .build();
6358///
6359/// # let executor = hyper_util::rt::TokioExecutor::new();
6360/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6361/// #     secret,
6362/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6363/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6364/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6365/// #     ),
6366/// # ).build().await.unwrap();
6367///
6368/// # let client = hyper_util::client::legacy::Client::builder(
6369/// #     hyper_util::rt::TokioExecutor::new()
6370/// # )
6371/// # .build(
6372/// #     hyper_rustls::HttpsConnectorBuilder::new()
6373/// #         .with_native_roots()
6374/// #         .unwrap()
6375/// #         .https_or_http()
6376/// #         .enable_http2()
6377/// #         .build()
6378/// # );
6379/// # let mut hub = CloudSupport::new(client, auth);
6380/// // As the method needs a request, you would usually fill it with the desired information
6381/// // into the respective structure. Some of the parts shown here might not be applicable !
6382/// // Values shown here are possibly random and not representative !
6383/// let mut req = CreateAttachmentRequest::default();
6384///
6385/// // You can configure optional parameters by calling the respective setters at will, and
6386/// // execute the final call using `upload(...)`.
6387/// // Values shown here are possibly random and not representative !
6388/// let result = hub.media().upload(req, "parent")
6389///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
6390/// # }
6391/// ```
6392pub struct MediaUploadCall<'a, C>
6393where
6394    C: 'a,
6395{
6396    hub: &'a CloudSupport<C>,
6397    _request: CreateAttachmentRequest,
6398    _parent: String,
6399    _delegate: Option<&'a mut dyn common::Delegate>,
6400    _additional_params: HashMap<String, String>,
6401    _scopes: BTreeSet<String>,
6402}
6403
6404impl<'a, C> common::CallBuilder for MediaUploadCall<'a, C> {}
6405
6406impl<'a, C> MediaUploadCall<'a, C>
6407where
6408    C: common::Connector,
6409{
6410    /// Perform the operation you have build so far.
6411    async fn doit<RS>(
6412        mut self,
6413        mut reader: RS,
6414        reader_mime_type: mime::Mime,
6415        protocol: common::UploadProtocol,
6416    ) -> common::Result<(common::Response, Attachment)>
6417    where
6418        RS: common::ReadSeek,
6419    {
6420        use std::borrow::Cow;
6421        use std::io::{Read, Seek};
6422
6423        use common::{url::Params, ToParts};
6424        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6425
6426        let mut dd = common::DefaultDelegate;
6427        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6428        dlg.begin(common::MethodInfo {
6429            id: "cloudsupport.media.upload",
6430            http_method: hyper::Method::POST,
6431        });
6432
6433        for &field in ["alt", "parent"].iter() {
6434            if self._additional_params.contains_key(field) {
6435                dlg.finished(false);
6436                return Err(common::Error::FieldClash(field));
6437            }
6438        }
6439
6440        let mut params = Params::with_capacity(4 + self._additional_params.len());
6441        params.push("parent", self._parent);
6442
6443        params.extend(self._additional_params.iter());
6444
6445        params.push("alt", "json");
6446        let (mut url, upload_type) = if protocol == common::UploadProtocol::Simple {
6447            (
6448                self.hub._root_url.clone() + "upload/v2beta/{+parent}/attachments",
6449                "multipart",
6450            )
6451        } else {
6452            unreachable!()
6453        };
6454        params.push("uploadType", upload_type);
6455        if self._scopes.is_empty() {
6456            self._scopes
6457                .insert(Scope::CloudPlatform.as_ref().to_string());
6458        }
6459
6460        #[allow(clippy::single_element_loop)]
6461        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6462            url = params.uri_replacement(url, param_name, find_this, true);
6463        }
6464        {
6465            let to_remove = ["parent"];
6466            params.remove_params(&to_remove);
6467        }
6468
6469        let url = params.parse_with_url(&url);
6470
6471        let mut json_mime_type = mime::APPLICATION_JSON;
6472        let mut request_value_reader = {
6473            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6474            common::remove_json_null_values(&mut value);
6475            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6476            serde_json::to_writer(&mut dst, &value).unwrap();
6477            dst
6478        };
6479        let request_size = request_value_reader
6480            .seek(std::io::SeekFrom::End(0))
6481            .unwrap();
6482        request_value_reader
6483            .seek(std::io::SeekFrom::Start(0))
6484            .unwrap();
6485
6486        loop {
6487            let token = match self
6488                .hub
6489                .auth
6490                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6491                .await
6492            {
6493                Ok(token) => token,
6494                Err(e) => match dlg.token(e) {
6495                    Ok(token) => token,
6496                    Err(e) => {
6497                        dlg.finished(false);
6498                        return Err(common::Error::MissingToken(e));
6499                    }
6500                },
6501            };
6502            request_value_reader
6503                .seek(std::io::SeekFrom::Start(0))
6504                .unwrap();
6505            let mut req_result = {
6506                let mut mp_reader: common::MultiPartReader = Default::default();
6507                let (mut body_reader, content_type) = match protocol {
6508                    common::UploadProtocol::Simple => {
6509                        mp_reader.reserve_exact(2);
6510                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6511                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6512
6513                        mp_reader
6514                            .add_part(
6515                                &mut request_value_reader,
6516                                request_size,
6517                                json_mime_type.clone(),
6518                            )
6519                            .add_part(&mut reader, size, reader_mime_type.clone());
6520                        (
6521                            &mut mp_reader as &mut (dyn std::io::Read + Send),
6522                            common::MultiPartReader::mime_type(),
6523                        )
6524                    }
6525                    _ => (
6526                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
6527                        json_mime_type.clone(),
6528                    ),
6529                };
6530                let client = &self.hub.client;
6531                dlg.pre_request();
6532                let mut req_builder = hyper::Request::builder()
6533                    .method(hyper::Method::POST)
6534                    .uri(url.as_str())
6535                    .header(USER_AGENT, self.hub._user_agent.clone());
6536
6537                if let Some(token) = token.as_ref() {
6538                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6539                }
6540
6541                let mut body_reader_bytes = vec![];
6542                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
6543                let request = req_builder
6544                    .header(CONTENT_TYPE, content_type.to_string())
6545                    .body(common::to_body(body_reader_bytes.into()));
6546
6547                client.request(request.unwrap()).await
6548            };
6549
6550            match req_result {
6551                Err(err) => {
6552                    if let common::Retry::After(d) = dlg.http_error(&err) {
6553                        sleep(d).await;
6554                        continue;
6555                    }
6556                    dlg.finished(false);
6557                    return Err(common::Error::HttpError(err));
6558                }
6559                Ok(res) => {
6560                    let (mut parts, body) = res.into_parts();
6561                    let mut body = common::Body::new(body);
6562                    if !parts.status.is_success() {
6563                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6564                        let error = serde_json::from_str(&common::to_string(&bytes));
6565                        let response = common::to_response(parts, bytes.into());
6566
6567                        if let common::Retry::After(d) =
6568                            dlg.http_failure(&response, error.as_ref().ok())
6569                        {
6570                            sleep(d).await;
6571                            continue;
6572                        }
6573
6574                        dlg.finished(false);
6575
6576                        return Err(match error {
6577                            Ok(value) => common::Error::BadRequest(value),
6578                            _ => common::Error::Failure(response),
6579                        });
6580                    }
6581                    let response = {
6582                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6583                        let encoded = common::to_string(&bytes);
6584                        match serde_json::from_str(&encoded) {
6585                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6586                            Err(error) => {
6587                                dlg.response_json_decode_error(&encoded, &error);
6588                                return Err(common::Error::JsonDecodeError(
6589                                    encoded.to_string(),
6590                                    error,
6591                                ));
6592                            }
6593                        }
6594                    };
6595
6596                    dlg.finished(true);
6597                    return Ok(response);
6598                }
6599            }
6600        }
6601    }
6602
6603    /// Upload media all at once.
6604    /// If the upload fails for whichever reason, all progress is lost.
6605    ///
6606    /// * *multipart*: yes
6607    /// * *max size*: 0kb
6608    /// * *valid mime types*: '*/*'
6609    pub async fn upload<RS>(
6610        self,
6611        stream: RS,
6612        mime_type: mime::Mime,
6613    ) -> common::Result<(common::Response, Attachment)>
6614    where
6615        RS: common::ReadSeek,
6616    {
6617        self.doit(stream, mime_type, common::UploadProtocol::Simple)
6618            .await
6619    }
6620
6621    ///
6622    /// Sets the *request* property to the given value.
6623    ///
6624    /// Even though the property as already been set when instantiating this call,
6625    /// we provide this method for API completeness.
6626    pub fn request(mut self, new_value: CreateAttachmentRequest) -> MediaUploadCall<'a, C> {
6627        self._request = new_value;
6628        self
6629    }
6630    /// Required. The name of the case or Cloud resource to which the attachment should be attached.
6631    ///
6632    /// Sets the *parent* path property to the given value.
6633    ///
6634    /// Even though the property as already been set when instantiating this call,
6635    /// we provide this method for API completeness.
6636    pub fn parent(mut self, new_value: &str) -> MediaUploadCall<'a, C> {
6637        self._parent = new_value.to_string();
6638        self
6639    }
6640    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6641    /// while executing the actual API request.
6642    ///
6643    /// ````text
6644    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6645    /// ````
6646    ///
6647    /// Sets the *delegate* property to the given value.
6648    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MediaUploadCall<'a, C> {
6649        self._delegate = Some(new_value);
6650        self
6651    }
6652
6653    /// Set any additional parameter of the query string used in the request.
6654    /// It should be used to set parameters which are not yet available through their own
6655    /// setters.
6656    ///
6657    /// Please note that this method must not be used to set any of the known parameters
6658    /// which have their own setter method. If done anyway, the request will fail.
6659    ///
6660    /// # Additional Parameters
6661    ///
6662    /// * *$.xgafv* (query-string) - V1 error format.
6663    /// * *access_token* (query-string) - OAuth access token.
6664    /// * *alt* (query-string) - Data format for response.
6665    /// * *callback* (query-string) - JSONP
6666    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6667    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6668    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6669    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6670    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6671    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6672    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6673    pub fn param<T>(mut self, name: T, value: T) -> MediaUploadCall<'a, C>
6674    where
6675        T: AsRef<str>,
6676    {
6677        self._additional_params
6678            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6679        self
6680    }
6681
6682    /// Identifies the authorization scope for the method you are building.
6683    ///
6684    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6685    /// [`Scope::CloudPlatform`].
6686    ///
6687    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6688    /// tokens for more than one scope.
6689    ///
6690    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6691    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6692    /// sufficient, a read-write scope will do as well.
6693    pub fn add_scope<St>(mut self, scope: St) -> MediaUploadCall<'a, C>
6694    where
6695        St: AsRef<str>,
6696    {
6697        self._scopes.insert(String::from(scope.as_ref()));
6698        self
6699    }
6700    /// Identifies the authorization scope(s) for the method you are building.
6701    ///
6702    /// See [`Self::add_scope()`] for details.
6703    pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaUploadCall<'a, C>
6704    where
6705        I: IntoIterator<Item = St>,
6706        St: AsRef<str>,
6707    {
6708        self._scopes
6709            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6710        self
6711    }
6712
6713    /// Removes all scopes, and no default scope will be used either.
6714    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6715    /// for details).
6716    pub fn clear_scopes(mut self) -> MediaUploadCall<'a, C> {
6717        self._scopes.clear();
6718        self
6719    }
6720}