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