google_doubleclickbidmanager1/
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    /// View and manage your reports in DoubleClick Bid Manager
17    Full,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::Full => "https://www.googleapis.com/auth/doubleclickbidmanager",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::Full
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all DoubleClickBidManager 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_doubleclickbidmanager1 as doubleclickbidmanager1;
49/// use doubleclickbidmanager1::api::Query;
50/// use doubleclickbidmanager1::{Result, Error};
51/// # async fn dox() {
52/// use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = DoubleClickBidManager::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Query::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.queries().createquery(req)
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct DoubleClickBidManager<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for DoubleClickBidManager<C> {}
130
131impl<'a, C> DoubleClickBidManager<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> DoubleClickBidManager<C> {
136        DoubleClickBidManager {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://doubleclickbidmanager.googleapis.com/doubleclickbidmanager/v1/"
141                .to_string(),
142            _root_url: "https://doubleclickbidmanager.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn lineitems(&'a self) -> LineitemMethods<'a, C> {
147        LineitemMethods { hub: self }
148    }
149    pub fn queries(&'a self) -> QueryMethods<'a, C> {
150        QueryMethods { hub: self }
151    }
152    pub fn reports(&'a self) -> ReportMethods<'a, C> {
153        ReportMethods { hub: self }
154    }
155    pub fn sdf(&'a self) -> SdfMethods<'a, C> {
156        SdfMethods { hub: self }
157    }
158
159    /// Set the user-agent header field to use in all requests to the server.
160    /// It defaults to `google-api-rust-client/7.0.0`.
161    ///
162    /// Returns the previously set user-agent.
163    pub fn user_agent(&mut self, agent_name: String) -> String {
164        std::mem::replace(&mut self._user_agent, agent_name)
165    }
166
167    /// Set the base url to use in all requests to the server.
168    /// It defaults to `https://doubleclickbidmanager.googleapis.com/doubleclickbidmanager/v1/`.
169    ///
170    /// Returns the previously set base url.
171    pub fn base_url(&mut self, new_base_url: String) -> String {
172        std::mem::replace(&mut self._base_url, new_base_url)
173    }
174
175    /// Set the root url to use in all requests to the server.
176    /// It defaults to `https://doubleclickbidmanager.googleapis.com/`.
177    ///
178    /// Returns the previously set root url.
179    pub fn root_url(&mut self, new_root_url: String) -> String {
180        std::mem::replace(&mut self._root_url, new_root_url)
181    }
182}
183
184// ############
185// SCHEMAS ###
186// ##########
187/// Request to fetch stored line items.
188///
189/// # Activities
190///
191/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
192/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
193///
194/// * [downloadlineitems lineitems](LineitemDownloadlineitemCall) (request)
195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
196#[serde_with::serde_as]
197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
198pub struct DownloadLineItemsRequest {
199    /// File specification (column names, types, order) in which the line items will be returned. Default to EWF.
200    #[serde(rename = "fileSpec")]
201    pub file_spec: Option<String>,
202    /// Ids of the specified filter type used to filter line items to fetch. If omitted, all the line items will be returned.
203    #[serde(rename = "filterIds")]
204    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
205    pub filter_ids: Option<Vec<i64>>,
206    /// Filter type used to filter line items to fetch.
207    #[serde(rename = "filterType")]
208    pub filter_type: Option<String>,
209    /// Format in which the line items will be returned. Default to CSV.
210    pub format: Option<String>,
211}
212
213impl common::RequestValue for DownloadLineItemsRequest {}
214
215/// Download line items response.
216///
217/// # Activities
218///
219/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
220/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
221///
222/// * [downloadlineitems lineitems](LineitemDownloadlineitemCall) (response)
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224#[serde_with::serde_as]
225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
226pub struct DownloadLineItemsResponse {
227    /// Retrieved line items in CSV format. For more information about file formats, see Entity Write File Format.
228    #[serde(rename = "lineItems")]
229    pub line_items: Option<String>,
230}
231
232impl common::ResponseResult for DownloadLineItemsResponse {}
233
234/// Request to fetch stored inventory sources, campaigns, insertion orders, line items, YouTube ad groups and ads.
235///
236/// # Activities
237///
238/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
239/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
240///
241/// * [download sdf](SdfDownloadCall) (request)
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct DownloadRequest {
246    /// File types that will be returned. If INVENTORY_SOURCE is requested, no other file types may be requested. Acceptable values are: - "AD" - "AD_GROUP" - "CAMPAIGN" - "INSERTION_ORDER" - "INVENTORY_SOURCE" - "LINE_ITEM"
247    #[serde(rename = "fileTypes")]
248    pub file_types: Option<Vec<String>>,
249    /// The IDs of the specified filter type. This is used to filter entities to fetch. At least one ID must be specified.
250    #[serde(rename = "filterIds")]
251    #[serde_as(as = "Option<Vec<serde_with::DisplayFromStr>>")]
252    pub filter_ids: Option<Vec<i64>>,
253    /// Filter type used to filter entities to fetch. PARTNER_ID and INVENTORY_SOURCE_ID may only be used when downloading inventory sources.
254    #[serde(rename = "filterType")]
255    pub filter_type: Option<String>,
256    /// SDF Version (column names, types, order) in which the entities will be returned. Default to 5.
257    pub version: Option<String>,
258}
259
260impl common::RequestValue for DownloadRequest {}
261
262/// Download response.
263///
264/// # Activities
265///
266/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
267/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
268///
269/// * [download sdf](SdfDownloadCall) (response)
270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
271#[serde_with::serde_as]
272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
273pub struct DownloadResponse {
274    /// Retrieved ad groups in SDF format.
275    #[serde(rename = "adGroups")]
276    pub ad_groups: Option<String>,
277    /// Retrieved ads in SDF format.
278    pub ads: Option<String>,
279    /// Retrieved campaigns in SDF format.
280    pub campaigns: Option<String>,
281    /// Retrieved insertion orders in SDF format.
282    #[serde(rename = "insertionOrders")]
283    pub insertion_orders: Option<String>,
284    /// no description provided
285    #[serde(rename = "inventorySources")]
286    pub inventory_sources: Option<String>,
287    /// Retrieved line items in SDF format.
288    #[serde(rename = "lineItems")]
289    pub line_items: Option<String>,
290}
291
292impl common::ResponseResult for DownloadResponse {}
293
294/// Filter used to match traffic data in your report.
295///
296/// This type is not used in any activity, and only used as *part* of another schema.
297///
298#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
299#[serde_with::serde_as]
300#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
301pub struct FilterPair {
302    /// Filter type.
303    #[serde(rename = "type")]
304    pub type_: Option<String>,
305    /// Filter value.
306    pub value: Option<String>,
307}
308
309impl common::Part for FilterPair {}
310
311/// List queries response.
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [listqueries queries](QueryListqueryCall) (response)
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct ListQueriesResponse {
323    /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listQueriesResponse".
324    pub kind: Option<String>,
325    /// Retrieved queries.
326    pub queries: Option<Vec<Query>>,
327}
328
329impl common::ResponseResult for ListQueriesResponse {}
330
331/// List reports response.
332///
333/// # Activities
334///
335/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
336/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
337///
338/// * [listreports reports](ReportListreportCall) (response)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct ListReportsResponse {
343    /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#listReportsResponse".
344    pub kind: Option<String>,
345    /// Retrieved reports.
346    pub reports: Option<Vec<Report>>,
347}
348
349impl common::ResponseResult for ListReportsResponse {}
350
351/// Parameters of a query or report.
352///
353/// This type is not used in any activity, and only used as *part* of another schema.
354///
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct Parameters {
359    /// Filters used to match traffic data in your report.
360    pub filters: Option<Vec<FilterPair>>,
361    /// Data is grouped by the filters listed in this field.
362    #[serde(rename = "groupBys")]
363    pub group_bys: Option<Vec<String>>,
364    /// Deprecated. This field is no longer in use.
365    #[serde(rename = "includeInviteData")]
366    pub include_invite_data: Option<bool>,
367    /// Metrics to include as columns in your report.
368    pub metrics: Option<Vec<String>>,
369    /// Report type.
370    #[serde(rename = "type")]
371    pub type_: Option<String>,
372}
373
374impl common::Part for Parameters {}
375
376/// Represents a query.
377///
378/// # Activities
379///
380/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
381/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
382///
383/// * [createquery queries](QueryCreatequeryCall) (request|response)
384/// * [getquery queries](QueryGetqueryCall) (response)
385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
386#[serde_with::serde_as]
387#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
388pub struct Query {
389    /// Identifies what kind of resource this is. Value: the fixed string "doubleclickbidmanager#query".
390    pub kind: Option<String>,
391    /// Query metadata.
392    pub metadata: Option<QueryMetadata>,
393    /// Query parameters.
394    pub params: Option<Parameters>,
395    /// Query ID.
396    #[serde(rename = "queryId")]
397    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
398    pub query_id: Option<i64>,
399    /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise.
400    #[serde(rename = "reportDataEndTimeMs")]
401    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
402    pub report_data_end_time_ms: Option<i64>,
403    /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if metadata.dataRange is CUSTOM_DATES and ignored otherwise.
404    #[serde(rename = "reportDataStartTimeMs")]
405    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
406    pub report_data_start_time_ms: Option<i64>,
407    /// Information on how often and when to run a query.
408    pub schedule: Option<QuerySchedule>,
409    /// Canonical timezone code for report data time. Defaults to America/New_York.
410    #[serde(rename = "timezoneCode")]
411    pub timezone_code: Option<String>,
412}
413
414impl common::RequestValue for Query {}
415impl common::ResponseResult for Query {}
416
417/// Query metadata.
418///
419/// This type is not used in any activity, and only used as *part* of another schema.
420///
421#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
422#[serde_with::serde_as]
423#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
424pub struct QueryMetadata {
425    /// Range of report data.
426    #[serde(rename = "dataRange")]
427    pub data_range: Option<String>,
428    /// Format of the generated report.
429    pub format: Option<String>,
430    /// The path to the location in Google Cloud Storage where the latest report is stored.
431    #[serde(rename = "googleCloudStoragePathForLatestReport")]
432    pub google_cloud_storage_path_for_latest_report: Option<String>,
433    /// The path in Google Drive for the latest report.
434    #[serde(rename = "googleDrivePathForLatestReport")]
435    pub google_drive_path_for_latest_report: Option<String>,
436    /// The time when the latest report started to run.
437    #[serde(rename = "latestReportRunTimeMs")]
438    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
439    pub latest_report_run_time_ms: Option<i64>,
440    /// Locale of the generated reports. Valid values are cs CZECH de GERMAN en ENGLISH es SPANISH fr FRENCH it ITALIAN ja JAPANESE ko KOREAN pl POLISH pt-BR BRAZILIAN_PORTUGUESE ru RUSSIAN tr TURKISH uk UKRAINIAN zh-CN CHINA_CHINESE zh-TW TAIWAN_CHINESE An locale string not in the list above will generate reports in English.
441    pub locale: Option<String>,
442    /// Number of reports that have been generated for the query.
443    #[serde(rename = "reportCount")]
444    pub report_count: Option<i32>,
445    /// Whether the latest report is currently running.
446    pub running: Option<bool>,
447    /// Whether to send an email notification when a report is ready. Default to false.
448    #[serde(rename = "sendNotification")]
449    pub send_notification: Option<bool>,
450    /// List of email addresses which are sent email notifications when the report is finished. Separate from sendNotification.
451    #[serde(rename = "shareEmailAddress")]
452    pub share_email_address: Option<Vec<String>>,
453    /// Query title. It is used to name the reports generated from this query.
454    pub title: Option<String>,
455}
456
457impl common::Part for QueryMetadata {}
458
459/// Information on how frequently and when to run a query.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct QuerySchedule {
467    /// Datetime to periodically run the query until.
468    #[serde(rename = "endTimeMs")]
469    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
470    pub end_time_ms: Option<i64>,
471    /// How often the query is run.
472    pub frequency: Option<String>,
473    /// Time of day at which a new report will be generated, represented as minutes past midnight. Range is 0 to 1439. Only applies to scheduled reports.
474    #[serde(rename = "nextRunMinuteOfDay")]
475    pub next_run_minute_of_day: Option<i32>,
476    /// Canonical timezone code for report generation time. Defaults to America/New_York.
477    #[serde(rename = "nextRunTimezoneCode")]
478    pub next_run_timezone_code: Option<String>,
479}
480
481impl common::Part for QuerySchedule {}
482
483/// Represents a report.
484///
485/// # Activities
486///
487/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
488/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
489///
490/// * [listreports reports](ReportListreportCall) (none)
491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
492#[serde_with::serde_as]
493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
494pub struct Report {
495    /// Key used to identify a report.
496    pub key: Option<ReportKey>,
497    /// Report metadata.
498    pub metadata: Option<ReportMetadata>,
499    /// Report parameters.
500    pub params: Option<Parameters>,
501}
502
503impl common::Resource for Report {}
504
505/// An explanation of a report failure.
506///
507/// This type is not used in any activity, and only used as *part* of another schema.
508///
509#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
510#[serde_with::serde_as]
511#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
512pub struct ReportFailure {
513    /// Error code that shows why the report was not created.
514    #[serde(rename = "errorCode")]
515    pub error_code: Option<String>,
516}
517
518impl common::Part for ReportFailure {}
519
520/// Key used to identify a report.
521///
522/// This type is not used in any activity, and only used as *part* of another schema.
523///
524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
525#[serde_with::serde_as]
526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
527pub struct ReportKey {
528    /// Query ID.
529    #[serde(rename = "queryId")]
530    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
531    pub query_id: Option<i64>,
532    /// Report ID.
533    #[serde(rename = "reportId")]
534    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
535    pub report_id: Option<i64>,
536}
537
538impl common::Part for ReportKey {}
539
540/// Report metadata.
541///
542/// This type is not used in any activity, and only used as *part* of another schema.
543///
544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
545#[serde_with::serde_as]
546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
547pub struct ReportMetadata {
548    /// The path to the location in Google Cloud Storage where the report is stored.
549    #[serde(rename = "googleCloudStoragePath")]
550    pub google_cloud_storage_path: Option<String>,
551    /// The ending time for the data that is shown in the report.
552    #[serde(rename = "reportDataEndTimeMs")]
553    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
554    pub report_data_end_time_ms: Option<i64>,
555    /// The starting time for the data that is shown in the report.
556    #[serde(rename = "reportDataStartTimeMs")]
557    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
558    pub report_data_start_time_ms: Option<i64>,
559    /// Report status.
560    pub status: Option<ReportStatus>,
561}
562
563impl common::Part for ReportMetadata {}
564
565/// Report status.
566///
567/// This type is not used in any activity, and only used as *part* of another schema.
568///
569#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
570#[serde_with::serde_as]
571#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
572pub struct ReportStatus {
573    /// If the report failed, this records the cause.
574    pub failure: Option<ReportFailure>,
575    /// The time when this report either completed successfully or failed.
576    #[serde(rename = "finishTimeMs")]
577    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
578    pub finish_time_ms: Option<i64>,
579    /// The file type of the report.
580    pub format: Option<String>,
581    /// The state of the report.
582    pub state: Option<String>,
583}
584
585impl common::Part for ReportStatus {}
586
587/// Represents the upload status of a row in the request.
588///
589/// This type is not used in any activity, and only used as *part* of another schema.
590///
591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
592#[serde_with::serde_as]
593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
594pub struct RowStatus {
595    /// Whether the stored entity is changed as a result of upload.
596    pub changed: Option<bool>,
597    /// Entity Id.
598    #[serde(rename = "entityId")]
599    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
600    pub entity_id: Option<i64>,
601    /// Entity name.
602    #[serde(rename = "entityName")]
603    pub entity_name: Option<String>,
604    /// Reasons why the entity can't be uploaded.
605    pub errors: Option<Vec<String>>,
606    /// Whether the entity is persisted.
607    pub persisted: Option<bool>,
608    /// Row number.
609    #[serde(rename = "rowNumber")]
610    pub row_number: Option<i32>,
611}
612
613impl common::Part for RowStatus {}
614
615/// Request to run a stored query to generate a report.
616///
617/// # Activities
618///
619/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
620/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
621///
622/// * [runquery queries](QueryRunqueryCall) (request)
623#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
624#[serde_with::serde_as]
625#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
626pub struct RunQueryRequest {
627    /// Report data range used to generate the report.
628    #[serde(rename = "dataRange")]
629    pub data_range: Option<String>,
630    /// The ending time for the data that is shown in the report. Note, reportDataEndTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise.
631    #[serde(rename = "reportDataEndTimeMs")]
632    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
633    pub report_data_end_time_ms: Option<i64>,
634    /// The starting time for the data that is shown in the report. Note, reportDataStartTimeMs is required if dataRange is CUSTOM_DATES and ignored otherwise.
635    #[serde(rename = "reportDataStartTimeMs")]
636    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
637    pub report_data_start_time_ms: Option<i64>,
638    /// Canonical timezone code for report data time. Defaults to America/New_York.
639    #[serde(rename = "timezoneCode")]
640    pub timezone_code: Option<String>,
641}
642
643impl common::RequestValue for RunQueryRequest {}
644
645/// Request to upload line items.
646///
647/// # Activities
648///
649/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
650/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
651///
652/// * [uploadlineitems lineitems](LineitemUploadlineitemCall) (request)
653#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
654#[serde_with::serde_as]
655#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
656pub struct UploadLineItemsRequest {
657    /// Set to true to get upload status without actually persisting the line items.
658    #[serde(rename = "dryRun")]
659    pub dry_run: Option<bool>,
660    /// Format the line items are in. Default to CSV.
661    pub format: Option<String>,
662    /// Line items in CSV to upload. Refer to Entity Write File Format for more information on file format.
663    #[serde(rename = "lineItems")]
664    pub line_items: Option<String>,
665}
666
667impl common::RequestValue for UploadLineItemsRequest {}
668
669/// Upload line items response.
670///
671/// # Activities
672///
673/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
674/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
675///
676/// * [uploadlineitems lineitems](LineitemUploadlineitemCall) (response)
677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
678#[serde_with::serde_as]
679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
680pub struct UploadLineItemsResponse {
681    /// Status of upload.
682    #[serde(rename = "uploadStatus")]
683    pub upload_status: Option<UploadStatus>,
684}
685
686impl common::ResponseResult for UploadLineItemsResponse {}
687
688/// Represents the status of upload.
689///
690/// This type is not used in any activity, and only used as *part* of another schema.
691///
692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
693#[serde_with::serde_as]
694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
695pub struct UploadStatus {
696    /// Reasons why upload can't be completed.
697    pub errors: Option<Vec<String>>,
698    /// Per-row upload status.
699    #[serde(rename = "rowStatus")]
700    pub row_status: Option<Vec<RowStatus>>,
701}
702
703impl common::Part for UploadStatus {}
704
705// ###################
706// MethodBuilders ###
707// #################
708
709/// A builder providing access to all methods supported on *lineitem* resources.
710/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
711///
712/// # Example
713///
714/// Instantiate a resource builder
715///
716/// ```test_harness,no_run
717/// extern crate hyper;
718/// extern crate hyper_rustls;
719/// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
720///
721/// # async fn dox() {
722/// use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
723///
724/// let secret: yup_oauth2::ApplicationSecret = Default::default();
725/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
726///     .with_native_roots()
727///     .unwrap()
728///     .https_only()
729///     .enable_http2()
730///     .build();
731///
732/// let executor = hyper_util::rt::TokioExecutor::new();
733/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
734///     secret,
735///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
736///     yup_oauth2::client::CustomHyperClientBuilder::from(
737///         hyper_util::client::legacy::Client::builder(executor).build(connector),
738///     ),
739/// ).build().await.unwrap();
740///
741/// let client = hyper_util::client::legacy::Client::builder(
742///     hyper_util::rt::TokioExecutor::new()
743/// )
744/// .build(
745///     hyper_rustls::HttpsConnectorBuilder::new()
746///         .with_native_roots()
747///         .unwrap()
748///         .https_or_http()
749///         .enable_http2()
750///         .build()
751/// );
752/// let mut hub = DoubleClickBidManager::new(client, auth);
753/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
754/// // like `downloadlineitems(...)` and `uploadlineitems(...)`
755/// // to build up your call.
756/// let rb = hub.lineitems();
757/// # }
758/// ```
759pub struct LineitemMethods<'a, C>
760where
761    C: 'a,
762{
763    hub: &'a DoubleClickBidManager<C>,
764}
765
766impl<'a, C> common::MethodsBuilder for LineitemMethods<'a, C> {}
767
768impl<'a, C> LineitemMethods<'a, C> {
769    /// Create a builder to help you perform the following task:
770    ///
771    /// Retrieves line items in CSV format. YouTube & partners line items are not supported.
772    ///
773    /// # Arguments
774    ///
775    /// * `request` - No description provided.
776    pub fn downloadlineitems(
777        &self,
778        request: DownloadLineItemsRequest,
779    ) -> LineitemDownloadlineitemCall<'a, C> {
780        LineitemDownloadlineitemCall {
781            hub: self.hub,
782            _request: request,
783            _delegate: Default::default(),
784            _additional_params: Default::default(),
785            _scopes: Default::default(),
786        }
787    }
788
789    /// Create a builder to help you perform the following task:
790    ///
791    /// Uploads line items in CSV format. YouTube & partners line items are not supported.
792    ///
793    /// # Arguments
794    ///
795    /// * `request` - No description provided.
796    pub fn uploadlineitems(
797        &self,
798        request: UploadLineItemsRequest,
799    ) -> LineitemUploadlineitemCall<'a, C> {
800        LineitemUploadlineitemCall {
801            hub: self.hub,
802            _request: request,
803            _delegate: Default::default(),
804            _additional_params: Default::default(),
805            _scopes: Default::default(),
806        }
807    }
808}
809
810/// A builder providing access to all methods supported on *query* resources.
811/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
812///
813/// # Example
814///
815/// Instantiate a resource builder
816///
817/// ```test_harness,no_run
818/// extern crate hyper;
819/// extern crate hyper_rustls;
820/// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
821///
822/// # async fn dox() {
823/// use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
824///
825/// let secret: yup_oauth2::ApplicationSecret = Default::default();
826/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
827///     .with_native_roots()
828///     .unwrap()
829///     .https_only()
830///     .enable_http2()
831///     .build();
832///
833/// let executor = hyper_util::rt::TokioExecutor::new();
834/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
835///     secret,
836///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
837///     yup_oauth2::client::CustomHyperClientBuilder::from(
838///         hyper_util::client::legacy::Client::builder(executor).build(connector),
839///     ),
840/// ).build().await.unwrap();
841///
842/// let client = hyper_util::client::legacy::Client::builder(
843///     hyper_util::rt::TokioExecutor::new()
844/// )
845/// .build(
846///     hyper_rustls::HttpsConnectorBuilder::new()
847///         .with_native_roots()
848///         .unwrap()
849///         .https_or_http()
850///         .enable_http2()
851///         .build()
852/// );
853/// let mut hub = DoubleClickBidManager::new(client, auth);
854/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
855/// // like `createquery(...)`, `deletequery(...)`, `getquery(...)`, `listqueries(...)` and `runquery(...)`
856/// // to build up your call.
857/// let rb = hub.queries();
858/// # }
859/// ```
860pub struct QueryMethods<'a, C>
861where
862    C: 'a,
863{
864    hub: &'a DoubleClickBidManager<C>,
865}
866
867impl<'a, C> common::MethodsBuilder for QueryMethods<'a, C> {}
868
869impl<'a, C> QueryMethods<'a, C> {
870    /// Create a builder to help you perform the following task:
871    ///
872    /// Creates a query.
873    ///
874    /// # Arguments
875    ///
876    /// * `request` - No description provided.
877    pub fn createquery(&self, request: Query) -> QueryCreatequeryCall<'a, C> {
878        QueryCreatequeryCall {
879            hub: self.hub,
880            _request: request,
881            _delegate: Default::default(),
882            _additional_params: Default::default(),
883            _scopes: Default::default(),
884        }
885    }
886
887    /// Create a builder to help you perform the following task:
888    ///
889    /// Deletes a stored query as well as the associated stored reports.
890    ///
891    /// # Arguments
892    ///
893    /// * `queryId` - Query ID to delete.
894    pub fn deletequery(&self, query_id: i64) -> QueryDeletequeryCall<'a, C> {
895        QueryDeletequeryCall {
896            hub: self.hub,
897            _query_id: query_id,
898            _delegate: Default::default(),
899            _additional_params: Default::default(),
900            _scopes: Default::default(),
901        }
902    }
903
904    /// Create a builder to help you perform the following task:
905    ///
906    /// Retrieves a stored query.
907    ///
908    /// # Arguments
909    ///
910    /// * `queryId` - Query ID to retrieve.
911    pub fn getquery(&self, query_id: i64) -> QueryGetqueryCall<'a, C> {
912        QueryGetqueryCall {
913            hub: self.hub,
914            _query_id: query_id,
915            _delegate: Default::default(),
916            _additional_params: Default::default(),
917            _scopes: Default::default(),
918        }
919    }
920
921    /// Create a builder to help you perform the following task:
922    ///
923    /// Retrieves stored queries.
924    pub fn listqueries(&self) -> QueryListqueryCall<'a, C> {
925        QueryListqueryCall {
926            hub: self.hub,
927            _delegate: Default::default(),
928            _additional_params: Default::default(),
929            _scopes: Default::default(),
930        }
931    }
932
933    /// Create a builder to help you perform the following task:
934    ///
935    /// Runs a stored query to generate a report.
936    ///
937    /// # Arguments
938    ///
939    /// * `request` - No description provided.
940    /// * `queryId` - Query ID to run.
941    pub fn runquery(&self, request: RunQueryRequest, query_id: i64) -> QueryRunqueryCall<'a, C> {
942        QueryRunqueryCall {
943            hub: self.hub,
944            _request: request,
945            _query_id: query_id,
946            _delegate: Default::default(),
947            _additional_params: Default::default(),
948            _scopes: Default::default(),
949        }
950    }
951}
952
953/// A builder providing access to all methods supported on *report* resources.
954/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
955///
956/// # Example
957///
958/// Instantiate a resource builder
959///
960/// ```test_harness,no_run
961/// extern crate hyper;
962/// extern crate hyper_rustls;
963/// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
964///
965/// # async fn dox() {
966/// use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
967///
968/// let secret: yup_oauth2::ApplicationSecret = Default::default();
969/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
970///     .with_native_roots()
971///     .unwrap()
972///     .https_only()
973///     .enable_http2()
974///     .build();
975///
976/// let executor = hyper_util::rt::TokioExecutor::new();
977/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
978///     secret,
979///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
980///     yup_oauth2::client::CustomHyperClientBuilder::from(
981///         hyper_util::client::legacy::Client::builder(executor).build(connector),
982///     ),
983/// ).build().await.unwrap();
984///
985/// let client = hyper_util::client::legacy::Client::builder(
986///     hyper_util::rt::TokioExecutor::new()
987/// )
988/// .build(
989///     hyper_rustls::HttpsConnectorBuilder::new()
990///         .with_native_roots()
991///         .unwrap()
992///         .https_or_http()
993///         .enable_http2()
994///         .build()
995/// );
996/// let mut hub = DoubleClickBidManager::new(client, auth);
997/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
998/// // like `listreports(...)`
999/// // to build up your call.
1000/// let rb = hub.reports();
1001/// # }
1002/// ```
1003pub struct ReportMethods<'a, C>
1004where
1005    C: 'a,
1006{
1007    hub: &'a DoubleClickBidManager<C>,
1008}
1009
1010impl<'a, C> common::MethodsBuilder for ReportMethods<'a, C> {}
1011
1012impl<'a, C> ReportMethods<'a, C> {
1013    /// Create a builder to help you perform the following task:
1014    ///
1015    /// Retrieves stored reports.
1016    ///
1017    /// # Arguments
1018    ///
1019    /// * `queryId` - Query ID with which the reports are associated.
1020    pub fn listreports(&self, query_id: i64) -> ReportListreportCall<'a, C> {
1021        ReportListreportCall {
1022            hub: self.hub,
1023            _query_id: query_id,
1024            _delegate: Default::default(),
1025            _additional_params: Default::default(),
1026            _scopes: Default::default(),
1027        }
1028    }
1029}
1030
1031/// A builder providing access to all methods supported on *sdf* resources.
1032/// It is not used directly, but through the [`DoubleClickBidManager`] hub.
1033///
1034/// # Example
1035///
1036/// Instantiate a resource builder
1037///
1038/// ```test_harness,no_run
1039/// extern crate hyper;
1040/// extern crate hyper_rustls;
1041/// extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
1042///
1043/// # async fn dox() {
1044/// use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1045///
1046/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1047/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1048///     .with_native_roots()
1049///     .unwrap()
1050///     .https_only()
1051///     .enable_http2()
1052///     .build();
1053///
1054/// let executor = hyper_util::rt::TokioExecutor::new();
1055/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1056///     secret,
1057///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1058///     yup_oauth2::client::CustomHyperClientBuilder::from(
1059///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1060///     ),
1061/// ).build().await.unwrap();
1062///
1063/// let client = hyper_util::client::legacy::Client::builder(
1064///     hyper_util::rt::TokioExecutor::new()
1065/// )
1066/// .build(
1067///     hyper_rustls::HttpsConnectorBuilder::new()
1068///         .with_native_roots()
1069///         .unwrap()
1070///         .https_or_http()
1071///         .enable_http2()
1072///         .build()
1073/// );
1074/// let mut hub = DoubleClickBidManager::new(client, auth);
1075/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1076/// // like `download(...)`
1077/// // to build up your call.
1078/// let rb = hub.sdf();
1079/// # }
1080/// ```
1081pub struct SdfMethods<'a, C>
1082where
1083    C: 'a,
1084{
1085    hub: &'a DoubleClickBidManager<C>,
1086}
1087
1088impl<'a, C> common::MethodsBuilder for SdfMethods<'a, C> {}
1089
1090impl<'a, C> SdfMethods<'a, C> {
1091    /// Create a builder to help you perform the following task:
1092    ///
1093    /// Retrieves entities in SDF format.
1094    ///
1095    /// # Arguments
1096    ///
1097    /// * `request` - No description provided.
1098    pub fn download(&self, request: DownloadRequest) -> SdfDownloadCall<'a, C> {
1099        SdfDownloadCall {
1100            hub: self.hub,
1101            _request: request,
1102            _delegate: Default::default(),
1103            _additional_params: Default::default(),
1104            _scopes: Default::default(),
1105        }
1106    }
1107}
1108
1109// ###################
1110// CallBuilders   ###
1111// #################
1112
1113/// Retrieves line items in CSV format. YouTube & partners line items are not supported.
1114///
1115/// A builder for the *downloadlineitems* method supported by a *lineitem* resource.
1116/// It is not used directly, but through a [`LineitemMethods`] instance.
1117///
1118/// # Example
1119///
1120/// Instantiate a resource method builder
1121///
1122/// ```test_harness,no_run
1123/// # extern crate hyper;
1124/// # extern crate hyper_rustls;
1125/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
1126/// use doubleclickbidmanager1::api::DownloadLineItemsRequest;
1127/// # async fn dox() {
1128/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1129///
1130/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1131/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1132/// #     .with_native_roots()
1133/// #     .unwrap()
1134/// #     .https_only()
1135/// #     .enable_http2()
1136/// #     .build();
1137///
1138/// # let executor = hyper_util::rt::TokioExecutor::new();
1139/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1140/// #     secret,
1141/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1142/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1143/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1144/// #     ),
1145/// # ).build().await.unwrap();
1146///
1147/// # let client = hyper_util::client::legacy::Client::builder(
1148/// #     hyper_util::rt::TokioExecutor::new()
1149/// # )
1150/// # .build(
1151/// #     hyper_rustls::HttpsConnectorBuilder::new()
1152/// #         .with_native_roots()
1153/// #         .unwrap()
1154/// #         .https_or_http()
1155/// #         .enable_http2()
1156/// #         .build()
1157/// # );
1158/// # let mut hub = DoubleClickBidManager::new(client, auth);
1159/// // As the method needs a request, you would usually fill it with the desired information
1160/// // into the respective structure. Some of the parts shown here might not be applicable !
1161/// // Values shown here are possibly random and not representative !
1162/// let mut req = DownloadLineItemsRequest::default();
1163///
1164/// // You can configure optional parameters by calling the respective setters at will, and
1165/// // execute the final call using `doit()`.
1166/// // Values shown here are possibly random and not representative !
1167/// let result = hub.lineitems().downloadlineitems(req)
1168///              .doit().await;
1169/// # }
1170/// ```
1171pub struct LineitemDownloadlineitemCall<'a, C>
1172where
1173    C: 'a,
1174{
1175    hub: &'a DoubleClickBidManager<C>,
1176    _request: DownloadLineItemsRequest,
1177    _delegate: Option<&'a mut dyn common::Delegate>,
1178    _additional_params: HashMap<String, String>,
1179    _scopes: BTreeSet<String>,
1180}
1181
1182impl<'a, C> common::CallBuilder for LineitemDownloadlineitemCall<'a, C> {}
1183
1184impl<'a, C> LineitemDownloadlineitemCall<'a, C>
1185where
1186    C: common::Connector,
1187{
1188    /// Perform the operation you have build so far.
1189    pub async fn doit(mut self) -> common::Result<(common::Response, DownloadLineItemsResponse)> {
1190        use std::borrow::Cow;
1191        use std::io::{Read, Seek};
1192
1193        use common::{url::Params, ToParts};
1194        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1195
1196        let mut dd = common::DefaultDelegate;
1197        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1198        dlg.begin(common::MethodInfo {
1199            id: "doubleclickbidmanager.lineitems.downloadlineitems",
1200            http_method: hyper::Method::POST,
1201        });
1202
1203        for &field in ["alt"].iter() {
1204            if self._additional_params.contains_key(field) {
1205                dlg.finished(false);
1206                return Err(common::Error::FieldClash(field));
1207            }
1208        }
1209
1210        let mut params = Params::with_capacity(3 + self._additional_params.len());
1211
1212        params.extend(self._additional_params.iter());
1213
1214        params.push("alt", "json");
1215        let mut url = self.hub._base_url.clone() + "lineitems/downloadlineitems";
1216        if self._scopes.is_empty() {
1217            self._scopes.insert(Scope::Full.as_ref().to_string());
1218        }
1219
1220        let url = params.parse_with_url(&url);
1221
1222        let mut json_mime_type = mime::APPLICATION_JSON;
1223        let mut request_value_reader = {
1224            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1225            common::remove_json_null_values(&mut value);
1226            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1227            serde_json::to_writer(&mut dst, &value).unwrap();
1228            dst
1229        };
1230        let request_size = request_value_reader
1231            .seek(std::io::SeekFrom::End(0))
1232            .unwrap();
1233        request_value_reader
1234            .seek(std::io::SeekFrom::Start(0))
1235            .unwrap();
1236
1237        loop {
1238            let token = match self
1239                .hub
1240                .auth
1241                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1242                .await
1243            {
1244                Ok(token) => token,
1245                Err(e) => match dlg.token(e) {
1246                    Ok(token) => token,
1247                    Err(e) => {
1248                        dlg.finished(false);
1249                        return Err(common::Error::MissingToken(e));
1250                    }
1251                },
1252            };
1253            request_value_reader
1254                .seek(std::io::SeekFrom::Start(0))
1255                .unwrap();
1256            let mut req_result = {
1257                let client = &self.hub.client;
1258                dlg.pre_request();
1259                let mut req_builder = hyper::Request::builder()
1260                    .method(hyper::Method::POST)
1261                    .uri(url.as_str())
1262                    .header(USER_AGENT, self.hub._user_agent.clone());
1263
1264                if let Some(token) = token.as_ref() {
1265                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1266                }
1267
1268                let request = req_builder
1269                    .header(CONTENT_TYPE, json_mime_type.to_string())
1270                    .header(CONTENT_LENGTH, request_size as u64)
1271                    .body(common::to_body(
1272                        request_value_reader.get_ref().clone().into(),
1273                    ));
1274
1275                client.request(request.unwrap()).await
1276            };
1277
1278            match req_result {
1279                Err(err) => {
1280                    if let common::Retry::After(d) = dlg.http_error(&err) {
1281                        sleep(d).await;
1282                        continue;
1283                    }
1284                    dlg.finished(false);
1285                    return Err(common::Error::HttpError(err));
1286                }
1287                Ok(res) => {
1288                    let (mut parts, body) = res.into_parts();
1289                    let mut body = common::Body::new(body);
1290                    if !parts.status.is_success() {
1291                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1292                        let error = serde_json::from_str(&common::to_string(&bytes));
1293                        let response = common::to_response(parts, bytes.into());
1294
1295                        if let common::Retry::After(d) =
1296                            dlg.http_failure(&response, error.as_ref().ok())
1297                        {
1298                            sleep(d).await;
1299                            continue;
1300                        }
1301
1302                        dlg.finished(false);
1303
1304                        return Err(match error {
1305                            Ok(value) => common::Error::BadRequest(value),
1306                            _ => common::Error::Failure(response),
1307                        });
1308                    }
1309                    let response = {
1310                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1311                        let encoded = common::to_string(&bytes);
1312                        match serde_json::from_str(&encoded) {
1313                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1314                            Err(error) => {
1315                                dlg.response_json_decode_error(&encoded, &error);
1316                                return Err(common::Error::JsonDecodeError(
1317                                    encoded.to_string(),
1318                                    error,
1319                                ));
1320                            }
1321                        }
1322                    };
1323
1324                    dlg.finished(true);
1325                    return Ok(response);
1326                }
1327            }
1328        }
1329    }
1330
1331    ///
1332    /// Sets the *request* property to the given value.
1333    ///
1334    /// Even though the property as already been set when instantiating this call,
1335    /// we provide this method for API completeness.
1336    pub fn request(
1337        mut self,
1338        new_value: DownloadLineItemsRequest,
1339    ) -> LineitemDownloadlineitemCall<'a, C> {
1340        self._request = new_value;
1341        self
1342    }
1343    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1344    /// while executing the actual API request.
1345    ///
1346    /// ````text
1347    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1348    /// ````
1349    ///
1350    /// Sets the *delegate* property to the given value.
1351    pub fn delegate(
1352        mut self,
1353        new_value: &'a mut dyn common::Delegate,
1354    ) -> LineitemDownloadlineitemCall<'a, C> {
1355        self._delegate = Some(new_value);
1356        self
1357    }
1358
1359    /// Set any additional parameter of the query string used in the request.
1360    /// It should be used to set parameters which are not yet available through their own
1361    /// setters.
1362    ///
1363    /// Please note that this method must not be used to set any of the known parameters
1364    /// which have their own setter method. If done anyway, the request will fail.
1365    ///
1366    /// # Additional Parameters
1367    ///
1368    /// * *$.xgafv* (query-string) - V1 error format.
1369    /// * *access_token* (query-string) - OAuth access token.
1370    /// * *alt* (query-string) - Data format for response.
1371    /// * *callback* (query-string) - JSONP
1372    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1373    /// * *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.
1374    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1375    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1376    /// * *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.
1377    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1378    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1379    pub fn param<T>(mut self, name: T, value: T) -> LineitemDownloadlineitemCall<'a, C>
1380    where
1381        T: AsRef<str>,
1382    {
1383        self._additional_params
1384            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1385        self
1386    }
1387
1388    /// Identifies the authorization scope for the method you are building.
1389    ///
1390    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1391    /// [`Scope::Full`].
1392    ///
1393    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1394    /// tokens for more than one scope.
1395    ///
1396    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1397    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1398    /// sufficient, a read-write scope will do as well.
1399    pub fn add_scope<St>(mut self, scope: St) -> LineitemDownloadlineitemCall<'a, C>
1400    where
1401        St: AsRef<str>,
1402    {
1403        self._scopes.insert(String::from(scope.as_ref()));
1404        self
1405    }
1406    /// Identifies the authorization scope(s) for the method you are building.
1407    ///
1408    /// See [`Self::add_scope()`] for details.
1409    pub fn add_scopes<I, St>(mut self, scopes: I) -> LineitemDownloadlineitemCall<'a, C>
1410    where
1411        I: IntoIterator<Item = St>,
1412        St: AsRef<str>,
1413    {
1414        self._scopes
1415            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1416        self
1417    }
1418
1419    /// Removes all scopes, and no default scope will be used either.
1420    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1421    /// for details).
1422    pub fn clear_scopes(mut self) -> LineitemDownloadlineitemCall<'a, C> {
1423        self._scopes.clear();
1424        self
1425    }
1426}
1427
1428/// Uploads line items in CSV format. YouTube & partners line items are not supported.
1429///
1430/// A builder for the *uploadlineitems* method supported by a *lineitem* resource.
1431/// It is not used directly, but through a [`LineitemMethods`] instance.
1432///
1433/// # Example
1434///
1435/// Instantiate a resource method builder
1436///
1437/// ```test_harness,no_run
1438/// # extern crate hyper;
1439/// # extern crate hyper_rustls;
1440/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
1441/// use doubleclickbidmanager1::api::UploadLineItemsRequest;
1442/// # async fn dox() {
1443/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1444///
1445/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1446/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1447/// #     .with_native_roots()
1448/// #     .unwrap()
1449/// #     .https_only()
1450/// #     .enable_http2()
1451/// #     .build();
1452///
1453/// # let executor = hyper_util::rt::TokioExecutor::new();
1454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1455/// #     secret,
1456/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1457/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1458/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1459/// #     ),
1460/// # ).build().await.unwrap();
1461///
1462/// # let client = hyper_util::client::legacy::Client::builder(
1463/// #     hyper_util::rt::TokioExecutor::new()
1464/// # )
1465/// # .build(
1466/// #     hyper_rustls::HttpsConnectorBuilder::new()
1467/// #         .with_native_roots()
1468/// #         .unwrap()
1469/// #         .https_or_http()
1470/// #         .enable_http2()
1471/// #         .build()
1472/// # );
1473/// # let mut hub = DoubleClickBidManager::new(client, auth);
1474/// // As the method needs a request, you would usually fill it with the desired information
1475/// // into the respective structure. Some of the parts shown here might not be applicable !
1476/// // Values shown here are possibly random and not representative !
1477/// let mut req = UploadLineItemsRequest::default();
1478///
1479/// // You can configure optional parameters by calling the respective setters at will, and
1480/// // execute the final call using `doit()`.
1481/// // Values shown here are possibly random and not representative !
1482/// let result = hub.lineitems().uploadlineitems(req)
1483///              .doit().await;
1484/// # }
1485/// ```
1486pub struct LineitemUploadlineitemCall<'a, C>
1487where
1488    C: 'a,
1489{
1490    hub: &'a DoubleClickBidManager<C>,
1491    _request: UploadLineItemsRequest,
1492    _delegate: Option<&'a mut dyn common::Delegate>,
1493    _additional_params: HashMap<String, String>,
1494    _scopes: BTreeSet<String>,
1495}
1496
1497impl<'a, C> common::CallBuilder for LineitemUploadlineitemCall<'a, C> {}
1498
1499impl<'a, C> LineitemUploadlineitemCall<'a, C>
1500where
1501    C: common::Connector,
1502{
1503    /// Perform the operation you have build so far.
1504    pub async fn doit(mut self) -> common::Result<(common::Response, UploadLineItemsResponse)> {
1505        use std::borrow::Cow;
1506        use std::io::{Read, Seek};
1507
1508        use common::{url::Params, ToParts};
1509        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1510
1511        let mut dd = common::DefaultDelegate;
1512        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1513        dlg.begin(common::MethodInfo {
1514            id: "doubleclickbidmanager.lineitems.uploadlineitems",
1515            http_method: hyper::Method::POST,
1516        });
1517
1518        for &field in ["alt"].iter() {
1519            if self._additional_params.contains_key(field) {
1520                dlg.finished(false);
1521                return Err(common::Error::FieldClash(field));
1522            }
1523        }
1524
1525        let mut params = Params::with_capacity(3 + self._additional_params.len());
1526
1527        params.extend(self._additional_params.iter());
1528
1529        params.push("alt", "json");
1530        let mut url = self.hub._base_url.clone() + "lineitems/uploadlineitems";
1531        if self._scopes.is_empty() {
1532            self._scopes.insert(Scope::Full.as_ref().to_string());
1533        }
1534
1535        let url = params.parse_with_url(&url);
1536
1537        let mut json_mime_type = mime::APPLICATION_JSON;
1538        let mut request_value_reader = {
1539            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1540            common::remove_json_null_values(&mut value);
1541            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1542            serde_json::to_writer(&mut dst, &value).unwrap();
1543            dst
1544        };
1545        let request_size = request_value_reader
1546            .seek(std::io::SeekFrom::End(0))
1547            .unwrap();
1548        request_value_reader
1549            .seek(std::io::SeekFrom::Start(0))
1550            .unwrap();
1551
1552        loop {
1553            let token = match self
1554                .hub
1555                .auth
1556                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1557                .await
1558            {
1559                Ok(token) => token,
1560                Err(e) => match dlg.token(e) {
1561                    Ok(token) => token,
1562                    Err(e) => {
1563                        dlg.finished(false);
1564                        return Err(common::Error::MissingToken(e));
1565                    }
1566                },
1567            };
1568            request_value_reader
1569                .seek(std::io::SeekFrom::Start(0))
1570                .unwrap();
1571            let mut req_result = {
1572                let client = &self.hub.client;
1573                dlg.pre_request();
1574                let mut req_builder = hyper::Request::builder()
1575                    .method(hyper::Method::POST)
1576                    .uri(url.as_str())
1577                    .header(USER_AGENT, self.hub._user_agent.clone());
1578
1579                if let Some(token) = token.as_ref() {
1580                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1581                }
1582
1583                let request = req_builder
1584                    .header(CONTENT_TYPE, json_mime_type.to_string())
1585                    .header(CONTENT_LENGTH, request_size as u64)
1586                    .body(common::to_body(
1587                        request_value_reader.get_ref().clone().into(),
1588                    ));
1589
1590                client.request(request.unwrap()).await
1591            };
1592
1593            match req_result {
1594                Err(err) => {
1595                    if let common::Retry::After(d) = dlg.http_error(&err) {
1596                        sleep(d).await;
1597                        continue;
1598                    }
1599                    dlg.finished(false);
1600                    return Err(common::Error::HttpError(err));
1601                }
1602                Ok(res) => {
1603                    let (mut parts, body) = res.into_parts();
1604                    let mut body = common::Body::new(body);
1605                    if !parts.status.is_success() {
1606                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1607                        let error = serde_json::from_str(&common::to_string(&bytes));
1608                        let response = common::to_response(parts, bytes.into());
1609
1610                        if let common::Retry::After(d) =
1611                            dlg.http_failure(&response, error.as_ref().ok())
1612                        {
1613                            sleep(d).await;
1614                            continue;
1615                        }
1616
1617                        dlg.finished(false);
1618
1619                        return Err(match error {
1620                            Ok(value) => common::Error::BadRequest(value),
1621                            _ => common::Error::Failure(response),
1622                        });
1623                    }
1624                    let response = {
1625                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1626                        let encoded = common::to_string(&bytes);
1627                        match serde_json::from_str(&encoded) {
1628                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1629                            Err(error) => {
1630                                dlg.response_json_decode_error(&encoded, &error);
1631                                return Err(common::Error::JsonDecodeError(
1632                                    encoded.to_string(),
1633                                    error,
1634                                ));
1635                            }
1636                        }
1637                    };
1638
1639                    dlg.finished(true);
1640                    return Ok(response);
1641                }
1642            }
1643        }
1644    }
1645
1646    ///
1647    /// Sets the *request* property to the given value.
1648    ///
1649    /// Even though the property as already been set when instantiating this call,
1650    /// we provide this method for API completeness.
1651    pub fn request(
1652        mut self,
1653        new_value: UploadLineItemsRequest,
1654    ) -> LineitemUploadlineitemCall<'a, C> {
1655        self._request = new_value;
1656        self
1657    }
1658    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1659    /// while executing the actual API request.
1660    ///
1661    /// ````text
1662    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1663    /// ````
1664    ///
1665    /// Sets the *delegate* property to the given value.
1666    pub fn delegate(
1667        mut self,
1668        new_value: &'a mut dyn common::Delegate,
1669    ) -> LineitemUploadlineitemCall<'a, C> {
1670        self._delegate = Some(new_value);
1671        self
1672    }
1673
1674    /// Set any additional parameter of the query string used in the request.
1675    /// It should be used to set parameters which are not yet available through their own
1676    /// setters.
1677    ///
1678    /// Please note that this method must not be used to set any of the known parameters
1679    /// which have their own setter method. If done anyway, the request will fail.
1680    ///
1681    /// # Additional Parameters
1682    ///
1683    /// * *$.xgafv* (query-string) - V1 error format.
1684    /// * *access_token* (query-string) - OAuth access token.
1685    /// * *alt* (query-string) - Data format for response.
1686    /// * *callback* (query-string) - JSONP
1687    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1688    /// * *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.
1689    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1690    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1691    /// * *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.
1692    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1693    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1694    pub fn param<T>(mut self, name: T, value: T) -> LineitemUploadlineitemCall<'a, C>
1695    where
1696        T: AsRef<str>,
1697    {
1698        self._additional_params
1699            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1700        self
1701    }
1702
1703    /// Identifies the authorization scope for the method you are building.
1704    ///
1705    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1706    /// [`Scope::Full`].
1707    ///
1708    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1709    /// tokens for more than one scope.
1710    ///
1711    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1712    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1713    /// sufficient, a read-write scope will do as well.
1714    pub fn add_scope<St>(mut self, scope: St) -> LineitemUploadlineitemCall<'a, C>
1715    where
1716        St: AsRef<str>,
1717    {
1718        self._scopes.insert(String::from(scope.as_ref()));
1719        self
1720    }
1721    /// Identifies the authorization scope(s) for the method you are building.
1722    ///
1723    /// See [`Self::add_scope()`] for details.
1724    pub fn add_scopes<I, St>(mut self, scopes: I) -> LineitemUploadlineitemCall<'a, C>
1725    where
1726        I: IntoIterator<Item = St>,
1727        St: AsRef<str>,
1728    {
1729        self._scopes
1730            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1731        self
1732    }
1733
1734    /// Removes all scopes, and no default scope will be used either.
1735    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1736    /// for details).
1737    pub fn clear_scopes(mut self) -> LineitemUploadlineitemCall<'a, C> {
1738        self._scopes.clear();
1739        self
1740    }
1741}
1742
1743/// Creates a query.
1744///
1745/// A builder for the *createquery* method supported by a *query* resource.
1746/// It is not used directly, but through a [`QueryMethods`] instance.
1747///
1748/// # Example
1749///
1750/// Instantiate a resource method builder
1751///
1752/// ```test_harness,no_run
1753/// # extern crate hyper;
1754/// # extern crate hyper_rustls;
1755/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
1756/// use doubleclickbidmanager1::api::Query;
1757/// # async fn dox() {
1758/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1759///
1760/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1761/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1762/// #     .with_native_roots()
1763/// #     .unwrap()
1764/// #     .https_only()
1765/// #     .enable_http2()
1766/// #     .build();
1767///
1768/// # let executor = hyper_util::rt::TokioExecutor::new();
1769/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1770/// #     secret,
1771/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1772/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1773/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1774/// #     ),
1775/// # ).build().await.unwrap();
1776///
1777/// # let client = hyper_util::client::legacy::Client::builder(
1778/// #     hyper_util::rt::TokioExecutor::new()
1779/// # )
1780/// # .build(
1781/// #     hyper_rustls::HttpsConnectorBuilder::new()
1782/// #         .with_native_roots()
1783/// #         .unwrap()
1784/// #         .https_or_http()
1785/// #         .enable_http2()
1786/// #         .build()
1787/// # );
1788/// # let mut hub = DoubleClickBidManager::new(client, auth);
1789/// // As the method needs a request, you would usually fill it with the desired information
1790/// // into the respective structure. Some of the parts shown here might not be applicable !
1791/// // Values shown here are possibly random and not representative !
1792/// let mut req = Query::default();
1793///
1794/// // You can configure optional parameters by calling the respective setters at will, and
1795/// // execute the final call using `doit()`.
1796/// // Values shown here are possibly random and not representative !
1797/// let result = hub.queries().createquery(req)
1798///              .doit().await;
1799/// # }
1800/// ```
1801pub struct QueryCreatequeryCall<'a, C>
1802where
1803    C: 'a,
1804{
1805    hub: &'a DoubleClickBidManager<C>,
1806    _request: Query,
1807    _delegate: Option<&'a mut dyn common::Delegate>,
1808    _additional_params: HashMap<String, String>,
1809    _scopes: BTreeSet<String>,
1810}
1811
1812impl<'a, C> common::CallBuilder for QueryCreatequeryCall<'a, C> {}
1813
1814impl<'a, C> QueryCreatequeryCall<'a, C>
1815where
1816    C: common::Connector,
1817{
1818    /// Perform the operation you have build so far.
1819    pub async fn doit(mut self) -> common::Result<(common::Response, Query)> {
1820        use std::borrow::Cow;
1821        use std::io::{Read, Seek};
1822
1823        use common::{url::Params, ToParts};
1824        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1825
1826        let mut dd = common::DefaultDelegate;
1827        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1828        dlg.begin(common::MethodInfo {
1829            id: "doubleclickbidmanager.queries.createquery",
1830            http_method: hyper::Method::POST,
1831        });
1832
1833        for &field in ["alt"].iter() {
1834            if self._additional_params.contains_key(field) {
1835                dlg.finished(false);
1836                return Err(common::Error::FieldClash(field));
1837            }
1838        }
1839
1840        let mut params = Params::with_capacity(3 + self._additional_params.len());
1841
1842        params.extend(self._additional_params.iter());
1843
1844        params.push("alt", "json");
1845        let mut url = self.hub._base_url.clone() + "query";
1846        if self._scopes.is_empty() {
1847            self._scopes.insert(Scope::Full.as_ref().to_string());
1848        }
1849
1850        let url = params.parse_with_url(&url);
1851
1852        let mut json_mime_type = mime::APPLICATION_JSON;
1853        let mut request_value_reader = {
1854            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1855            common::remove_json_null_values(&mut value);
1856            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1857            serde_json::to_writer(&mut dst, &value).unwrap();
1858            dst
1859        };
1860        let request_size = request_value_reader
1861            .seek(std::io::SeekFrom::End(0))
1862            .unwrap();
1863        request_value_reader
1864            .seek(std::io::SeekFrom::Start(0))
1865            .unwrap();
1866
1867        loop {
1868            let token = match self
1869                .hub
1870                .auth
1871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1872                .await
1873            {
1874                Ok(token) => token,
1875                Err(e) => match dlg.token(e) {
1876                    Ok(token) => token,
1877                    Err(e) => {
1878                        dlg.finished(false);
1879                        return Err(common::Error::MissingToken(e));
1880                    }
1881                },
1882            };
1883            request_value_reader
1884                .seek(std::io::SeekFrom::Start(0))
1885                .unwrap();
1886            let mut req_result = {
1887                let client = &self.hub.client;
1888                dlg.pre_request();
1889                let mut req_builder = hyper::Request::builder()
1890                    .method(hyper::Method::POST)
1891                    .uri(url.as_str())
1892                    .header(USER_AGENT, self.hub._user_agent.clone());
1893
1894                if let Some(token) = token.as_ref() {
1895                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1896                }
1897
1898                let request = req_builder
1899                    .header(CONTENT_TYPE, json_mime_type.to_string())
1900                    .header(CONTENT_LENGTH, request_size as u64)
1901                    .body(common::to_body(
1902                        request_value_reader.get_ref().clone().into(),
1903                    ));
1904
1905                client.request(request.unwrap()).await
1906            };
1907
1908            match req_result {
1909                Err(err) => {
1910                    if let common::Retry::After(d) = dlg.http_error(&err) {
1911                        sleep(d).await;
1912                        continue;
1913                    }
1914                    dlg.finished(false);
1915                    return Err(common::Error::HttpError(err));
1916                }
1917                Ok(res) => {
1918                    let (mut parts, body) = res.into_parts();
1919                    let mut body = common::Body::new(body);
1920                    if !parts.status.is_success() {
1921                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1922                        let error = serde_json::from_str(&common::to_string(&bytes));
1923                        let response = common::to_response(parts, bytes.into());
1924
1925                        if let common::Retry::After(d) =
1926                            dlg.http_failure(&response, error.as_ref().ok())
1927                        {
1928                            sleep(d).await;
1929                            continue;
1930                        }
1931
1932                        dlg.finished(false);
1933
1934                        return Err(match error {
1935                            Ok(value) => common::Error::BadRequest(value),
1936                            _ => common::Error::Failure(response),
1937                        });
1938                    }
1939                    let response = {
1940                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1941                        let encoded = common::to_string(&bytes);
1942                        match serde_json::from_str(&encoded) {
1943                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1944                            Err(error) => {
1945                                dlg.response_json_decode_error(&encoded, &error);
1946                                return Err(common::Error::JsonDecodeError(
1947                                    encoded.to_string(),
1948                                    error,
1949                                ));
1950                            }
1951                        }
1952                    };
1953
1954                    dlg.finished(true);
1955                    return Ok(response);
1956                }
1957            }
1958        }
1959    }
1960
1961    ///
1962    /// Sets the *request* property to the given value.
1963    ///
1964    /// Even though the property as already been set when instantiating this call,
1965    /// we provide this method for API completeness.
1966    pub fn request(mut self, new_value: Query) -> QueryCreatequeryCall<'a, C> {
1967        self._request = new_value;
1968        self
1969    }
1970    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1971    /// while executing the actual API request.
1972    ///
1973    /// ````text
1974    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1975    /// ````
1976    ///
1977    /// Sets the *delegate* property to the given value.
1978    pub fn delegate(
1979        mut self,
1980        new_value: &'a mut dyn common::Delegate,
1981    ) -> QueryCreatequeryCall<'a, C> {
1982        self._delegate = Some(new_value);
1983        self
1984    }
1985
1986    /// Set any additional parameter of the query string used in the request.
1987    /// It should be used to set parameters which are not yet available through their own
1988    /// setters.
1989    ///
1990    /// Please note that this method must not be used to set any of the known parameters
1991    /// which have their own setter method. If done anyway, the request will fail.
1992    ///
1993    /// # Additional Parameters
1994    ///
1995    /// * *$.xgafv* (query-string) - V1 error format.
1996    /// * *access_token* (query-string) - OAuth access token.
1997    /// * *alt* (query-string) - Data format for response.
1998    /// * *callback* (query-string) - JSONP
1999    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2000    /// * *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.
2001    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2002    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2003    /// * *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.
2004    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2005    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2006    pub fn param<T>(mut self, name: T, value: T) -> QueryCreatequeryCall<'a, C>
2007    where
2008        T: AsRef<str>,
2009    {
2010        self._additional_params
2011            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2012        self
2013    }
2014
2015    /// Identifies the authorization scope for the method you are building.
2016    ///
2017    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2018    /// [`Scope::Full`].
2019    ///
2020    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2021    /// tokens for more than one scope.
2022    ///
2023    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2024    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2025    /// sufficient, a read-write scope will do as well.
2026    pub fn add_scope<St>(mut self, scope: St) -> QueryCreatequeryCall<'a, C>
2027    where
2028        St: AsRef<str>,
2029    {
2030        self._scopes.insert(String::from(scope.as_ref()));
2031        self
2032    }
2033    /// Identifies the authorization scope(s) for the method you are building.
2034    ///
2035    /// See [`Self::add_scope()`] for details.
2036    pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryCreatequeryCall<'a, C>
2037    where
2038        I: IntoIterator<Item = St>,
2039        St: AsRef<str>,
2040    {
2041        self._scopes
2042            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2043        self
2044    }
2045
2046    /// Removes all scopes, and no default scope will be used either.
2047    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2048    /// for details).
2049    pub fn clear_scopes(mut self) -> QueryCreatequeryCall<'a, C> {
2050        self._scopes.clear();
2051        self
2052    }
2053}
2054
2055/// Deletes a stored query as well as the associated stored reports.
2056///
2057/// A builder for the *deletequery* method supported by a *query* resource.
2058/// It is not used directly, but through a [`QueryMethods`] instance.
2059///
2060/// # Example
2061///
2062/// Instantiate a resource method builder
2063///
2064/// ```test_harness,no_run
2065/// # extern crate hyper;
2066/// # extern crate hyper_rustls;
2067/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
2068/// # async fn dox() {
2069/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2070///
2071/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2072/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2073/// #     .with_native_roots()
2074/// #     .unwrap()
2075/// #     .https_only()
2076/// #     .enable_http2()
2077/// #     .build();
2078///
2079/// # let executor = hyper_util::rt::TokioExecutor::new();
2080/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2081/// #     secret,
2082/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2083/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2084/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2085/// #     ),
2086/// # ).build().await.unwrap();
2087///
2088/// # let client = hyper_util::client::legacy::Client::builder(
2089/// #     hyper_util::rt::TokioExecutor::new()
2090/// # )
2091/// # .build(
2092/// #     hyper_rustls::HttpsConnectorBuilder::new()
2093/// #         .with_native_roots()
2094/// #         .unwrap()
2095/// #         .https_or_http()
2096/// #         .enable_http2()
2097/// #         .build()
2098/// # );
2099/// # let mut hub = DoubleClickBidManager::new(client, auth);
2100/// // You can configure optional parameters by calling the respective setters at will, and
2101/// // execute the final call using `doit()`.
2102/// // Values shown here are possibly random and not representative !
2103/// let result = hub.queries().deletequery(-22)
2104///              .doit().await;
2105/// # }
2106/// ```
2107pub struct QueryDeletequeryCall<'a, C>
2108where
2109    C: 'a,
2110{
2111    hub: &'a DoubleClickBidManager<C>,
2112    _query_id: i64,
2113    _delegate: Option<&'a mut dyn common::Delegate>,
2114    _additional_params: HashMap<String, String>,
2115    _scopes: BTreeSet<String>,
2116}
2117
2118impl<'a, C> common::CallBuilder for QueryDeletequeryCall<'a, C> {}
2119
2120impl<'a, C> QueryDeletequeryCall<'a, C>
2121where
2122    C: common::Connector,
2123{
2124    /// Perform the operation you have build so far.
2125    pub async fn doit(mut self) -> common::Result<common::Response> {
2126        use std::borrow::Cow;
2127        use std::io::{Read, Seek};
2128
2129        use common::{url::Params, ToParts};
2130        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2131
2132        let mut dd = common::DefaultDelegate;
2133        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2134        dlg.begin(common::MethodInfo {
2135            id: "doubleclickbidmanager.queries.deletequery",
2136            http_method: hyper::Method::DELETE,
2137        });
2138
2139        for &field in ["queryId"].iter() {
2140            if self._additional_params.contains_key(field) {
2141                dlg.finished(false);
2142                return Err(common::Error::FieldClash(field));
2143            }
2144        }
2145
2146        let mut params = Params::with_capacity(2 + self._additional_params.len());
2147        params.push("queryId", self._query_id.to_string());
2148
2149        params.extend(self._additional_params.iter());
2150
2151        let mut url = self.hub._base_url.clone() + "query/{queryId}";
2152        if self._scopes.is_empty() {
2153            self._scopes.insert(Scope::Full.as_ref().to_string());
2154        }
2155
2156        #[allow(clippy::single_element_loop)]
2157        for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
2158            url = params.uri_replacement(url, param_name, find_this, false);
2159        }
2160        {
2161            let to_remove = ["queryId"];
2162            params.remove_params(&to_remove);
2163        }
2164
2165        let url = params.parse_with_url(&url);
2166
2167        loop {
2168            let token = match self
2169                .hub
2170                .auth
2171                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2172                .await
2173            {
2174                Ok(token) => token,
2175                Err(e) => match dlg.token(e) {
2176                    Ok(token) => token,
2177                    Err(e) => {
2178                        dlg.finished(false);
2179                        return Err(common::Error::MissingToken(e));
2180                    }
2181                },
2182            };
2183            let mut req_result = {
2184                let client = &self.hub.client;
2185                dlg.pre_request();
2186                let mut req_builder = hyper::Request::builder()
2187                    .method(hyper::Method::DELETE)
2188                    .uri(url.as_str())
2189                    .header(USER_AGENT, self.hub._user_agent.clone());
2190
2191                if let Some(token) = token.as_ref() {
2192                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2193                }
2194
2195                let request = req_builder
2196                    .header(CONTENT_LENGTH, 0_u64)
2197                    .body(common::to_body::<String>(None));
2198
2199                client.request(request.unwrap()).await
2200            };
2201
2202            match req_result {
2203                Err(err) => {
2204                    if let common::Retry::After(d) = dlg.http_error(&err) {
2205                        sleep(d).await;
2206                        continue;
2207                    }
2208                    dlg.finished(false);
2209                    return Err(common::Error::HttpError(err));
2210                }
2211                Ok(res) => {
2212                    let (mut parts, body) = res.into_parts();
2213                    let mut body = common::Body::new(body);
2214                    if !parts.status.is_success() {
2215                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2216                        let error = serde_json::from_str(&common::to_string(&bytes));
2217                        let response = common::to_response(parts, bytes.into());
2218
2219                        if let common::Retry::After(d) =
2220                            dlg.http_failure(&response, error.as_ref().ok())
2221                        {
2222                            sleep(d).await;
2223                            continue;
2224                        }
2225
2226                        dlg.finished(false);
2227
2228                        return Err(match error {
2229                            Ok(value) => common::Error::BadRequest(value),
2230                            _ => common::Error::Failure(response),
2231                        });
2232                    }
2233                    let response = common::Response::from_parts(parts, body);
2234
2235                    dlg.finished(true);
2236                    return Ok(response);
2237                }
2238            }
2239        }
2240    }
2241
2242    /// Query ID to delete.
2243    ///
2244    /// Sets the *query id* path property to the given value.
2245    ///
2246    /// Even though the property as already been set when instantiating this call,
2247    /// we provide this method for API completeness.
2248    pub fn query_id(mut self, new_value: i64) -> QueryDeletequeryCall<'a, C> {
2249        self._query_id = new_value;
2250        self
2251    }
2252    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2253    /// while executing the actual API request.
2254    ///
2255    /// ````text
2256    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2257    /// ````
2258    ///
2259    /// Sets the *delegate* property to the given value.
2260    pub fn delegate(
2261        mut self,
2262        new_value: &'a mut dyn common::Delegate,
2263    ) -> QueryDeletequeryCall<'a, C> {
2264        self._delegate = Some(new_value);
2265        self
2266    }
2267
2268    /// Set any additional parameter of the query string used in the request.
2269    /// It should be used to set parameters which are not yet available through their own
2270    /// setters.
2271    ///
2272    /// Please note that this method must not be used to set any of the known parameters
2273    /// which have their own setter method. If done anyway, the request will fail.
2274    ///
2275    /// # Additional Parameters
2276    ///
2277    /// * *$.xgafv* (query-string) - V1 error format.
2278    /// * *access_token* (query-string) - OAuth access token.
2279    /// * *alt* (query-string) - Data format for response.
2280    /// * *callback* (query-string) - JSONP
2281    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2282    /// * *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.
2283    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2284    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2285    /// * *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.
2286    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2287    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2288    pub fn param<T>(mut self, name: T, value: T) -> QueryDeletequeryCall<'a, C>
2289    where
2290        T: AsRef<str>,
2291    {
2292        self._additional_params
2293            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2294        self
2295    }
2296
2297    /// Identifies the authorization scope for the method you are building.
2298    ///
2299    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2300    /// [`Scope::Full`].
2301    ///
2302    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2303    /// tokens for more than one scope.
2304    ///
2305    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2306    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2307    /// sufficient, a read-write scope will do as well.
2308    pub fn add_scope<St>(mut self, scope: St) -> QueryDeletequeryCall<'a, C>
2309    where
2310        St: AsRef<str>,
2311    {
2312        self._scopes.insert(String::from(scope.as_ref()));
2313        self
2314    }
2315    /// Identifies the authorization scope(s) for the method you are building.
2316    ///
2317    /// See [`Self::add_scope()`] for details.
2318    pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryDeletequeryCall<'a, C>
2319    where
2320        I: IntoIterator<Item = St>,
2321        St: AsRef<str>,
2322    {
2323        self._scopes
2324            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2325        self
2326    }
2327
2328    /// Removes all scopes, and no default scope will be used either.
2329    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2330    /// for details).
2331    pub fn clear_scopes(mut self) -> QueryDeletequeryCall<'a, C> {
2332        self._scopes.clear();
2333        self
2334    }
2335}
2336
2337/// Retrieves a stored query.
2338///
2339/// A builder for the *getquery* method supported by a *query* resource.
2340/// It is not used directly, but through a [`QueryMethods`] instance.
2341///
2342/// # Example
2343///
2344/// Instantiate a resource method builder
2345///
2346/// ```test_harness,no_run
2347/// # extern crate hyper;
2348/// # extern crate hyper_rustls;
2349/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
2350/// # async fn dox() {
2351/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2352///
2353/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2354/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2355/// #     .with_native_roots()
2356/// #     .unwrap()
2357/// #     .https_only()
2358/// #     .enable_http2()
2359/// #     .build();
2360///
2361/// # let executor = hyper_util::rt::TokioExecutor::new();
2362/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2363/// #     secret,
2364/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2365/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2366/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2367/// #     ),
2368/// # ).build().await.unwrap();
2369///
2370/// # let client = hyper_util::client::legacy::Client::builder(
2371/// #     hyper_util::rt::TokioExecutor::new()
2372/// # )
2373/// # .build(
2374/// #     hyper_rustls::HttpsConnectorBuilder::new()
2375/// #         .with_native_roots()
2376/// #         .unwrap()
2377/// #         .https_or_http()
2378/// #         .enable_http2()
2379/// #         .build()
2380/// # );
2381/// # let mut hub = DoubleClickBidManager::new(client, auth);
2382/// // You can configure optional parameters by calling the respective setters at will, and
2383/// // execute the final call using `doit()`.
2384/// // Values shown here are possibly random and not representative !
2385/// let result = hub.queries().getquery(-33)
2386///              .doit().await;
2387/// # }
2388/// ```
2389pub struct QueryGetqueryCall<'a, C>
2390where
2391    C: 'a,
2392{
2393    hub: &'a DoubleClickBidManager<C>,
2394    _query_id: i64,
2395    _delegate: Option<&'a mut dyn common::Delegate>,
2396    _additional_params: HashMap<String, String>,
2397    _scopes: BTreeSet<String>,
2398}
2399
2400impl<'a, C> common::CallBuilder for QueryGetqueryCall<'a, C> {}
2401
2402impl<'a, C> QueryGetqueryCall<'a, C>
2403where
2404    C: common::Connector,
2405{
2406    /// Perform the operation you have build so far.
2407    pub async fn doit(mut self) -> common::Result<(common::Response, Query)> {
2408        use std::borrow::Cow;
2409        use std::io::{Read, Seek};
2410
2411        use common::{url::Params, ToParts};
2412        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2413
2414        let mut dd = common::DefaultDelegate;
2415        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2416        dlg.begin(common::MethodInfo {
2417            id: "doubleclickbidmanager.queries.getquery",
2418            http_method: hyper::Method::GET,
2419        });
2420
2421        for &field in ["alt", "queryId"].iter() {
2422            if self._additional_params.contains_key(field) {
2423                dlg.finished(false);
2424                return Err(common::Error::FieldClash(field));
2425            }
2426        }
2427
2428        let mut params = Params::with_capacity(3 + self._additional_params.len());
2429        params.push("queryId", self._query_id.to_string());
2430
2431        params.extend(self._additional_params.iter());
2432
2433        params.push("alt", "json");
2434        let mut url = self.hub._base_url.clone() + "query/{queryId}";
2435        if self._scopes.is_empty() {
2436            self._scopes.insert(Scope::Full.as_ref().to_string());
2437        }
2438
2439        #[allow(clippy::single_element_loop)]
2440        for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
2441            url = params.uri_replacement(url, param_name, find_this, false);
2442        }
2443        {
2444            let to_remove = ["queryId"];
2445            params.remove_params(&to_remove);
2446        }
2447
2448        let url = params.parse_with_url(&url);
2449
2450        loop {
2451            let token = match self
2452                .hub
2453                .auth
2454                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2455                .await
2456            {
2457                Ok(token) => token,
2458                Err(e) => match dlg.token(e) {
2459                    Ok(token) => token,
2460                    Err(e) => {
2461                        dlg.finished(false);
2462                        return Err(common::Error::MissingToken(e));
2463                    }
2464                },
2465            };
2466            let mut req_result = {
2467                let client = &self.hub.client;
2468                dlg.pre_request();
2469                let mut req_builder = hyper::Request::builder()
2470                    .method(hyper::Method::GET)
2471                    .uri(url.as_str())
2472                    .header(USER_AGENT, self.hub._user_agent.clone());
2473
2474                if let Some(token) = token.as_ref() {
2475                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2476                }
2477
2478                let request = req_builder
2479                    .header(CONTENT_LENGTH, 0_u64)
2480                    .body(common::to_body::<String>(None));
2481
2482                client.request(request.unwrap()).await
2483            };
2484
2485            match req_result {
2486                Err(err) => {
2487                    if let common::Retry::After(d) = dlg.http_error(&err) {
2488                        sleep(d).await;
2489                        continue;
2490                    }
2491                    dlg.finished(false);
2492                    return Err(common::Error::HttpError(err));
2493                }
2494                Ok(res) => {
2495                    let (mut parts, body) = res.into_parts();
2496                    let mut body = common::Body::new(body);
2497                    if !parts.status.is_success() {
2498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2499                        let error = serde_json::from_str(&common::to_string(&bytes));
2500                        let response = common::to_response(parts, bytes.into());
2501
2502                        if let common::Retry::After(d) =
2503                            dlg.http_failure(&response, error.as_ref().ok())
2504                        {
2505                            sleep(d).await;
2506                            continue;
2507                        }
2508
2509                        dlg.finished(false);
2510
2511                        return Err(match error {
2512                            Ok(value) => common::Error::BadRequest(value),
2513                            _ => common::Error::Failure(response),
2514                        });
2515                    }
2516                    let response = {
2517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2518                        let encoded = common::to_string(&bytes);
2519                        match serde_json::from_str(&encoded) {
2520                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2521                            Err(error) => {
2522                                dlg.response_json_decode_error(&encoded, &error);
2523                                return Err(common::Error::JsonDecodeError(
2524                                    encoded.to_string(),
2525                                    error,
2526                                ));
2527                            }
2528                        }
2529                    };
2530
2531                    dlg.finished(true);
2532                    return Ok(response);
2533                }
2534            }
2535        }
2536    }
2537
2538    /// Query ID to retrieve.
2539    ///
2540    /// Sets the *query id* path property to the given value.
2541    ///
2542    /// Even though the property as already been set when instantiating this call,
2543    /// we provide this method for API completeness.
2544    pub fn query_id(mut self, new_value: i64) -> QueryGetqueryCall<'a, C> {
2545        self._query_id = new_value;
2546        self
2547    }
2548    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2549    /// while executing the actual API request.
2550    ///
2551    /// ````text
2552    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2553    /// ````
2554    ///
2555    /// Sets the *delegate* property to the given value.
2556    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> QueryGetqueryCall<'a, C> {
2557        self._delegate = Some(new_value);
2558        self
2559    }
2560
2561    /// Set any additional parameter of the query string used in the request.
2562    /// It should be used to set parameters which are not yet available through their own
2563    /// setters.
2564    ///
2565    /// Please note that this method must not be used to set any of the known parameters
2566    /// which have their own setter method. If done anyway, the request will fail.
2567    ///
2568    /// # Additional Parameters
2569    ///
2570    /// * *$.xgafv* (query-string) - V1 error format.
2571    /// * *access_token* (query-string) - OAuth access token.
2572    /// * *alt* (query-string) - Data format for response.
2573    /// * *callback* (query-string) - JSONP
2574    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2575    /// * *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.
2576    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2577    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2578    /// * *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.
2579    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2580    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2581    pub fn param<T>(mut self, name: T, value: T) -> QueryGetqueryCall<'a, C>
2582    where
2583        T: AsRef<str>,
2584    {
2585        self._additional_params
2586            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2587        self
2588    }
2589
2590    /// Identifies the authorization scope for the method you are building.
2591    ///
2592    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2593    /// [`Scope::Full`].
2594    ///
2595    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2596    /// tokens for more than one scope.
2597    ///
2598    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2599    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2600    /// sufficient, a read-write scope will do as well.
2601    pub fn add_scope<St>(mut self, scope: St) -> QueryGetqueryCall<'a, C>
2602    where
2603        St: AsRef<str>,
2604    {
2605        self._scopes.insert(String::from(scope.as_ref()));
2606        self
2607    }
2608    /// Identifies the authorization scope(s) for the method you are building.
2609    ///
2610    /// See [`Self::add_scope()`] for details.
2611    pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryGetqueryCall<'a, C>
2612    where
2613        I: IntoIterator<Item = St>,
2614        St: AsRef<str>,
2615    {
2616        self._scopes
2617            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2618        self
2619    }
2620
2621    /// Removes all scopes, and no default scope will be used either.
2622    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2623    /// for details).
2624    pub fn clear_scopes(mut self) -> QueryGetqueryCall<'a, C> {
2625        self._scopes.clear();
2626        self
2627    }
2628}
2629
2630/// Retrieves stored queries.
2631///
2632/// A builder for the *listqueries* method supported by a *query* resource.
2633/// It is not used directly, but through a [`QueryMethods`] instance.
2634///
2635/// # Example
2636///
2637/// Instantiate a resource method builder
2638///
2639/// ```test_harness,no_run
2640/// # extern crate hyper;
2641/// # extern crate hyper_rustls;
2642/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
2643/// # async fn dox() {
2644/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2645///
2646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2647/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2648/// #     .with_native_roots()
2649/// #     .unwrap()
2650/// #     .https_only()
2651/// #     .enable_http2()
2652/// #     .build();
2653///
2654/// # let executor = hyper_util::rt::TokioExecutor::new();
2655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2656/// #     secret,
2657/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2658/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2659/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2660/// #     ),
2661/// # ).build().await.unwrap();
2662///
2663/// # let client = hyper_util::client::legacy::Client::builder(
2664/// #     hyper_util::rt::TokioExecutor::new()
2665/// # )
2666/// # .build(
2667/// #     hyper_rustls::HttpsConnectorBuilder::new()
2668/// #         .with_native_roots()
2669/// #         .unwrap()
2670/// #         .https_or_http()
2671/// #         .enable_http2()
2672/// #         .build()
2673/// # );
2674/// # let mut hub = DoubleClickBidManager::new(client, auth);
2675/// // You can configure optional parameters by calling the respective setters at will, and
2676/// // execute the final call using `doit()`.
2677/// // Values shown here are possibly random and not representative !
2678/// let result = hub.queries().listqueries()
2679///              .doit().await;
2680/// # }
2681/// ```
2682pub struct QueryListqueryCall<'a, C>
2683where
2684    C: 'a,
2685{
2686    hub: &'a DoubleClickBidManager<C>,
2687    _delegate: Option<&'a mut dyn common::Delegate>,
2688    _additional_params: HashMap<String, String>,
2689    _scopes: BTreeSet<String>,
2690}
2691
2692impl<'a, C> common::CallBuilder for QueryListqueryCall<'a, C> {}
2693
2694impl<'a, C> QueryListqueryCall<'a, C>
2695where
2696    C: common::Connector,
2697{
2698    /// Perform the operation you have build so far.
2699    pub async fn doit(mut self) -> common::Result<(common::Response, ListQueriesResponse)> {
2700        use std::borrow::Cow;
2701        use std::io::{Read, Seek};
2702
2703        use common::{url::Params, ToParts};
2704        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2705
2706        let mut dd = common::DefaultDelegate;
2707        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2708        dlg.begin(common::MethodInfo {
2709            id: "doubleclickbidmanager.queries.listqueries",
2710            http_method: hyper::Method::GET,
2711        });
2712
2713        for &field in ["alt"].iter() {
2714            if self._additional_params.contains_key(field) {
2715                dlg.finished(false);
2716                return Err(common::Error::FieldClash(field));
2717            }
2718        }
2719
2720        let mut params = Params::with_capacity(2 + self._additional_params.len());
2721
2722        params.extend(self._additional_params.iter());
2723
2724        params.push("alt", "json");
2725        let mut url = self.hub._base_url.clone() + "queries";
2726        if self._scopes.is_empty() {
2727            self._scopes.insert(Scope::Full.as_ref().to_string());
2728        }
2729
2730        let url = params.parse_with_url(&url);
2731
2732        loop {
2733            let token = match self
2734                .hub
2735                .auth
2736                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2737                .await
2738            {
2739                Ok(token) => token,
2740                Err(e) => match dlg.token(e) {
2741                    Ok(token) => token,
2742                    Err(e) => {
2743                        dlg.finished(false);
2744                        return Err(common::Error::MissingToken(e));
2745                    }
2746                },
2747            };
2748            let mut req_result = {
2749                let client = &self.hub.client;
2750                dlg.pre_request();
2751                let mut req_builder = hyper::Request::builder()
2752                    .method(hyper::Method::GET)
2753                    .uri(url.as_str())
2754                    .header(USER_AGENT, self.hub._user_agent.clone());
2755
2756                if let Some(token) = token.as_ref() {
2757                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2758                }
2759
2760                let request = req_builder
2761                    .header(CONTENT_LENGTH, 0_u64)
2762                    .body(common::to_body::<String>(None));
2763
2764                client.request(request.unwrap()).await
2765            };
2766
2767            match req_result {
2768                Err(err) => {
2769                    if let common::Retry::After(d) = dlg.http_error(&err) {
2770                        sleep(d).await;
2771                        continue;
2772                    }
2773                    dlg.finished(false);
2774                    return Err(common::Error::HttpError(err));
2775                }
2776                Ok(res) => {
2777                    let (mut parts, body) = res.into_parts();
2778                    let mut body = common::Body::new(body);
2779                    if !parts.status.is_success() {
2780                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2781                        let error = serde_json::from_str(&common::to_string(&bytes));
2782                        let response = common::to_response(parts, bytes.into());
2783
2784                        if let common::Retry::After(d) =
2785                            dlg.http_failure(&response, error.as_ref().ok())
2786                        {
2787                            sleep(d).await;
2788                            continue;
2789                        }
2790
2791                        dlg.finished(false);
2792
2793                        return Err(match error {
2794                            Ok(value) => common::Error::BadRequest(value),
2795                            _ => common::Error::Failure(response),
2796                        });
2797                    }
2798                    let response = {
2799                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2800                        let encoded = common::to_string(&bytes);
2801                        match serde_json::from_str(&encoded) {
2802                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2803                            Err(error) => {
2804                                dlg.response_json_decode_error(&encoded, &error);
2805                                return Err(common::Error::JsonDecodeError(
2806                                    encoded.to_string(),
2807                                    error,
2808                                ));
2809                            }
2810                        }
2811                    };
2812
2813                    dlg.finished(true);
2814                    return Ok(response);
2815                }
2816            }
2817        }
2818    }
2819
2820    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2821    /// while executing the actual API request.
2822    ///
2823    /// ````text
2824    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2825    /// ````
2826    ///
2827    /// Sets the *delegate* property to the given value.
2828    pub fn delegate(
2829        mut self,
2830        new_value: &'a mut dyn common::Delegate,
2831    ) -> QueryListqueryCall<'a, C> {
2832        self._delegate = Some(new_value);
2833        self
2834    }
2835
2836    /// Set any additional parameter of the query string used in the request.
2837    /// It should be used to set parameters which are not yet available through their own
2838    /// setters.
2839    ///
2840    /// Please note that this method must not be used to set any of the known parameters
2841    /// which have their own setter method. If done anyway, the request will fail.
2842    ///
2843    /// # Additional Parameters
2844    ///
2845    /// * *$.xgafv* (query-string) - V1 error format.
2846    /// * *access_token* (query-string) - OAuth access token.
2847    /// * *alt* (query-string) - Data format for response.
2848    /// * *callback* (query-string) - JSONP
2849    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2850    /// * *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.
2851    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2852    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2853    /// * *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.
2854    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2855    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2856    pub fn param<T>(mut self, name: T, value: T) -> QueryListqueryCall<'a, C>
2857    where
2858        T: AsRef<str>,
2859    {
2860        self._additional_params
2861            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2862        self
2863    }
2864
2865    /// Identifies the authorization scope for the method you are building.
2866    ///
2867    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2868    /// [`Scope::Full`].
2869    ///
2870    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2871    /// tokens for more than one scope.
2872    ///
2873    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2874    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2875    /// sufficient, a read-write scope will do as well.
2876    pub fn add_scope<St>(mut self, scope: St) -> QueryListqueryCall<'a, C>
2877    where
2878        St: AsRef<str>,
2879    {
2880        self._scopes.insert(String::from(scope.as_ref()));
2881        self
2882    }
2883    /// Identifies the authorization scope(s) for the method you are building.
2884    ///
2885    /// See [`Self::add_scope()`] for details.
2886    pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryListqueryCall<'a, C>
2887    where
2888        I: IntoIterator<Item = St>,
2889        St: AsRef<str>,
2890    {
2891        self._scopes
2892            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2893        self
2894    }
2895
2896    /// Removes all scopes, and no default scope will be used either.
2897    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2898    /// for details).
2899    pub fn clear_scopes(mut self) -> QueryListqueryCall<'a, C> {
2900        self._scopes.clear();
2901        self
2902    }
2903}
2904
2905/// Runs a stored query to generate a report.
2906///
2907/// A builder for the *runquery* method supported by a *query* resource.
2908/// It is not used directly, but through a [`QueryMethods`] instance.
2909///
2910/// # Example
2911///
2912/// Instantiate a resource method builder
2913///
2914/// ```test_harness,no_run
2915/// # extern crate hyper;
2916/// # extern crate hyper_rustls;
2917/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
2918/// use doubleclickbidmanager1::api::RunQueryRequest;
2919/// # async fn dox() {
2920/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2921///
2922/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2923/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2924/// #     .with_native_roots()
2925/// #     .unwrap()
2926/// #     .https_only()
2927/// #     .enable_http2()
2928/// #     .build();
2929///
2930/// # let executor = hyper_util::rt::TokioExecutor::new();
2931/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2932/// #     secret,
2933/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2934/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2935/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2936/// #     ),
2937/// # ).build().await.unwrap();
2938///
2939/// # let client = hyper_util::client::legacy::Client::builder(
2940/// #     hyper_util::rt::TokioExecutor::new()
2941/// # )
2942/// # .build(
2943/// #     hyper_rustls::HttpsConnectorBuilder::new()
2944/// #         .with_native_roots()
2945/// #         .unwrap()
2946/// #         .https_or_http()
2947/// #         .enable_http2()
2948/// #         .build()
2949/// # );
2950/// # let mut hub = DoubleClickBidManager::new(client, auth);
2951/// // As the method needs a request, you would usually fill it with the desired information
2952/// // into the respective structure. Some of the parts shown here might not be applicable !
2953/// // Values shown here are possibly random and not representative !
2954/// let mut req = RunQueryRequest::default();
2955///
2956/// // You can configure optional parameters by calling the respective setters at will, and
2957/// // execute the final call using `doit()`.
2958/// // Values shown here are possibly random and not representative !
2959/// let result = hub.queries().runquery(req, -11)
2960///              .doit().await;
2961/// # }
2962/// ```
2963pub struct QueryRunqueryCall<'a, C>
2964where
2965    C: 'a,
2966{
2967    hub: &'a DoubleClickBidManager<C>,
2968    _request: RunQueryRequest,
2969    _query_id: i64,
2970    _delegate: Option<&'a mut dyn common::Delegate>,
2971    _additional_params: HashMap<String, String>,
2972    _scopes: BTreeSet<String>,
2973}
2974
2975impl<'a, C> common::CallBuilder for QueryRunqueryCall<'a, C> {}
2976
2977impl<'a, C> QueryRunqueryCall<'a, C>
2978where
2979    C: common::Connector,
2980{
2981    /// Perform the operation you have build so far.
2982    pub async fn doit(mut self) -> common::Result<common::Response> {
2983        use std::borrow::Cow;
2984        use std::io::{Read, Seek};
2985
2986        use common::{url::Params, ToParts};
2987        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2988
2989        let mut dd = common::DefaultDelegate;
2990        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2991        dlg.begin(common::MethodInfo {
2992            id: "doubleclickbidmanager.queries.runquery",
2993            http_method: hyper::Method::POST,
2994        });
2995
2996        for &field in ["queryId"].iter() {
2997            if self._additional_params.contains_key(field) {
2998                dlg.finished(false);
2999                return Err(common::Error::FieldClash(field));
3000            }
3001        }
3002
3003        let mut params = Params::with_capacity(3 + self._additional_params.len());
3004        params.push("queryId", self._query_id.to_string());
3005
3006        params.extend(self._additional_params.iter());
3007
3008        let mut url = self.hub._base_url.clone() + "query/{queryId}";
3009        if self._scopes.is_empty() {
3010            self._scopes.insert(Scope::Full.as_ref().to_string());
3011        }
3012
3013        #[allow(clippy::single_element_loop)]
3014        for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
3015            url = params.uri_replacement(url, param_name, find_this, false);
3016        }
3017        {
3018            let to_remove = ["queryId"];
3019            params.remove_params(&to_remove);
3020        }
3021
3022        let url = params.parse_with_url(&url);
3023
3024        let mut json_mime_type = mime::APPLICATION_JSON;
3025        let mut request_value_reader = {
3026            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3027            common::remove_json_null_values(&mut value);
3028            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3029            serde_json::to_writer(&mut dst, &value).unwrap();
3030            dst
3031        };
3032        let request_size = request_value_reader
3033            .seek(std::io::SeekFrom::End(0))
3034            .unwrap();
3035        request_value_reader
3036            .seek(std::io::SeekFrom::Start(0))
3037            .unwrap();
3038
3039        loop {
3040            let token = match self
3041                .hub
3042                .auth
3043                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3044                .await
3045            {
3046                Ok(token) => token,
3047                Err(e) => match dlg.token(e) {
3048                    Ok(token) => token,
3049                    Err(e) => {
3050                        dlg.finished(false);
3051                        return Err(common::Error::MissingToken(e));
3052                    }
3053                },
3054            };
3055            request_value_reader
3056                .seek(std::io::SeekFrom::Start(0))
3057                .unwrap();
3058            let mut req_result = {
3059                let client = &self.hub.client;
3060                dlg.pre_request();
3061                let mut req_builder = hyper::Request::builder()
3062                    .method(hyper::Method::POST)
3063                    .uri(url.as_str())
3064                    .header(USER_AGENT, self.hub._user_agent.clone());
3065
3066                if let Some(token) = token.as_ref() {
3067                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3068                }
3069
3070                let request = req_builder
3071                    .header(CONTENT_TYPE, json_mime_type.to_string())
3072                    .header(CONTENT_LENGTH, request_size as u64)
3073                    .body(common::to_body(
3074                        request_value_reader.get_ref().clone().into(),
3075                    ));
3076
3077                client.request(request.unwrap()).await
3078            };
3079
3080            match req_result {
3081                Err(err) => {
3082                    if let common::Retry::After(d) = dlg.http_error(&err) {
3083                        sleep(d).await;
3084                        continue;
3085                    }
3086                    dlg.finished(false);
3087                    return Err(common::Error::HttpError(err));
3088                }
3089                Ok(res) => {
3090                    let (mut parts, body) = res.into_parts();
3091                    let mut body = common::Body::new(body);
3092                    if !parts.status.is_success() {
3093                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3094                        let error = serde_json::from_str(&common::to_string(&bytes));
3095                        let response = common::to_response(parts, bytes.into());
3096
3097                        if let common::Retry::After(d) =
3098                            dlg.http_failure(&response, error.as_ref().ok())
3099                        {
3100                            sleep(d).await;
3101                            continue;
3102                        }
3103
3104                        dlg.finished(false);
3105
3106                        return Err(match error {
3107                            Ok(value) => common::Error::BadRequest(value),
3108                            _ => common::Error::Failure(response),
3109                        });
3110                    }
3111                    let response = common::Response::from_parts(parts, body);
3112
3113                    dlg.finished(true);
3114                    return Ok(response);
3115                }
3116            }
3117        }
3118    }
3119
3120    ///
3121    /// Sets the *request* property to the given value.
3122    ///
3123    /// Even though the property as already been set when instantiating this call,
3124    /// we provide this method for API completeness.
3125    pub fn request(mut self, new_value: RunQueryRequest) -> QueryRunqueryCall<'a, C> {
3126        self._request = new_value;
3127        self
3128    }
3129    /// Query ID to run.
3130    ///
3131    /// Sets the *query id* path property to the given value.
3132    ///
3133    /// Even though the property as already been set when instantiating this call,
3134    /// we provide this method for API completeness.
3135    pub fn query_id(mut self, new_value: i64) -> QueryRunqueryCall<'a, C> {
3136        self._query_id = new_value;
3137        self
3138    }
3139    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3140    /// while executing the actual API request.
3141    ///
3142    /// ````text
3143    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3144    /// ````
3145    ///
3146    /// Sets the *delegate* property to the given value.
3147    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> QueryRunqueryCall<'a, C> {
3148        self._delegate = Some(new_value);
3149        self
3150    }
3151
3152    /// Set any additional parameter of the query string used in the request.
3153    /// It should be used to set parameters which are not yet available through their own
3154    /// setters.
3155    ///
3156    /// Please note that this method must not be used to set any of the known parameters
3157    /// which have their own setter method. If done anyway, the request will fail.
3158    ///
3159    /// # Additional Parameters
3160    ///
3161    /// * *$.xgafv* (query-string) - V1 error format.
3162    /// * *access_token* (query-string) - OAuth access token.
3163    /// * *alt* (query-string) - Data format for response.
3164    /// * *callback* (query-string) - JSONP
3165    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3166    /// * *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.
3167    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3168    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3169    /// * *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.
3170    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3171    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3172    pub fn param<T>(mut self, name: T, value: T) -> QueryRunqueryCall<'a, C>
3173    where
3174        T: AsRef<str>,
3175    {
3176        self._additional_params
3177            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3178        self
3179    }
3180
3181    /// Identifies the authorization scope for the method you are building.
3182    ///
3183    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3184    /// [`Scope::Full`].
3185    ///
3186    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3187    /// tokens for more than one scope.
3188    ///
3189    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3190    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3191    /// sufficient, a read-write scope will do as well.
3192    pub fn add_scope<St>(mut self, scope: St) -> QueryRunqueryCall<'a, C>
3193    where
3194        St: AsRef<str>,
3195    {
3196        self._scopes.insert(String::from(scope.as_ref()));
3197        self
3198    }
3199    /// Identifies the authorization scope(s) for the method you are building.
3200    ///
3201    /// See [`Self::add_scope()`] for details.
3202    pub fn add_scopes<I, St>(mut self, scopes: I) -> QueryRunqueryCall<'a, C>
3203    where
3204        I: IntoIterator<Item = St>,
3205        St: AsRef<str>,
3206    {
3207        self._scopes
3208            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3209        self
3210    }
3211
3212    /// Removes all scopes, and no default scope will be used either.
3213    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3214    /// for details).
3215    pub fn clear_scopes(mut self) -> QueryRunqueryCall<'a, C> {
3216        self._scopes.clear();
3217        self
3218    }
3219}
3220
3221/// Retrieves stored reports.
3222///
3223/// A builder for the *listreports* method supported by a *report* resource.
3224/// It is not used directly, but through a [`ReportMethods`] instance.
3225///
3226/// # Example
3227///
3228/// Instantiate a resource method builder
3229///
3230/// ```test_harness,no_run
3231/// # extern crate hyper;
3232/// # extern crate hyper_rustls;
3233/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
3234/// # async fn dox() {
3235/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3236///
3237/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3238/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3239/// #     .with_native_roots()
3240/// #     .unwrap()
3241/// #     .https_only()
3242/// #     .enable_http2()
3243/// #     .build();
3244///
3245/// # let executor = hyper_util::rt::TokioExecutor::new();
3246/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3247/// #     secret,
3248/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3249/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3250/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3251/// #     ),
3252/// # ).build().await.unwrap();
3253///
3254/// # let client = hyper_util::client::legacy::Client::builder(
3255/// #     hyper_util::rt::TokioExecutor::new()
3256/// # )
3257/// # .build(
3258/// #     hyper_rustls::HttpsConnectorBuilder::new()
3259/// #         .with_native_roots()
3260/// #         .unwrap()
3261/// #         .https_or_http()
3262/// #         .enable_http2()
3263/// #         .build()
3264/// # );
3265/// # let mut hub = DoubleClickBidManager::new(client, auth);
3266/// // You can configure optional parameters by calling the respective setters at will, and
3267/// // execute the final call using `doit()`.
3268/// // Values shown here are possibly random and not representative !
3269/// let result = hub.reports().listreports(-55)
3270///              .doit().await;
3271/// # }
3272/// ```
3273pub struct ReportListreportCall<'a, C>
3274where
3275    C: 'a,
3276{
3277    hub: &'a DoubleClickBidManager<C>,
3278    _query_id: i64,
3279    _delegate: Option<&'a mut dyn common::Delegate>,
3280    _additional_params: HashMap<String, String>,
3281    _scopes: BTreeSet<String>,
3282}
3283
3284impl<'a, C> common::CallBuilder for ReportListreportCall<'a, C> {}
3285
3286impl<'a, C> ReportListreportCall<'a, C>
3287where
3288    C: common::Connector,
3289{
3290    /// Perform the operation you have build so far.
3291    pub async fn doit(mut self) -> common::Result<(common::Response, ListReportsResponse)> {
3292        use std::borrow::Cow;
3293        use std::io::{Read, Seek};
3294
3295        use common::{url::Params, ToParts};
3296        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3297
3298        let mut dd = common::DefaultDelegate;
3299        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3300        dlg.begin(common::MethodInfo {
3301            id: "doubleclickbidmanager.reports.listreports",
3302            http_method: hyper::Method::GET,
3303        });
3304
3305        for &field in ["alt", "queryId"].iter() {
3306            if self._additional_params.contains_key(field) {
3307                dlg.finished(false);
3308                return Err(common::Error::FieldClash(field));
3309            }
3310        }
3311
3312        let mut params = Params::with_capacity(3 + self._additional_params.len());
3313        params.push("queryId", self._query_id.to_string());
3314
3315        params.extend(self._additional_params.iter());
3316
3317        params.push("alt", "json");
3318        let mut url = self.hub._base_url.clone() + "queries/{queryId}/reports";
3319        if self._scopes.is_empty() {
3320            self._scopes.insert(Scope::Full.as_ref().to_string());
3321        }
3322
3323        #[allow(clippy::single_element_loop)]
3324        for &(find_this, param_name) in [("{queryId}", "queryId")].iter() {
3325            url = params.uri_replacement(url, param_name, find_this, false);
3326        }
3327        {
3328            let to_remove = ["queryId"];
3329            params.remove_params(&to_remove);
3330        }
3331
3332        let url = params.parse_with_url(&url);
3333
3334        loop {
3335            let token = match self
3336                .hub
3337                .auth
3338                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3339                .await
3340            {
3341                Ok(token) => token,
3342                Err(e) => match dlg.token(e) {
3343                    Ok(token) => token,
3344                    Err(e) => {
3345                        dlg.finished(false);
3346                        return Err(common::Error::MissingToken(e));
3347                    }
3348                },
3349            };
3350            let mut req_result = {
3351                let client = &self.hub.client;
3352                dlg.pre_request();
3353                let mut req_builder = hyper::Request::builder()
3354                    .method(hyper::Method::GET)
3355                    .uri(url.as_str())
3356                    .header(USER_AGENT, self.hub._user_agent.clone());
3357
3358                if let Some(token) = token.as_ref() {
3359                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3360                }
3361
3362                let request = req_builder
3363                    .header(CONTENT_LENGTH, 0_u64)
3364                    .body(common::to_body::<String>(None));
3365
3366                client.request(request.unwrap()).await
3367            };
3368
3369            match req_result {
3370                Err(err) => {
3371                    if let common::Retry::After(d) = dlg.http_error(&err) {
3372                        sleep(d).await;
3373                        continue;
3374                    }
3375                    dlg.finished(false);
3376                    return Err(common::Error::HttpError(err));
3377                }
3378                Ok(res) => {
3379                    let (mut parts, body) = res.into_parts();
3380                    let mut body = common::Body::new(body);
3381                    if !parts.status.is_success() {
3382                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3383                        let error = serde_json::from_str(&common::to_string(&bytes));
3384                        let response = common::to_response(parts, bytes.into());
3385
3386                        if let common::Retry::After(d) =
3387                            dlg.http_failure(&response, error.as_ref().ok())
3388                        {
3389                            sleep(d).await;
3390                            continue;
3391                        }
3392
3393                        dlg.finished(false);
3394
3395                        return Err(match error {
3396                            Ok(value) => common::Error::BadRequest(value),
3397                            _ => common::Error::Failure(response),
3398                        });
3399                    }
3400                    let response = {
3401                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3402                        let encoded = common::to_string(&bytes);
3403                        match serde_json::from_str(&encoded) {
3404                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3405                            Err(error) => {
3406                                dlg.response_json_decode_error(&encoded, &error);
3407                                return Err(common::Error::JsonDecodeError(
3408                                    encoded.to_string(),
3409                                    error,
3410                                ));
3411                            }
3412                        }
3413                    };
3414
3415                    dlg.finished(true);
3416                    return Ok(response);
3417                }
3418            }
3419        }
3420    }
3421
3422    /// Query ID with which the reports are associated.
3423    ///
3424    /// Sets the *query id* path property to the given value.
3425    ///
3426    /// Even though the property as already been set when instantiating this call,
3427    /// we provide this method for API completeness.
3428    pub fn query_id(mut self, new_value: i64) -> ReportListreportCall<'a, C> {
3429        self._query_id = new_value;
3430        self
3431    }
3432    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3433    /// while executing the actual API request.
3434    ///
3435    /// ````text
3436    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3437    /// ````
3438    ///
3439    /// Sets the *delegate* property to the given value.
3440    pub fn delegate(
3441        mut self,
3442        new_value: &'a mut dyn common::Delegate,
3443    ) -> ReportListreportCall<'a, C> {
3444        self._delegate = Some(new_value);
3445        self
3446    }
3447
3448    /// Set any additional parameter of the query string used in the request.
3449    /// It should be used to set parameters which are not yet available through their own
3450    /// setters.
3451    ///
3452    /// Please note that this method must not be used to set any of the known parameters
3453    /// which have their own setter method. If done anyway, the request will fail.
3454    ///
3455    /// # Additional Parameters
3456    ///
3457    /// * *$.xgafv* (query-string) - V1 error format.
3458    /// * *access_token* (query-string) - OAuth access token.
3459    /// * *alt* (query-string) - Data format for response.
3460    /// * *callback* (query-string) - JSONP
3461    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3462    /// * *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.
3463    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3464    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3465    /// * *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.
3466    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3467    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3468    pub fn param<T>(mut self, name: T, value: T) -> ReportListreportCall<'a, C>
3469    where
3470        T: AsRef<str>,
3471    {
3472        self._additional_params
3473            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3474        self
3475    }
3476
3477    /// Identifies the authorization scope for the method you are building.
3478    ///
3479    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3480    /// [`Scope::Full`].
3481    ///
3482    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3483    /// tokens for more than one scope.
3484    ///
3485    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3486    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3487    /// sufficient, a read-write scope will do as well.
3488    pub fn add_scope<St>(mut self, scope: St) -> ReportListreportCall<'a, C>
3489    where
3490        St: AsRef<str>,
3491    {
3492        self._scopes.insert(String::from(scope.as_ref()));
3493        self
3494    }
3495    /// Identifies the authorization scope(s) for the method you are building.
3496    ///
3497    /// See [`Self::add_scope()`] for details.
3498    pub fn add_scopes<I, St>(mut self, scopes: I) -> ReportListreportCall<'a, C>
3499    where
3500        I: IntoIterator<Item = St>,
3501        St: AsRef<str>,
3502    {
3503        self._scopes
3504            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3505        self
3506    }
3507
3508    /// Removes all scopes, and no default scope will be used either.
3509    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3510    /// for details).
3511    pub fn clear_scopes(mut self) -> ReportListreportCall<'a, C> {
3512        self._scopes.clear();
3513        self
3514    }
3515}
3516
3517/// Retrieves entities in SDF format.
3518///
3519/// A builder for the *download* method supported by a *sdf* resource.
3520/// It is not used directly, but through a [`SdfMethods`] instance.
3521///
3522/// # Example
3523///
3524/// Instantiate a resource method builder
3525///
3526/// ```test_harness,no_run
3527/// # extern crate hyper;
3528/// # extern crate hyper_rustls;
3529/// # extern crate google_doubleclickbidmanager1 as doubleclickbidmanager1;
3530/// use doubleclickbidmanager1::api::DownloadRequest;
3531/// # async fn dox() {
3532/// # use doubleclickbidmanager1::{DoubleClickBidManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3533///
3534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3536/// #     .with_native_roots()
3537/// #     .unwrap()
3538/// #     .https_only()
3539/// #     .enable_http2()
3540/// #     .build();
3541///
3542/// # let executor = hyper_util::rt::TokioExecutor::new();
3543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3544/// #     secret,
3545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3546/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3547/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3548/// #     ),
3549/// # ).build().await.unwrap();
3550///
3551/// # let client = hyper_util::client::legacy::Client::builder(
3552/// #     hyper_util::rt::TokioExecutor::new()
3553/// # )
3554/// # .build(
3555/// #     hyper_rustls::HttpsConnectorBuilder::new()
3556/// #         .with_native_roots()
3557/// #         .unwrap()
3558/// #         .https_or_http()
3559/// #         .enable_http2()
3560/// #         .build()
3561/// # );
3562/// # let mut hub = DoubleClickBidManager::new(client, auth);
3563/// // As the method needs a request, you would usually fill it with the desired information
3564/// // into the respective structure. Some of the parts shown here might not be applicable !
3565/// // Values shown here are possibly random and not representative !
3566/// let mut req = DownloadRequest::default();
3567///
3568/// // You can configure optional parameters by calling the respective setters at will, and
3569/// // execute the final call using `doit()`.
3570/// // Values shown here are possibly random and not representative !
3571/// let result = hub.sdf().download(req)
3572///              .doit().await;
3573/// # }
3574/// ```
3575pub struct SdfDownloadCall<'a, C>
3576where
3577    C: 'a,
3578{
3579    hub: &'a DoubleClickBidManager<C>,
3580    _request: DownloadRequest,
3581    _delegate: Option<&'a mut dyn common::Delegate>,
3582    _additional_params: HashMap<String, String>,
3583    _scopes: BTreeSet<String>,
3584}
3585
3586impl<'a, C> common::CallBuilder for SdfDownloadCall<'a, C> {}
3587
3588impl<'a, C> SdfDownloadCall<'a, C>
3589where
3590    C: common::Connector,
3591{
3592    /// Perform the operation you have build so far.
3593    pub async fn doit(mut self) -> common::Result<(common::Response, DownloadResponse)> {
3594        use std::borrow::Cow;
3595        use std::io::{Read, Seek};
3596
3597        use common::{url::Params, ToParts};
3598        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3599
3600        let mut dd = common::DefaultDelegate;
3601        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3602        dlg.begin(common::MethodInfo {
3603            id: "doubleclickbidmanager.sdf.download",
3604            http_method: hyper::Method::POST,
3605        });
3606
3607        for &field in ["alt"].iter() {
3608            if self._additional_params.contains_key(field) {
3609                dlg.finished(false);
3610                return Err(common::Error::FieldClash(field));
3611            }
3612        }
3613
3614        let mut params = Params::with_capacity(3 + self._additional_params.len());
3615
3616        params.extend(self._additional_params.iter());
3617
3618        params.push("alt", "json");
3619        let mut url = self.hub._base_url.clone() + "sdf/download";
3620        if self._scopes.is_empty() {
3621            self._scopes.insert(Scope::Full.as_ref().to_string());
3622        }
3623
3624        let url = params.parse_with_url(&url);
3625
3626        let mut json_mime_type = mime::APPLICATION_JSON;
3627        let mut request_value_reader = {
3628            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3629            common::remove_json_null_values(&mut value);
3630            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3631            serde_json::to_writer(&mut dst, &value).unwrap();
3632            dst
3633        };
3634        let request_size = request_value_reader
3635            .seek(std::io::SeekFrom::End(0))
3636            .unwrap();
3637        request_value_reader
3638            .seek(std::io::SeekFrom::Start(0))
3639            .unwrap();
3640
3641        loop {
3642            let token = match self
3643                .hub
3644                .auth
3645                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3646                .await
3647            {
3648                Ok(token) => token,
3649                Err(e) => match dlg.token(e) {
3650                    Ok(token) => token,
3651                    Err(e) => {
3652                        dlg.finished(false);
3653                        return Err(common::Error::MissingToken(e));
3654                    }
3655                },
3656            };
3657            request_value_reader
3658                .seek(std::io::SeekFrom::Start(0))
3659                .unwrap();
3660            let mut req_result = {
3661                let client = &self.hub.client;
3662                dlg.pre_request();
3663                let mut req_builder = hyper::Request::builder()
3664                    .method(hyper::Method::POST)
3665                    .uri(url.as_str())
3666                    .header(USER_AGENT, self.hub._user_agent.clone());
3667
3668                if let Some(token) = token.as_ref() {
3669                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3670                }
3671
3672                let request = req_builder
3673                    .header(CONTENT_TYPE, json_mime_type.to_string())
3674                    .header(CONTENT_LENGTH, request_size as u64)
3675                    .body(common::to_body(
3676                        request_value_reader.get_ref().clone().into(),
3677                    ));
3678
3679                client.request(request.unwrap()).await
3680            };
3681
3682            match req_result {
3683                Err(err) => {
3684                    if let common::Retry::After(d) = dlg.http_error(&err) {
3685                        sleep(d).await;
3686                        continue;
3687                    }
3688                    dlg.finished(false);
3689                    return Err(common::Error::HttpError(err));
3690                }
3691                Ok(res) => {
3692                    let (mut parts, body) = res.into_parts();
3693                    let mut body = common::Body::new(body);
3694                    if !parts.status.is_success() {
3695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3696                        let error = serde_json::from_str(&common::to_string(&bytes));
3697                        let response = common::to_response(parts, bytes.into());
3698
3699                        if let common::Retry::After(d) =
3700                            dlg.http_failure(&response, error.as_ref().ok())
3701                        {
3702                            sleep(d).await;
3703                            continue;
3704                        }
3705
3706                        dlg.finished(false);
3707
3708                        return Err(match error {
3709                            Ok(value) => common::Error::BadRequest(value),
3710                            _ => common::Error::Failure(response),
3711                        });
3712                    }
3713                    let response = {
3714                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3715                        let encoded = common::to_string(&bytes);
3716                        match serde_json::from_str(&encoded) {
3717                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3718                            Err(error) => {
3719                                dlg.response_json_decode_error(&encoded, &error);
3720                                return Err(common::Error::JsonDecodeError(
3721                                    encoded.to_string(),
3722                                    error,
3723                                ));
3724                            }
3725                        }
3726                    };
3727
3728                    dlg.finished(true);
3729                    return Ok(response);
3730                }
3731            }
3732        }
3733    }
3734
3735    ///
3736    /// Sets the *request* property to the given value.
3737    ///
3738    /// Even though the property as already been set when instantiating this call,
3739    /// we provide this method for API completeness.
3740    pub fn request(mut self, new_value: DownloadRequest) -> SdfDownloadCall<'a, C> {
3741        self._request = new_value;
3742        self
3743    }
3744    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3745    /// while executing the actual API request.
3746    ///
3747    /// ````text
3748    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3749    /// ````
3750    ///
3751    /// Sets the *delegate* property to the given value.
3752    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SdfDownloadCall<'a, C> {
3753        self._delegate = Some(new_value);
3754        self
3755    }
3756
3757    /// Set any additional parameter of the query string used in the request.
3758    /// It should be used to set parameters which are not yet available through their own
3759    /// setters.
3760    ///
3761    /// Please note that this method must not be used to set any of the known parameters
3762    /// which have their own setter method. If done anyway, the request will fail.
3763    ///
3764    /// # Additional Parameters
3765    ///
3766    /// * *$.xgafv* (query-string) - V1 error format.
3767    /// * *access_token* (query-string) - OAuth access token.
3768    /// * *alt* (query-string) - Data format for response.
3769    /// * *callback* (query-string) - JSONP
3770    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3771    /// * *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.
3772    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3773    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3774    /// * *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.
3775    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3776    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3777    pub fn param<T>(mut self, name: T, value: T) -> SdfDownloadCall<'a, C>
3778    where
3779        T: AsRef<str>,
3780    {
3781        self._additional_params
3782            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3783        self
3784    }
3785
3786    /// Identifies the authorization scope for the method you are building.
3787    ///
3788    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3789    /// [`Scope::Full`].
3790    ///
3791    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3792    /// tokens for more than one scope.
3793    ///
3794    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3795    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3796    /// sufficient, a read-write scope will do as well.
3797    pub fn add_scope<St>(mut self, scope: St) -> SdfDownloadCall<'a, C>
3798    where
3799        St: AsRef<str>,
3800    {
3801        self._scopes.insert(String::from(scope.as_ref()));
3802        self
3803    }
3804    /// Identifies the authorization scope(s) for the method you are building.
3805    ///
3806    /// See [`Self::add_scope()`] for details.
3807    pub fn add_scopes<I, St>(mut self, scopes: I) -> SdfDownloadCall<'a, C>
3808    where
3809        I: IntoIterator<Item = St>,
3810        St: AsRef<str>,
3811    {
3812        self._scopes
3813            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3814        self
3815    }
3816
3817    /// Removes all scopes, and no default scope will be used either.
3818    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3819    /// for details).
3820    pub fn clear_scopes(mut self) -> SdfDownloadCall<'a, C> {
3821        self._scopes.clear();
3822        self
3823    }
3824}