google_area120tables1_alpha1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, create, and delete all of your Google Drive files
17 Drive,
18
19 /// See, edit, create, and delete only the specific Google Drive files you use with this app
20 DriveFile,
21
22 /// See and download all your Google Drive files
23 DriveReadonly,
24
25 /// See, edit, create, and delete all your Google Sheets spreadsheets
26 Spreadsheet,
27
28 /// See all your Google Sheets spreadsheets
29 SpreadsheetReadonly,
30
31 /// See, edit, create, and delete your tables in Tables by Area 120
32 Table,
33}
34
35impl AsRef<str> for Scope {
36 fn as_ref(&self) -> &str {
37 match *self {
38 Scope::Drive => "https://www.googleapis.com/auth/drive",
39 Scope::DriveFile => "https://www.googleapis.com/auth/drive.file",
40 Scope::DriveReadonly => "https://www.googleapis.com/auth/drive.readonly",
41 Scope::Spreadsheet => "https://www.googleapis.com/auth/spreadsheets",
42 Scope::SpreadsheetReadonly => "https://www.googleapis.com/auth/spreadsheets.readonly",
43 Scope::Table => "https://www.googleapis.com/auth/tables",
44 }
45 }
46}
47
48#[allow(clippy::derivable_impls)]
49impl Default for Scope {
50 fn default() -> Scope {
51 Scope::DriveReadonly
52 }
53}
54
55// ########
56// HUB ###
57// ######
58
59/// Central instance to access all Area120Tables related resource activities
60///
61/// # Examples
62///
63/// Instantiate a new hub
64///
65/// ```test_harness,no_run
66/// extern crate hyper;
67/// extern crate hyper_rustls;
68/// extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
69/// use area120tables1_alpha1::{Result, Error};
70/// # async fn dox() {
71/// use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
72///
73/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
74/// // `client_secret`, among other things.
75/// let secret: yup_oauth2::ApplicationSecret = Default::default();
76/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
77/// // unless you replace `None` with the desired Flow.
78/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
79/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
80/// // retrieve them from storage.
81/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
82/// .with_native_roots()
83/// .unwrap()
84/// .https_only()
85/// .enable_http2()
86/// .build();
87///
88/// let executor = hyper_util::rt::TokioExecutor::new();
89/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
90/// secret,
91/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
92/// yup_oauth2::client::CustomHyperClientBuilder::from(
93/// hyper_util::client::legacy::Client::builder(executor).build(connector),
94/// ),
95/// ).build().await.unwrap();
96///
97/// let client = hyper_util::client::legacy::Client::builder(
98/// hyper_util::rt::TokioExecutor::new()
99/// )
100/// .build(
101/// hyper_rustls::HttpsConnectorBuilder::new()
102/// .with_native_roots()
103/// .unwrap()
104/// .https_or_http()
105/// .enable_http2()
106/// .build()
107/// );
108/// let mut hub = Area120Tables::new(client, auth);
109/// // You can configure optional parameters by calling the respective setters at will, and
110/// // execute the final call using `doit()`.
111/// // Values shown here are possibly random and not representative !
112/// let result = hub.tables().rows_list("parent")
113/// .view("gubergren")
114/// .page_token("Lorem")
115/// .page_size(-12)
116/// .order_by("eos")
117/// .filter("dolor")
118/// .doit().await;
119///
120/// match result {
121/// Err(e) => match e {
122/// // The Error enum provides details about what exactly happened.
123/// // You can also just use its `Debug`, `Display` or `Error` traits
124/// Error::HttpError(_)
125/// |Error::Io(_)
126/// |Error::MissingAPIKey
127/// |Error::MissingToken(_)
128/// |Error::Cancelled
129/// |Error::UploadSizeLimitExceeded(_, _)
130/// |Error::Failure(_)
131/// |Error::BadRequest(_)
132/// |Error::FieldClash(_)
133/// |Error::JsonDecodeError(_, _) => println!("{}", e),
134/// },
135/// Ok(res) => println!("Success: {:?}", res),
136/// }
137/// # }
138/// ```
139#[derive(Clone)]
140pub struct Area120Tables<C> {
141 pub client: common::Client<C>,
142 pub auth: Box<dyn common::GetToken>,
143 _user_agent: String,
144 _base_url: String,
145 _root_url: String,
146}
147
148impl<C> common::Hub for Area120Tables<C> {}
149
150impl<'a, C> Area120Tables<C> {
151 pub fn new<A: 'static + common::GetToken>(
152 client: common::Client<C>,
153 auth: A,
154 ) -> Area120Tables<C> {
155 Area120Tables {
156 client,
157 auth: Box::new(auth),
158 _user_agent: "google-api-rust-client/7.0.0".to_string(),
159 _base_url: "https://area120tables.googleapis.com/".to_string(),
160 _root_url: "https://area120tables.googleapis.com/".to_string(),
161 }
162 }
163
164 pub fn tables(&'a self) -> TableMethods<'a, C> {
165 TableMethods { hub: self }
166 }
167 pub fn workspaces(&'a self) -> WorkspaceMethods<'a, C> {
168 WorkspaceMethods { hub: self }
169 }
170
171 /// Set the user-agent header field to use in all requests to the server.
172 /// It defaults to `google-api-rust-client/7.0.0`.
173 ///
174 /// Returns the previously set user-agent.
175 pub fn user_agent(&mut self, agent_name: String) -> String {
176 std::mem::replace(&mut self._user_agent, agent_name)
177 }
178
179 /// Set the base url to use in all requests to the server.
180 /// It defaults to `https://area120tables.googleapis.com/`.
181 ///
182 /// Returns the previously set base url.
183 pub fn base_url(&mut self, new_base_url: String) -> String {
184 std::mem::replace(&mut self._base_url, new_base_url)
185 }
186
187 /// Set the root url to use in all requests to the server.
188 /// It defaults to `https://area120tables.googleapis.com/`.
189 ///
190 /// Returns the previously set root url.
191 pub fn root_url(&mut self, new_root_url: String) -> String {
192 std::mem::replace(&mut self._root_url, new_root_url)
193 }
194}
195
196// ############
197// SCHEMAS ###
198// ##########
199/// Request message for TablesService.BatchCreateRows.
200///
201/// # Activities
202///
203/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
204/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
205///
206/// * [rows batch create tables](TableRowBatchCreateCall) (request)
207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
208#[serde_with::serde_as]
209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
210pub struct BatchCreateRowsRequest {
211 /// Required. The request message specifying the rows to create. A maximum of 500 rows can be created in a single batch.
212 pub requests: Option<Vec<CreateRowRequest>>,
213}
214
215impl common::RequestValue for BatchCreateRowsRequest {}
216
217/// Response message for TablesService.BatchCreateRows.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [rows batch create tables](TableRowBatchCreateCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct BatchCreateRowsResponse {
229 /// The created rows.
230 pub rows: Option<Vec<Row>>,
231}
232
233impl common::ResponseResult for BatchCreateRowsResponse {}
234
235/// Request message for TablesService.BatchDeleteRows
236///
237/// # Activities
238///
239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
241///
242/// * [rows batch delete tables](TableRowBatchDeleteCall) (request)
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct BatchDeleteRowsRequest {
247 /// Required. The names of the rows to delete. All rows must belong to the parent table or else the entire batch will fail. A maximum of 500 rows can be deleted in a batch. Format: tables/{table}/rows/{row}
248 pub names: Option<Vec<String>>,
249}
250
251impl common::RequestValue for BatchDeleteRowsRequest {}
252
253/// Request message for TablesService.BatchUpdateRows.
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [rows batch update tables](TableRowBatchUpdateCall) (request)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct BatchUpdateRowsRequest {
265 /// Required. The request messages specifying the rows to update. A maximum of 500 rows can be modified in a single batch.
266 pub requests: Option<Vec<UpdateRowRequest>>,
267}
268
269impl common::RequestValue for BatchUpdateRowsRequest {}
270
271/// Response message for TablesService.BatchUpdateRows.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [rows batch update tables](TableRowBatchUpdateCall) (response)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct BatchUpdateRowsResponse {
283 /// The updated rows.
284 pub rows: Option<Vec<Row>>,
285}
286
287impl common::ResponseResult for BatchUpdateRowsResponse {}
288
289/// Details on a column in the table.
290///
291/// This type is not used in any activity, and only used as *part* of another schema.
292///
293#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
294#[serde_with::serde_as]
295#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
296pub struct ColumnDescription {
297 /// Data type of the column Supported types are auto_id, boolean, boolean_list, creator, create_timestamp, date, dropdown, location, integer, integer_list, number, number_list, person, person_list, tags, check_list, text, text_list, update_timestamp, updater, relationship, file_attachment_list. These types directly map to the column types supported on Tables website.
298 #[serde(rename = "dataType")]
299 pub data_type: Option<String>,
300 /// Optional. Additional details about a date column.
301 #[serde(rename = "dateDetails")]
302 pub date_details: Option<DateDetails>,
303 /// Internal id for a column.
304 pub id: Option<String>,
305 /// Optional. Range of labeled values for the column. Some columns like tags and drop-downs limit the values to a set of possible values. We return the range of values in such cases to help clients implement better user data validation.
306 pub labels: Option<Vec<LabeledItem>>,
307 /// Optional. Indicates that this is a lookup column whose value is derived from the relationship column specified in the details. Lookup columns can not be updated directly. To change the value you must update the associated relationship column.
308 #[serde(rename = "lookupDetails")]
309 pub lookup_details: Option<LookupDetails>,
310 /// Optional. Indicates whether or not multiple values are allowed for array types where such a restriction is possible.
311 #[serde(rename = "multipleValuesDisallowed")]
312 pub multiple_values_disallowed: Option<bool>,
313 /// column name
314 pub name: Option<String>,
315 /// Optional. Indicates that values for the column cannot be set by the user.
316 pub readonly: Option<bool>,
317 /// Optional. Additional details about a relationship column. Specified when data_type is relationship.
318 #[serde(rename = "relationshipDetails")]
319 pub relationship_details: Option<RelationshipDetails>,
320}
321
322impl common::Part for ColumnDescription {}
323
324/// Request message for TablesService.CreateRow.
325///
326/// This type is not used in any activity, and only used as *part* of another schema.
327///
328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
329#[serde_with::serde_as]
330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
331pub struct CreateRowRequest {
332 /// Required. The parent table where this row will be created. Format: tables/{table}
333 pub parent: Option<String>,
334 /// Required. The row to create.
335 pub row: Option<Row>,
336 /// Optional. Column key to use for values in the row. Defaults to user entered name.
337 pub view: Option<String>,
338}
339
340impl common::Part for CreateRowRequest {}
341
342/// Details about a date column.
343///
344/// This type is not used in any activity, and only used as *part* of another schema.
345///
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct DateDetails {
350 /// Whether the date column includes time.
351 #[serde(rename = "hasTime")]
352 pub has_time: Option<bool>,
353}
354
355impl common::Part for DateDetails {}
356
357/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
358///
359/// # Activities
360///
361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
363///
364/// * [rows batch delete tables](TableRowBatchDeleteCall) (response)
365/// * [rows delete tables](TableRowDeleteCall) (response)
366#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
367#[serde_with::serde_as]
368#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
369pub struct Empty {
370 _never_set: Option<bool>,
371}
372
373impl common::ResponseResult for Empty {}
374
375/// A single item in a labeled column.
376///
377/// This type is not used in any activity, and only used as *part* of another schema.
378///
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct LabeledItem {
383 /// Internal id associated with the item.
384 pub id: Option<String>,
385 /// Display string as entered by user.
386 pub name: Option<String>,
387}
388
389impl common::Part for LabeledItem {}
390
391/// Response message for TablesService.ListRows.
392///
393/// # Activities
394///
395/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
396/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
397///
398/// * [rows list tables](TableRowListCall) (response)
399#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
400#[serde_with::serde_as]
401#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
402pub struct ListRowsResponse {
403 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages.
404 #[serde(rename = "nextPageToken")]
405 pub next_page_token: Option<String>,
406 /// The rows from the specified table.
407 pub rows: Option<Vec<Row>>,
408}
409
410impl common::ResponseResult for ListRowsResponse {}
411
412/// Response message for TablesService.ListTables.
413///
414/// # Activities
415///
416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
418///
419/// * [list tables](TableListCall) (response)
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct ListTablesResponse {
424 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages.
425 #[serde(rename = "nextPageToken")]
426 pub next_page_token: Option<String>,
427 /// The list of tables.
428 pub tables: Option<Vec<Table>>,
429}
430
431impl common::ResponseResult for ListTablesResponse {}
432
433/// Response message for TablesService.ListWorkspaces.
434///
435/// # Activities
436///
437/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
438/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
439///
440/// * [list workspaces](WorkspaceListCall) (response)
441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
442#[serde_with::serde_as]
443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
444pub struct ListWorkspacesResponse {
445 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is empty, there are no subsequent pages.
446 #[serde(rename = "nextPageToken")]
447 pub next_page_token: Option<String>,
448 /// The list of workspaces.
449 pub workspaces: Option<Vec<Workspace>>,
450}
451
452impl common::ResponseResult for ListWorkspacesResponse {}
453
454/// Details about a lookup column whose value comes from the associated relationship.
455///
456/// This type is not used in any activity, and only used as *part* of another schema.
457///
458#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
459#[serde_with::serde_as]
460#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
461pub struct LookupDetails {
462 /// The name of the relationship column associated with the lookup.
463 #[serde(rename = "relationshipColumn")]
464 pub relationship_column: Option<String>,
465 /// The id of the relationship column.
466 #[serde(rename = "relationshipColumnId")]
467 pub relationship_column_id: Option<String>,
468}
469
470impl common::Part for LookupDetails {}
471
472/// Details about a relationship column.
473///
474/// This type is not used in any activity, and only used as *part* of another schema.
475///
476#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
477#[serde_with::serde_as]
478#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
479pub struct RelationshipDetails {
480 /// The name of the table this relationship is linked to.
481 #[serde(rename = "linkedTable")]
482 pub linked_table: Option<String>,
483}
484
485impl common::Part for RelationshipDetails {}
486
487/// A single row in a table.
488///
489/// # Activities
490///
491/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
492/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
493///
494/// * [rows create tables](TableRowCreateCall) (request|response)
495/// * [rows get tables](TableRowGetCall) (response)
496/// * [rows patch tables](TableRowPatchCall) (request|response)
497#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
498#[serde_with::serde_as]
499#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
500pub struct Row {
501 /// Time when the row was created.
502 #[serde(rename = "createTime")]
503 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
504 /// The resource name of the row. Row names have the form `tables/{table}/rows/{row}`. The name is ignored when creating a row.
505 pub name: Option<String>,
506 /// Time when the row was last updated.
507 #[serde(rename = "updateTime")]
508 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
509 /// The values of the row. This is a map of column key to value. Key is user entered name(default) or the internal column id based on the view in the request.
510 pub values: Option<HashMap<String, serde_json::Value>>,
511}
512
513impl common::RequestValue for Row {}
514impl common::ResponseResult for Row {}
515
516/// A saved view of a table. NextId: 3
517///
518/// This type is not used in any activity, and only used as *part* of another schema.
519///
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct SavedView {
524 /// Internal id associated with the saved view.
525 pub id: Option<String>,
526 /// Display name of the saved view.
527 pub name: Option<String>,
528}
529
530impl common::Part for SavedView {}
531
532/// A single table. NextId: 8
533///
534/// # Activities
535///
536/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
537/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
538///
539/// * [rows batch create tables](TableRowBatchCreateCall) (none)
540/// * [rows batch delete tables](TableRowBatchDeleteCall) (none)
541/// * [rows batch update tables](TableRowBatchUpdateCall) (none)
542/// * [rows create tables](TableRowCreateCall) (none)
543/// * [rows delete tables](TableRowDeleteCall) (none)
544/// * [rows get tables](TableRowGetCall) (none)
545/// * [rows list tables](TableRowListCall) (none)
546/// * [rows patch tables](TableRowPatchCall) (none)
547/// * [get tables](TableGetCall) (response)
548/// * [list tables](TableListCall) (none)
549#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
550#[serde_with::serde_as]
551#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
552pub struct Table {
553 /// List of columns in this table. Order of columns matches the display order.
554 pub columns: Option<Vec<ColumnDescription>>,
555 /// Time when the table was created.
556 #[serde(rename = "createTime")]
557 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
558 /// The human readable title of the table.
559 #[serde(rename = "displayName")]
560 pub display_name: Option<String>,
561 /// The resource name of the table. Table names have the form `tables/{table}`.
562 pub name: Option<String>,
563 /// Saved views for this table.
564 #[serde(rename = "savedViews")]
565 pub saved_views: Option<Vec<SavedView>>,
566 /// The time zone of the table. IANA Time Zone Database time zone, e.g. "America/New_York".
567 #[serde(rename = "timeZone")]
568 pub time_zone: Option<String>,
569 /// Time when the table was last updated excluding updates to individual rows
570 #[serde(rename = "updateTime")]
571 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
572}
573
574impl common::Resource for Table {}
575impl common::ResponseResult for Table {}
576
577/// Request message for TablesService.UpdateRow.
578///
579/// This type is not used in any activity, and only used as *part* of another schema.
580///
581#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
582#[serde_with::serde_as]
583#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
584pub struct UpdateRowRequest {
585 /// Required. The row to update.
586 pub row: Option<Row>,
587 /// The list of fields to update.
588 #[serde(rename = "updateMask")]
589 pub update_mask: Option<common::FieldMask>,
590 /// Optional. Column key to use for values in the row. Defaults to user entered name.
591 pub view: Option<String>,
592}
593
594impl common::Part for UpdateRowRequest {}
595
596/// A single workspace.
597///
598/// # Activities
599///
600/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
601/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
602///
603/// * [get workspaces](WorkspaceGetCall) (response)
604/// * [list workspaces](WorkspaceListCall) (none)
605#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
606#[serde_with::serde_as]
607#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
608pub struct Workspace {
609 /// Time when the workspace was created.
610 #[serde(rename = "createTime")]
611 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
612 /// The human readable title of the workspace.
613 #[serde(rename = "displayName")]
614 pub display_name: Option<String>,
615 /// The resource name of the workspace. Workspace names have the form `workspaces/{workspace}`.
616 pub name: Option<String>,
617 /// The list of tables in the workspace.
618 pub tables: Option<Vec<Table>>,
619 /// Time when the workspace was last updated.
620 #[serde(rename = "updateTime")]
621 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
622}
623
624impl common::Resource for Workspace {}
625impl common::ResponseResult for Workspace {}
626
627// ###################
628// MethodBuilders ###
629// #################
630
631/// A builder providing access to all methods supported on *table* resources.
632/// It is not used directly, but through the [`Area120Tables`] hub.
633///
634/// # Example
635///
636/// Instantiate a resource builder
637///
638/// ```test_harness,no_run
639/// extern crate hyper;
640/// extern crate hyper_rustls;
641/// extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
642///
643/// # async fn dox() {
644/// use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
645///
646/// let secret: yup_oauth2::ApplicationSecret = Default::default();
647/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
648/// .with_native_roots()
649/// .unwrap()
650/// .https_only()
651/// .enable_http2()
652/// .build();
653///
654/// let executor = hyper_util::rt::TokioExecutor::new();
655/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
656/// secret,
657/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
658/// yup_oauth2::client::CustomHyperClientBuilder::from(
659/// hyper_util::client::legacy::Client::builder(executor).build(connector),
660/// ),
661/// ).build().await.unwrap();
662///
663/// let client = hyper_util::client::legacy::Client::builder(
664/// hyper_util::rt::TokioExecutor::new()
665/// )
666/// .build(
667/// hyper_rustls::HttpsConnectorBuilder::new()
668/// .with_native_roots()
669/// .unwrap()
670/// .https_or_http()
671/// .enable_http2()
672/// .build()
673/// );
674/// let mut hub = Area120Tables::new(client, auth);
675/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
676/// // like `get(...)`, `list(...)`, `rows_batch_create(...)`, `rows_batch_delete(...)`, `rows_batch_update(...)`, `rows_create(...)`, `rows_delete(...)`, `rows_get(...)`, `rows_list(...)` and `rows_patch(...)`
677/// // to build up your call.
678/// let rb = hub.tables();
679/// # }
680/// ```
681pub struct TableMethods<'a, C>
682where
683 C: 'a,
684{
685 hub: &'a Area120Tables<C>,
686}
687
688impl<'a, C> common::MethodsBuilder for TableMethods<'a, C> {}
689
690impl<'a, C> TableMethods<'a, C> {
691 /// Create a builder to help you perform the following task:
692 ///
693 /// Creates multiple rows.
694 ///
695 /// # Arguments
696 ///
697 /// * `request` - No description provided.
698 /// * `parent` - Required. The parent table where the rows will be created. Format: tables/{table}
699 pub fn rows_batch_create(
700 &self,
701 request: BatchCreateRowsRequest,
702 parent: &str,
703 ) -> TableRowBatchCreateCall<'a, C> {
704 TableRowBatchCreateCall {
705 hub: self.hub,
706 _request: request,
707 _parent: parent.to_string(),
708 _delegate: Default::default(),
709 _additional_params: Default::default(),
710 _scopes: Default::default(),
711 }
712 }
713
714 /// Create a builder to help you perform the following task:
715 ///
716 /// Deletes multiple rows.
717 ///
718 /// # Arguments
719 ///
720 /// * `request` - No description provided.
721 /// * `parent` - Required. The parent table shared by all rows being deleted. Format: tables/{table}
722 pub fn rows_batch_delete(
723 &self,
724 request: BatchDeleteRowsRequest,
725 parent: &str,
726 ) -> TableRowBatchDeleteCall<'a, C> {
727 TableRowBatchDeleteCall {
728 hub: self.hub,
729 _request: request,
730 _parent: parent.to_string(),
731 _delegate: Default::default(),
732 _additional_params: Default::default(),
733 _scopes: Default::default(),
734 }
735 }
736
737 /// Create a builder to help you perform the following task:
738 ///
739 /// Updates multiple rows.
740 ///
741 /// # Arguments
742 ///
743 /// * `request` - No description provided.
744 /// * `parent` - Required. The parent table shared by all rows being updated. Format: tables/{table}
745 pub fn rows_batch_update(
746 &self,
747 request: BatchUpdateRowsRequest,
748 parent: &str,
749 ) -> TableRowBatchUpdateCall<'a, C> {
750 TableRowBatchUpdateCall {
751 hub: self.hub,
752 _request: request,
753 _parent: parent.to_string(),
754 _delegate: Default::default(),
755 _additional_params: Default::default(),
756 _scopes: Default::default(),
757 }
758 }
759
760 /// Create a builder to help you perform the following task:
761 ///
762 /// Creates a row.
763 ///
764 /// # Arguments
765 ///
766 /// * `request` - No description provided.
767 /// * `parent` - Required. The parent table where this row will be created. Format: tables/{table}
768 pub fn rows_create(&self, request: Row, parent: &str) -> TableRowCreateCall<'a, C> {
769 TableRowCreateCall {
770 hub: self.hub,
771 _request: request,
772 _parent: parent.to_string(),
773 _view: Default::default(),
774 _delegate: Default::default(),
775 _additional_params: Default::default(),
776 _scopes: Default::default(),
777 }
778 }
779
780 /// Create a builder to help you perform the following task:
781 ///
782 /// Deletes a row.
783 ///
784 /// # Arguments
785 ///
786 /// * `name` - Required. The name of the row to delete. Format: tables/{table}/rows/{row}
787 pub fn rows_delete(&self, name: &str) -> TableRowDeleteCall<'a, C> {
788 TableRowDeleteCall {
789 hub: self.hub,
790 _name: name.to_string(),
791 _delegate: Default::default(),
792 _additional_params: Default::default(),
793 _scopes: Default::default(),
794 }
795 }
796
797 /// Create a builder to help you perform the following task:
798 ///
799 /// Gets a row. Returns NOT_FOUND if the row does not exist in the table.
800 ///
801 /// # Arguments
802 ///
803 /// * `name` - Required. The name of the row to retrieve. Format: tables/{table}/rows/{row}
804 pub fn rows_get(&self, name: &str) -> TableRowGetCall<'a, C> {
805 TableRowGetCall {
806 hub: self.hub,
807 _name: name.to_string(),
808 _view: Default::default(),
809 _delegate: Default::default(),
810 _additional_params: Default::default(),
811 _scopes: Default::default(),
812 }
813 }
814
815 /// Create a builder to help you perform the following task:
816 ///
817 /// Lists rows in a table. Returns NOT_FOUND if the table does not exist.
818 ///
819 /// # Arguments
820 ///
821 /// * `parent` - Required. The parent table. Format: tables/{table}
822 pub fn rows_list(&self, parent: &str) -> TableRowListCall<'a, C> {
823 TableRowListCall {
824 hub: self.hub,
825 _parent: parent.to_string(),
826 _view: Default::default(),
827 _page_token: Default::default(),
828 _page_size: Default::default(),
829 _order_by: Default::default(),
830 _filter: Default::default(),
831 _delegate: Default::default(),
832 _additional_params: Default::default(),
833 _scopes: Default::default(),
834 }
835 }
836
837 /// Create a builder to help you perform the following task:
838 ///
839 /// Updates a row.
840 ///
841 /// # Arguments
842 ///
843 /// * `request` - No description provided.
844 /// * `name` - The resource name of the row. Row names have the form `tables/{table}/rows/{row}`. The name is ignored when creating a row.
845 pub fn rows_patch(&self, request: Row, name: &str) -> TableRowPatchCall<'a, C> {
846 TableRowPatchCall {
847 hub: self.hub,
848 _request: request,
849 _name: name.to_string(),
850 _view: Default::default(),
851 _update_mask: Default::default(),
852 _delegate: Default::default(),
853 _additional_params: Default::default(),
854 _scopes: Default::default(),
855 }
856 }
857
858 /// Create a builder to help you perform the following task:
859 ///
860 /// Gets a table. Returns NOT_FOUND if the table does not exist.
861 ///
862 /// # Arguments
863 ///
864 /// * `name` - Required. The name of the table to retrieve. Format: tables/{table}
865 pub fn get(&self, name: &str) -> TableGetCall<'a, C> {
866 TableGetCall {
867 hub: self.hub,
868 _name: name.to_string(),
869 _delegate: Default::default(),
870 _additional_params: Default::default(),
871 _scopes: Default::default(),
872 }
873 }
874
875 /// Create a builder to help you perform the following task:
876 ///
877 /// Lists tables for the user.
878 pub fn list(&self) -> TableListCall<'a, C> {
879 TableListCall {
880 hub: self.hub,
881 _page_token: Default::default(),
882 _page_size: Default::default(),
883 _order_by: Default::default(),
884 _delegate: Default::default(),
885 _additional_params: Default::default(),
886 _scopes: Default::default(),
887 }
888 }
889}
890
891/// A builder providing access to all methods supported on *workspace* resources.
892/// It is not used directly, but through the [`Area120Tables`] hub.
893///
894/// # Example
895///
896/// Instantiate a resource builder
897///
898/// ```test_harness,no_run
899/// extern crate hyper;
900/// extern crate hyper_rustls;
901/// extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
902///
903/// # async fn dox() {
904/// use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
905///
906/// let secret: yup_oauth2::ApplicationSecret = Default::default();
907/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
908/// .with_native_roots()
909/// .unwrap()
910/// .https_only()
911/// .enable_http2()
912/// .build();
913///
914/// let executor = hyper_util::rt::TokioExecutor::new();
915/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
916/// secret,
917/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
918/// yup_oauth2::client::CustomHyperClientBuilder::from(
919/// hyper_util::client::legacy::Client::builder(executor).build(connector),
920/// ),
921/// ).build().await.unwrap();
922///
923/// let client = hyper_util::client::legacy::Client::builder(
924/// hyper_util::rt::TokioExecutor::new()
925/// )
926/// .build(
927/// hyper_rustls::HttpsConnectorBuilder::new()
928/// .with_native_roots()
929/// .unwrap()
930/// .https_or_http()
931/// .enable_http2()
932/// .build()
933/// );
934/// let mut hub = Area120Tables::new(client, auth);
935/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
936/// // like `get(...)` and `list(...)`
937/// // to build up your call.
938/// let rb = hub.workspaces();
939/// # }
940/// ```
941pub struct WorkspaceMethods<'a, C>
942where
943 C: 'a,
944{
945 hub: &'a Area120Tables<C>,
946}
947
948impl<'a, C> common::MethodsBuilder for WorkspaceMethods<'a, C> {}
949
950impl<'a, C> WorkspaceMethods<'a, C> {
951 /// Create a builder to help you perform the following task:
952 ///
953 /// Gets a workspace. Returns NOT_FOUND if the workspace does not exist.
954 ///
955 /// # Arguments
956 ///
957 /// * `name` - Required. The name of the workspace to retrieve. Format: workspaces/{workspace}
958 pub fn get(&self, name: &str) -> WorkspaceGetCall<'a, C> {
959 WorkspaceGetCall {
960 hub: self.hub,
961 _name: name.to_string(),
962 _delegate: Default::default(),
963 _additional_params: Default::default(),
964 _scopes: Default::default(),
965 }
966 }
967
968 /// Create a builder to help you perform the following task:
969 ///
970 /// Lists workspaces for the user.
971 pub fn list(&self) -> WorkspaceListCall<'a, C> {
972 WorkspaceListCall {
973 hub: self.hub,
974 _page_token: Default::default(),
975 _page_size: Default::default(),
976 _delegate: Default::default(),
977 _additional_params: Default::default(),
978 _scopes: Default::default(),
979 }
980 }
981}
982
983// ###################
984// CallBuilders ###
985// #################
986
987/// Creates multiple rows.
988///
989/// A builder for the *rows.batchCreate* method supported by a *table* resource.
990/// It is not used directly, but through a [`TableMethods`] instance.
991///
992/// # Example
993///
994/// Instantiate a resource method builder
995///
996/// ```test_harness,no_run
997/// # extern crate hyper;
998/// # extern crate hyper_rustls;
999/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
1000/// use area120tables1_alpha1::api::BatchCreateRowsRequest;
1001/// # async fn dox() {
1002/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1003///
1004/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1005/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1006/// # .with_native_roots()
1007/// # .unwrap()
1008/// # .https_only()
1009/// # .enable_http2()
1010/// # .build();
1011///
1012/// # let executor = hyper_util::rt::TokioExecutor::new();
1013/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1014/// # secret,
1015/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1016/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1017/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1018/// # ),
1019/// # ).build().await.unwrap();
1020///
1021/// # let client = hyper_util::client::legacy::Client::builder(
1022/// # hyper_util::rt::TokioExecutor::new()
1023/// # )
1024/// # .build(
1025/// # hyper_rustls::HttpsConnectorBuilder::new()
1026/// # .with_native_roots()
1027/// # .unwrap()
1028/// # .https_or_http()
1029/// # .enable_http2()
1030/// # .build()
1031/// # );
1032/// # let mut hub = Area120Tables::new(client, auth);
1033/// // As the method needs a request, you would usually fill it with the desired information
1034/// // into the respective structure. Some of the parts shown here might not be applicable !
1035/// // Values shown here are possibly random and not representative !
1036/// let mut req = BatchCreateRowsRequest::default();
1037///
1038/// // You can configure optional parameters by calling the respective setters at will, and
1039/// // execute the final call using `doit()`.
1040/// // Values shown here are possibly random and not representative !
1041/// let result = hub.tables().rows_batch_create(req, "parent")
1042/// .doit().await;
1043/// # }
1044/// ```
1045pub struct TableRowBatchCreateCall<'a, C>
1046where
1047 C: 'a,
1048{
1049 hub: &'a Area120Tables<C>,
1050 _request: BatchCreateRowsRequest,
1051 _parent: String,
1052 _delegate: Option<&'a mut dyn common::Delegate>,
1053 _additional_params: HashMap<String, String>,
1054 _scopes: BTreeSet<String>,
1055}
1056
1057impl<'a, C> common::CallBuilder for TableRowBatchCreateCall<'a, C> {}
1058
1059impl<'a, C> TableRowBatchCreateCall<'a, C>
1060where
1061 C: common::Connector,
1062{
1063 /// Perform the operation you have build so far.
1064 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateRowsResponse)> {
1065 use std::borrow::Cow;
1066 use std::io::{Read, Seek};
1067
1068 use common::{url::Params, ToParts};
1069 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1070
1071 let mut dd = common::DefaultDelegate;
1072 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1073 dlg.begin(common::MethodInfo {
1074 id: "area120tables.tables.rows.batchCreate",
1075 http_method: hyper::Method::POST,
1076 });
1077
1078 for &field in ["alt", "parent"].iter() {
1079 if self._additional_params.contains_key(field) {
1080 dlg.finished(false);
1081 return Err(common::Error::FieldClash(field));
1082 }
1083 }
1084
1085 let mut params = Params::with_capacity(4 + self._additional_params.len());
1086 params.push("parent", self._parent);
1087
1088 params.extend(self._additional_params.iter());
1089
1090 params.push("alt", "json");
1091 let mut url = self.hub._base_url.clone() + "v1alpha1/{+parent}/rows:batchCreate";
1092 if self._scopes.is_empty() {
1093 self._scopes.insert(Scope::Drive.as_ref().to_string());
1094 }
1095
1096 #[allow(clippy::single_element_loop)]
1097 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1098 url = params.uri_replacement(url, param_name, find_this, true);
1099 }
1100 {
1101 let to_remove = ["parent"];
1102 params.remove_params(&to_remove);
1103 }
1104
1105 let url = params.parse_with_url(&url);
1106
1107 let mut json_mime_type = mime::APPLICATION_JSON;
1108 let mut request_value_reader = {
1109 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1110 common::remove_json_null_values(&mut value);
1111 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1112 serde_json::to_writer(&mut dst, &value).unwrap();
1113 dst
1114 };
1115 let request_size = request_value_reader
1116 .seek(std::io::SeekFrom::End(0))
1117 .unwrap();
1118 request_value_reader
1119 .seek(std::io::SeekFrom::Start(0))
1120 .unwrap();
1121
1122 loop {
1123 let token = match self
1124 .hub
1125 .auth
1126 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1127 .await
1128 {
1129 Ok(token) => token,
1130 Err(e) => match dlg.token(e) {
1131 Ok(token) => token,
1132 Err(e) => {
1133 dlg.finished(false);
1134 return Err(common::Error::MissingToken(e));
1135 }
1136 },
1137 };
1138 request_value_reader
1139 .seek(std::io::SeekFrom::Start(0))
1140 .unwrap();
1141 let mut req_result = {
1142 let client = &self.hub.client;
1143 dlg.pre_request();
1144 let mut req_builder = hyper::Request::builder()
1145 .method(hyper::Method::POST)
1146 .uri(url.as_str())
1147 .header(USER_AGENT, self.hub._user_agent.clone());
1148
1149 if let Some(token) = token.as_ref() {
1150 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1151 }
1152
1153 let request = req_builder
1154 .header(CONTENT_TYPE, json_mime_type.to_string())
1155 .header(CONTENT_LENGTH, request_size as u64)
1156 .body(common::to_body(
1157 request_value_reader.get_ref().clone().into(),
1158 ));
1159
1160 client.request(request.unwrap()).await
1161 };
1162
1163 match req_result {
1164 Err(err) => {
1165 if let common::Retry::After(d) = dlg.http_error(&err) {
1166 sleep(d).await;
1167 continue;
1168 }
1169 dlg.finished(false);
1170 return Err(common::Error::HttpError(err));
1171 }
1172 Ok(res) => {
1173 let (mut parts, body) = res.into_parts();
1174 let mut body = common::Body::new(body);
1175 if !parts.status.is_success() {
1176 let bytes = common::to_bytes(body).await.unwrap_or_default();
1177 let error = serde_json::from_str(&common::to_string(&bytes));
1178 let response = common::to_response(parts, bytes.into());
1179
1180 if let common::Retry::After(d) =
1181 dlg.http_failure(&response, error.as_ref().ok())
1182 {
1183 sleep(d).await;
1184 continue;
1185 }
1186
1187 dlg.finished(false);
1188
1189 return Err(match error {
1190 Ok(value) => common::Error::BadRequest(value),
1191 _ => common::Error::Failure(response),
1192 });
1193 }
1194 let response = {
1195 let bytes = common::to_bytes(body).await.unwrap_or_default();
1196 let encoded = common::to_string(&bytes);
1197 match serde_json::from_str(&encoded) {
1198 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1199 Err(error) => {
1200 dlg.response_json_decode_error(&encoded, &error);
1201 return Err(common::Error::JsonDecodeError(
1202 encoded.to_string(),
1203 error,
1204 ));
1205 }
1206 }
1207 };
1208
1209 dlg.finished(true);
1210 return Ok(response);
1211 }
1212 }
1213 }
1214 }
1215
1216 ///
1217 /// Sets the *request* property to the given value.
1218 ///
1219 /// Even though the property as already been set when instantiating this call,
1220 /// we provide this method for API completeness.
1221 pub fn request(mut self, new_value: BatchCreateRowsRequest) -> TableRowBatchCreateCall<'a, C> {
1222 self._request = new_value;
1223 self
1224 }
1225 /// Required. The parent table where the rows will be created. Format: tables/{table}
1226 ///
1227 /// Sets the *parent* path property to the given value.
1228 ///
1229 /// Even though the property as already been set when instantiating this call,
1230 /// we provide this method for API completeness.
1231 pub fn parent(mut self, new_value: &str) -> TableRowBatchCreateCall<'a, C> {
1232 self._parent = new_value.to_string();
1233 self
1234 }
1235 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1236 /// while executing the actual API request.
1237 ///
1238 /// ````text
1239 /// It should be used to handle progress information, and to implement a certain level of resilience.
1240 /// ````
1241 ///
1242 /// Sets the *delegate* property to the given value.
1243 pub fn delegate(
1244 mut self,
1245 new_value: &'a mut dyn common::Delegate,
1246 ) -> TableRowBatchCreateCall<'a, C> {
1247 self._delegate = Some(new_value);
1248 self
1249 }
1250
1251 /// Set any additional parameter of the query string used in the request.
1252 /// It should be used to set parameters which are not yet available through their own
1253 /// setters.
1254 ///
1255 /// Please note that this method must not be used to set any of the known parameters
1256 /// which have their own setter method. If done anyway, the request will fail.
1257 ///
1258 /// # Additional Parameters
1259 ///
1260 /// * *$.xgafv* (query-string) - V1 error format.
1261 /// * *access_token* (query-string) - OAuth access token.
1262 /// * *alt* (query-string) - Data format for response.
1263 /// * *callback* (query-string) - JSONP
1264 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1265 /// * *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.
1266 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1267 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1268 /// * *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.
1269 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1270 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1271 pub fn param<T>(mut self, name: T, value: T) -> TableRowBatchCreateCall<'a, C>
1272 where
1273 T: AsRef<str>,
1274 {
1275 self._additional_params
1276 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1277 self
1278 }
1279
1280 /// Identifies the authorization scope for the method you are building.
1281 ///
1282 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1283 /// [`Scope::Drive`].
1284 ///
1285 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1286 /// tokens for more than one scope.
1287 ///
1288 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1289 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1290 /// sufficient, a read-write scope will do as well.
1291 pub fn add_scope<St>(mut self, scope: St) -> TableRowBatchCreateCall<'a, C>
1292 where
1293 St: AsRef<str>,
1294 {
1295 self._scopes.insert(String::from(scope.as_ref()));
1296 self
1297 }
1298 /// Identifies the authorization scope(s) for the method you are building.
1299 ///
1300 /// See [`Self::add_scope()`] for details.
1301 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowBatchCreateCall<'a, C>
1302 where
1303 I: IntoIterator<Item = St>,
1304 St: AsRef<str>,
1305 {
1306 self._scopes
1307 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1308 self
1309 }
1310
1311 /// Removes all scopes, and no default scope will be used either.
1312 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1313 /// for details).
1314 pub fn clear_scopes(mut self) -> TableRowBatchCreateCall<'a, C> {
1315 self._scopes.clear();
1316 self
1317 }
1318}
1319
1320/// Deletes multiple rows.
1321///
1322/// A builder for the *rows.batchDelete* method supported by a *table* resource.
1323/// It is not used directly, but through a [`TableMethods`] instance.
1324///
1325/// # Example
1326///
1327/// Instantiate a resource method builder
1328///
1329/// ```test_harness,no_run
1330/// # extern crate hyper;
1331/// # extern crate hyper_rustls;
1332/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
1333/// use area120tables1_alpha1::api::BatchDeleteRowsRequest;
1334/// # async fn dox() {
1335/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1336///
1337/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1338/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1339/// # .with_native_roots()
1340/// # .unwrap()
1341/// # .https_only()
1342/// # .enable_http2()
1343/// # .build();
1344///
1345/// # let executor = hyper_util::rt::TokioExecutor::new();
1346/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1347/// # secret,
1348/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1349/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1350/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1351/// # ),
1352/// # ).build().await.unwrap();
1353///
1354/// # let client = hyper_util::client::legacy::Client::builder(
1355/// # hyper_util::rt::TokioExecutor::new()
1356/// # )
1357/// # .build(
1358/// # hyper_rustls::HttpsConnectorBuilder::new()
1359/// # .with_native_roots()
1360/// # .unwrap()
1361/// # .https_or_http()
1362/// # .enable_http2()
1363/// # .build()
1364/// # );
1365/// # let mut hub = Area120Tables::new(client, auth);
1366/// // As the method needs a request, you would usually fill it with the desired information
1367/// // into the respective structure. Some of the parts shown here might not be applicable !
1368/// // Values shown here are possibly random and not representative !
1369/// let mut req = BatchDeleteRowsRequest::default();
1370///
1371/// // You can configure optional parameters by calling the respective setters at will, and
1372/// // execute the final call using `doit()`.
1373/// // Values shown here are possibly random and not representative !
1374/// let result = hub.tables().rows_batch_delete(req, "parent")
1375/// .doit().await;
1376/// # }
1377/// ```
1378pub struct TableRowBatchDeleteCall<'a, C>
1379where
1380 C: 'a,
1381{
1382 hub: &'a Area120Tables<C>,
1383 _request: BatchDeleteRowsRequest,
1384 _parent: String,
1385 _delegate: Option<&'a mut dyn common::Delegate>,
1386 _additional_params: HashMap<String, String>,
1387 _scopes: BTreeSet<String>,
1388}
1389
1390impl<'a, C> common::CallBuilder for TableRowBatchDeleteCall<'a, C> {}
1391
1392impl<'a, C> TableRowBatchDeleteCall<'a, C>
1393where
1394 C: common::Connector,
1395{
1396 /// Perform the operation you have build so far.
1397 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1398 use std::borrow::Cow;
1399 use std::io::{Read, Seek};
1400
1401 use common::{url::Params, ToParts};
1402 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1403
1404 let mut dd = common::DefaultDelegate;
1405 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1406 dlg.begin(common::MethodInfo {
1407 id: "area120tables.tables.rows.batchDelete",
1408 http_method: hyper::Method::POST,
1409 });
1410
1411 for &field in ["alt", "parent"].iter() {
1412 if self._additional_params.contains_key(field) {
1413 dlg.finished(false);
1414 return Err(common::Error::FieldClash(field));
1415 }
1416 }
1417
1418 let mut params = Params::with_capacity(4 + self._additional_params.len());
1419 params.push("parent", self._parent);
1420
1421 params.extend(self._additional_params.iter());
1422
1423 params.push("alt", "json");
1424 let mut url = self.hub._base_url.clone() + "v1alpha1/{+parent}/rows:batchDelete";
1425 if self._scopes.is_empty() {
1426 self._scopes.insert(Scope::Drive.as_ref().to_string());
1427 }
1428
1429 #[allow(clippy::single_element_loop)]
1430 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1431 url = params.uri_replacement(url, param_name, find_this, true);
1432 }
1433 {
1434 let to_remove = ["parent"];
1435 params.remove_params(&to_remove);
1436 }
1437
1438 let url = params.parse_with_url(&url);
1439
1440 let mut json_mime_type = mime::APPLICATION_JSON;
1441 let mut request_value_reader = {
1442 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1443 common::remove_json_null_values(&mut value);
1444 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1445 serde_json::to_writer(&mut dst, &value).unwrap();
1446 dst
1447 };
1448 let request_size = request_value_reader
1449 .seek(std::io::SeekFrom::End(0))
1450 .unwrap();
1451 request_value_reader
1452 .seek(std::io::SeekFrom::Start(0))
1453 .unwrap();
1454
1455 loop {
1456 let token = match self
1457 .hub
1458 .auth
1459 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1460 .await
1461 {
1462 Ok(token) => token,
1463 Err(e) => match dlg.token(e) {
1464 Ok(token) => token,
1465 Err(e) => {
1466 dlg.finished(false);
1467 return Err(common::Error::MissingToken(e));
1468 }
1469 },
1470 };
1471 request_value_reader
1472 .seek(std::io::SeekFrom::Start(0))
1473 .unwrap();
1474 let mut req_result = {
1475 let client = &self.hub.client;
1476 dlg.pre_request();
1477 let mut req_builder = hyper::Request::builder()
1478 .method(hyper::Method::POST)
1479 .uri(url.as_str())
1480 .header(USER_AGENT, self.hub._user_agent.clone());
1481
1482 if let Some(token) = token.as_ref() {
1483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1484 }
1485
1486 let request = req_builder
1487 .header(CONTENT_TYPE, json_mime_type.to_string())
1488 .header(CONTENT_LENGTH, request_size as u64)
1489 .body(common::to_body(
1490 request_value_reader.get_ref().clone().into(),
1491 ));
1492
1493 client.request(request.unwrap()).await
1494 };
1495
1496 match req_result {
1497 Err(err) => {
1498 if let common::Retry::After(d) = dlg.http_error(&err) {
1499 sleep(d).await;
1500 continue;
1501 }
1502 dlg.finished(false);
1503 return Err(common::Error::HttpError(err));
1504 }
1505 Ok(res) => {
1506 let (mut parts, body) = res.into_parts();
1507 let mut body = common::Body::new(body);
1508 if !parts.status.is_success() {
1509 let bytes = common::to_bytes(body).await.unwrap_or_default();
1510 let error = serde_json::from_str(&common::to_string(&bytes));
1511 let response = common::to_response(parts, bytes.into());
1512
1513 if let common::Retry::After(d) =
1514 dlg.http_failure(&response, error.as_ref().ok())
1515 {
1516 sleep(d).await;
1517 continue;
1518 }
1519
1520 dlg.finished(false);
1521
1522 return Err(match error {
1523 Ok(value) => common::Error::BadRequest(value),
1524 _ => common::Error::Failure(response),
1525 });
1526 }
1527 let response = {
1528 let bytes = common::to_bytes(body).await.unwrap_or_default();
1529 let encoded = common::to_string(&bytes);
1530 match serde_json::from_str(&encoded) {
1531 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1532 Err(error) => {
1533 dlg.response_json_decode_error(&encoded, &error);
1534 return Err(common::Error::JsonDecodeError(
1535 encoded.to_string(),
1536 error,
1537 ));
1538 }
1539 }
1540 };
1541
1542 dlg.finished(true);
1543 return Ok(response);
1544 }
1545 }
1546 }
1547 }
1548
1549 ///
1550 /// Sets the *request* property to the given value.
1551 ///
1552 /// Even though the property as already been set when instantiating this call,
1553 /// we provide this method for API completeness.
1554 pub fn request(mut self, new_value: BatchDeleteRowsRequest) -> TableRowBatchDeleteCall<'a, C> {
1555 self._request = new_value;
1556 self
1557 }
1558 /// Required. The parent table shared by all rows being deleted. Format: tables/{table}
1559 ///
1560 /// Sets the *parent* path property to the given value.
1561 ///
1562 /// Even though the property as already been set when instantiating this call,
1563 /// we provide this method for API completeness.
1564 pub fn parent(mut self, new_value: &str) -> TableRowBatchDeleteCall<'a, C> {
1565 self._parent = new_value.to_string();
1566 self
1567 }
1568 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1569 /// while executing the actual API request.
1570 ///
1571 /// ````text
1572 /// It should be used to handle progress information, and to implement a certain level of resilience.
1573 /// ````
1574 ///
1575 /// Sets the *delegate* property to the given value.
1576 pub fn delegate(
1577 mut self,
1578 new_value: &'a mut dyn common::Delegate,
1579 ) -> TableRowBatchDeleteCall<'a, C> {
1580 self._delegate = Some(new_value);
1581 self
1582 }
1583
1584 /// Set any additional parameter of the query string used in the request.
1585 /// It should be used to set parameters which are not yet available through their own
1586 /// setters.
1587 ///
1588 /// Please note that this method must not be used to set any of the known parameters
1589 /// which have their own setter method. If done anyway, the request will fail.
1590 ///
1591 /// # Additional Parameters
1592 ///
1593 /// * *$.xgafv* (query-string) - V1 error format.
1594 /// * *access_token* (query-string) - OAuth access token.
1595 /// * *alt* (query-string) - Data format for response.
1596 /// * *callback* (query-string) - JSONP
1597 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1598 /// * *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.
1599 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1600 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1601 /// * *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.
1602 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1603 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1604 pub fn param<T>(mut self, name: T, value: T) -> TableRowBatchDeleteCall<'a, C>
1605 where
1606 T: AsRef<str>,
1607 {
1608 self._additional_params
1609 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1610 self
1611 }
1612
1613 /// Identifies the authorization scope for the method you are building.
1614 ///
1615 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1616 /// [`Scope::Drive`].
1617 ///
1618 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1619 /// tokens for more than one scope.
1620 ///
1621 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1622 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1623 /// sufficient, a read-write scope will do as well.
1624 pub fn add_scope<St>(mut self, scope: St) -> TableRowBatchDeleteCall<'a, C>
1625 where
1626 St: AsRef<str>,
1627 {
1628 self._scopes.insert(String::from(scope.as_ref()));
1629 self
1630 }
1631 /// Identifies the authorization scope(s) for the method you are building.
1632 ///
1633 /// See [`Self::add_scope()`] for details.
1634 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowBatchDeleteCall<'a, C>
1635 where
1636 I: IntoIterator<Item = St>,
1637 St: AsRef<str>,
1638 {
1639 self._scopes
1640 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1641 self
1642 }
1643
1644 /// Removes all scopes, and no default scope will be used either.
1645 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1646 /// for details).
1647 pub fn clear_scopes(mut self) -> TableRowBatchDeleteCall<'a, C> {
1648 self._scopes.clear();
1649 self
1650 }
1651}
1652
1653/// Updates multiple rows.
1654///
1655/// A builder for the *rows.batchUpdate* method supported by a *table* resource.
1656/// It is not used directly, but through a [`TableMethods`] instance.
1657///
1658/// # Example
1659///
1660/// Instantiate a resource method builder
1661///
1662/// ```test_harness,no_run
1663/// # extern crate hyper;
1664/// # extern crate hyper_rustls;
1665/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
1666/// use area120tables1_alpha1::api::BatchUpdateRowsRequest;
1667/// # async fn dox() {
1668/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1669///
1670/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1671/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1672/// # .with_native_roots()
1673/// # .unwrap()
1674/// # .https_only()
1675/// # .enable_http2()
1676/// # .build();
1677///
1678/// # let executor = hyper_util::rt::TokioExecutor::new();
1679/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1680/// # secret,
1681/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1682/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1683/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1684/// # ),
1685/// # ).build().await.unwrap();
1686///
1687/// # let client = hyper_util::client::legacy::Client::builder(
1688/// # hyper_util::rt::TokioExecutor::new()
1689/// # )
1690/// # .build(
1691/// # hyper_rustls::HttpsConnectorBuilder::new()
1692/// # .with_native_roots()
1693/// # .unwrap()
1694/// # .https_or_http()
1695/// # .enable_http2()
1696/// # .build()
1697/// # );
1698/// # let mut hub = Area120Tables::new(client, auth);
1699/// // As the method needs a request, you would usually fill it with the desired information
1700/// // into the respective structure. Some of the parts shown here might not be applicable !
1701/// // Values shown here are possibly random and not representative !
1702/// let mut req = BatchUpdateRowsRequest::default();
1703///
1704/// // You can configure optional parameters by calling the respective setters at will, and
1705/// // execute the final call using `doit()`.
1706/// // Values shown here are possibly random and not representative !
1707/// let result = hub.tables().rows_batch_update(req, "parent")
1708/// .doit().await;
1709/// # }
1710/// ```
1711pub struct TableRowBatchUpdateCall<'a, C>
1712where
1713 C: 'a,
1714{
1715 hub: &'a Area120Tables<C>,
1716 _request: BatchUpdateRowsRequest,
1717 _parent: String,
1718 _delegate: Option<&'a mut dyn common::Delegate>,
1719 _additional_params: HashMap<String, String>,
1720 _scopes: BTreeSet<String>,
1721}
1722
1723impl<'a, C> common::CallBuilder for TableRowBatchUpdateCall<'a, C> {}
1724
1725impl<'a, C> TableRowBatchUpdateCall<'a, C>
1726where
1727 C: common::Connector,
1728{
1729 /// Perform the operation you have build so far.
1730 pub async fn doit(mut self) -> common::Result<(common::Response, BatchUpdateRowsResponse)> {
1731 use std::borrow::Cow;
1732 use std::io::{Read, Seek};
1733
1734 use common::{url::Params, ToParts};
1735 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1736
1737 let mut dd = common::DefaultDelegate;
1738 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1739 dlg.begin(common::MethodInfo {
1740 id: "area120tables.tables.rows.batchUpdate",
1741 http_method: hyper::Method::POST,
1742 });
1743
1744 for &field in ["alt", "parent"].iter() {
1745 if self._additional_params.contains_key(field) {
1746 dlg.finished(false);
1747 return Err(common::Error::FieldClash(field));
1748 }
1749 }
1750
1751 let mut params = Params::with_capacity(4 + self._additional_params.len());
1752 params.push("parent", self._parent);
1753
1754 params.extend(self._additional_params.iter());
1755
1756 params.push("alt", "json");
1757 let mut url = self.hub._base_url.clone() + "v1alpha1/{+parent}/rows:batchUpdate";
1758 if self._scopes.is_empty() {
1759 self._scopes.insert(Scope::Drive.as_ref().to_string());
1760 }
1761
1762 #[allow(clippy::single_element_loop)]
1763 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1764 url = params.uri_replacement(url, param_name, find_this, true);
1765 }
1766 {
1767 let to_remove = ["parent"];
1768 params.remove_params(&to_remove);
1769 }
1770
1771 let url = params.parse_with_url(&url);
1772
1773 let mut json_mime_type = mime::APPLICATION_JSON;
1774 let mut request_value_reader = {
1775 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1776 common::remove_json_null_values(&mut value);
1777 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1778 serde_json::to_writer(&mut dst, &value).unwrap();
1779 dst
1780 };
1781 let request_size = request_value_reader
1782 .seek(std::io::SeekFrom::End(0))
1783 .unwrap();
1784 request_value_reader
1785 .seek(std::io::SeekFrom::Start(0))
1786 .unwrap();
1787
1788 loop {
1789 let token = match self
1790 .hub
1791 .auth
1792 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1793 .await
1794 {
1795 Ok(token) => token,
1796 Err(e) => match dlg.token(e) {
1797 Ok(token) => token,
1798 Err(e) => {
1799 dlg.finished(false);
1800 return Err(common::Error::MissingToken(e));
1801 }
1802 },
1803 };
1804 request_value_reader
1805 .seek(std::io::SeekFrom::Start(0))
1806 .unwrap();
1807 let mut req_result = {
1808 let client = &self.hub.client;
1809 dlg.pre_request();
1810 let mut req_builder = hyper::Request::builder()
1811 .method(hyper::Method::POST)
1812 .uri(url.as_str())
1813 .header(USER_AGENT, self.hub._user_agent.clone());
1814
1815 if let Some(token) = token.as_ref() {
1816 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1817 }
1818
1819 let request = req_builder
1820 .header(CONTENT_TYPE, json_mime_type.to_string())
1821 .header(CONTENT_LENGTH, request_size as u64)
1822 .body(common::to_body(
1823 request_value_reader.get_ref().clone().into(),
1824 ));
1825
1826 client.request(request.unwrap()).await
1827 };
1828
1829 match req_result {
1830 Err(err) => {
1831 if let common::Retry::After(d) = dlg.http_error(&err) {
1832 sleep(d).await;
1833 continue;
1834 }
1835 dlg.finished(false);
1836 return Err(common::Error::HttpError(err));
1837 }
1838 Ok(res) => {
1839 let (mut parts, body) = res.into_parts();
1840 let mut body = common::Body::new(body);
1841 if !parts.status.is_success() {
1842 let bytes = common::to_bytes(body).await.unwrap_or_default();
1843 let error = serde_json::from_str(&common::to_string(&bytes));
1844 let response = common::to_response(parts, bytes.into());
1845
1846 if let common::Retry::After(d) =
1847 dlg.http_failure(&response, error.as_ref().ok())
1848 {
1849 sleep(d).await;
1850 continue;
1851 }
1852
1853 dlg.finished(false);
1854
1855 return Err(match error {
1856 Ok(value) => common::Error::BadRequest(value),
1857 _ => common::Error::Failure(response),
1858 });
1859 }
1860 let response = {
1861 let bytes = common::to_bytes(body).await.unwrap_or_default();
1862 let encoded = common::to_string(&bytes);
1863 match serde_json::from_str(&encoded) {
1864 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1865 Err(error) => {
1866 dlg.response_json_decode_error(&encoded, &error);
1867 return Err(common::Error::JsonDecodeError(
1868 encoded.to_string(),
1869 error,
1870 ));
1871 }
1872 }
1873 };
1874
1875 dlg.finished(true);
1876 return Ok(response);
1877 }
1878 }
1879 }
1880 }
1881
1882 ///
1883 /// Sets the *request* property to the given value.
1884 ///
1885 /// Even though the property as already been set when instantiating this call,
1886 /// we provide this method for API completeness.
1887 pub fn request(mut self, new_value: BatchUpdateRowsRequest) -> TableRowBatchUpdateCall<'a, C> {
1888 self._request = new_value;
1889 self
1890 }
1891 /// Required. The parent table shared by all rows being updated. Format: tables/{table}
1892 ///
1893 /// Sets the *parent* path property to the given value.
1894 ///
1895 /// Even though the property as already been set when instantiating this call,
1896 /// we provide this method for API completeness.
1897 pub fn parent(mut self, new_value: &str) -> TableRowBatchUpdateCall<'a, C> {
1898 self._parent = new_value.to_string();
1899 self
1900 }
1901 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1902 /// while executing the actual API request.
1903 ///
1904 /// ````text
1905 /// It should be used to handle progress information, and to implement a certain level of resilience.
1906 /// ````
1907 ///
1908 /// Sets the *delegate* property to the given value.
1909 pub fn delegate(
1910 mut self,
1911 new_value: &'a mut dyn common::Delegate,
1912 ) -> TableRowBatchUpdateCall<'a, C> {
1913 self._delegate = Some(new_value);
1914 self
1915 }
1916
1917 /// Set any additional parameter of the query string used in the request.
1918 /// It should be used to set parameters which are not yet available through their own
1919 /// setters.
1920 ///
1921 /// Please note that this method must not be used to set any of the known parameters
1922 /// which have their own setter method. If done anyway, the request will fail.
1923 ///
1924 /// # Additional Parameters
1925 ///
1926 /// * *$.xgafv* (query-string) - V1 error format.
1927 /// * *access_token* (query-string) - OAuth access token.
1928 /// * *alt* (query-string) - Data format for response.
1929 /// * *callback* (query-string) - JSONP
1930 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1931 /// * *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.
1932 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1933 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1934 /// * *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.
1935 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1936 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1937 pub fn param<T>(mut self, name: T, value: T) -> TableRowBatchUpdateCall<'a, C>
1938 where
1939 T: AsRef<str>,
1940 {
1941 self._additional_params
1942 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1943 self
1944 }
1945
1946 /// Identifies the authorization scope for the method you are building.
1947 ///
1948 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1949 /// [`Scope::Drive`].
1950 ///
1951 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1952 /// tokens for more than one scope.
1953 ///
1954 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1955 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1956 /// sufficient, a read-write scope will do as well.
1957 pub fn add_scope<St>(mut self, scope: St) -> TableRowBatchUpdateCall<'a, C>
1958 where
1959 St: AsRef<str>,
1960 {
1961 self._scopes.insert(String::from(scope.as_ref()));
1962 self
1963 }
1964 /// Identifies the authorization scope(s) for the method you are building.
1965 ///
1966 /// See [`Self::add_scope()`] for details.
1967 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowBatchUpdateCall<'a, C>
1968 where
1969 I: IntoIterator<Item = St>,
1970 St: AsRef<str>,
1971 {
1972 self._scopes
1973 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1974 self
1975 }
1976
1977 /// Removes all scopes, and no default scope will be used either.
1978 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1979 /// for details).
1980 pub fn clear_scopes(mut self) -> TableRowBatchUpdateCall<'a, C> {
1981 self._scopes.clear();
1982 self
1983 }
1984}
1985
1986/// Creates a row.
1987///
1988/// A builder for the *rows.create* method supported by a *table* resource.
1989/// It is not used directly, but through a [`TableMethods`] instance.
1990///
1991/// # Example
1992///
1993/// Instantiate a resource method builder
1994///
1995/// ```test_harness,no_run
1996/// # extern crate hyper;
1997/// # extern crate hyper_rustls;
1998/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
1999/// use area120tables1_alpha1::api::Row;
2000/// # async fn dox() {
2001/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2002///
2003/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2004/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2005/// # .with_native_roots()
2006/// # .unwrap()
2007/// # .https_only()
2008/// # .enable_http2()
2009/// # .build();
2010///
2011/// # let executor = hyper_util::rt::TokioExecutor::new();
2012/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2013/// # secret,
2014/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2015/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2016/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2017/// # ),
2018/// # ).build().await.unwrap();
2019///
2020/// # let client = hyper_util::client::legacy::Client::builder(
2021/// # hyper_util::rt::TokioExecutor::new()
2022/// # )
2023/// # .build(
2024/// # hyper_rustls::HttpsConnectorBuilder::new()
2025/// # .with_native_roots()
2026/// # .unwrap()
2027/// # .https_or_http()
2028/// # .enable_http2()
2029/// # .build()
2030/// # );
2031/// # let mut hub = Area120Tables::new(client, auth);
2032/// // As the method needs a request, you would usually fill it with the desired information
2033/// // into the respective structure. Some of the parts shown here might not be applicable !
2034/// // Values shown here are possibly random and not representative !
2035/// let mut req = Row::default();
2036///
2037/// // You can configure optional parameters by calling the respective setters at will, and
2038/// // execute the final call using `doit()`.
2039/// // Values shown here are possibly random and not representative !
2040/// let result = hub.tables().rows_create(req, "parent")
2041/// .view("duo")
2042/// .doit().await;
2043/// # }
2044/// ```
2045pub struct TableRowCreateCall<'a, C>
2046where
2047 C: 'a,
2048{
2049 hub: &'a Area120Tables<C>,
2050 _request: Row,
2051 _parent: String,
2052 _view: Option<String>,
2053 _delegate: Option<&'a mut dyn common::Delegate>,
2054 _additional_params: HashMap<String, String>,
2055 _scopes: BTreeSet<String>,
2056}
2057
2058impl<'a, C> common::CallBuilder for TableRowCreateCall<'a, C> {}
2059
2060impl<'a, C> TableRowCreateCall<'a, C>
2061where
2062 C: common::Connector,
2063{
2064 /// Perform the operation you have build so far.
2065 pub async fn doit(mut self) -> common::Result<(common::Response, Row)> {
2066 use std::borrow::Cow;
2067 use std::io::{Read, Seek};
2068
2069 use common::{url::Params, ToParts};
2070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2071
2072 let mut dd = common::DefaultDelegate;
2073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2074 dlg.begin(common::MethodInfo {
2075 id: "area120tables.tables.rows.create",
2076 http_method: hyper::Method::POST,
2077 });
2078
2079 for &field in ["alt", "parent", "view"].iter() {
2080 if self._additional_params.contains_key(field) {
2081 dlg.finished(false);
2082 return Err(common::Error::FieldClash(field));
2083 }
2084 }
2085
2086 let mut params = Params::with_capacity(5 + self._additional_params.len());
2087 params.push("parent", self._parent);
2088 if let Some(value) = self._view.as_ref() {
2089 params.push("view", value);
2090 }
2091
2092 params.extend(self._additional_params.iter());
2093
2094 params.push("alt", "json");
2095 let mut url = self.hub._base_url.clone() + "v1alpha1/{+parent}/rows";
2096 if self._scopes.is_empty() {
2097 self._scopes.insert(Scope::Drive.as_ref().to_string());
2098 }
2099
2100 #[allow(clippy::single_element_loop)]
2101 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2102 url = params.uri_replacement(url, param_name, find_this, true);
2103 }
2104 {
2105 let to_remove = ["parent"];
2106 params.remove_params(&to_remove);
2107 }
2108
2109 let url = params.parse_with_url(&url);
2110
2111 let mut json_mime_type = mime::APPLICATION_JSON;
2112 let mut request_value_reader = {
2113 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2114 common::remove_json_null_values(&mut value);
2115 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2116 serde_json::to_writer(&mut dst, &value).unwrap();
2117 dst
2118 };
2119 let request_size = request_value_reader
2120 .seek(std::io::SeekFrom::End(0))
2121 .unwrap();
2122 request_value_reader
2123 .seek(std::io::SeekFrom::Start(0))
2124 .unwrap();
2125
2126 loop {
2127 let token = match self
2128 .hub
2129 .auth
2130 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2131 .await
2132 {
2133 Ok(token) => token,
2134 Err(e) => match dlg.token(e) {
2135 Ok(token) => token,
2136 Err(e) => {
2137 dlg.finished(false);
2138 return Err(common::Error::MissingToken(e));
2139 }
2140 },
2141 };
2142 request_value_reader
2143 .seek(std::io::SeekFrom::Start(0))
2144 .unwrap();
2145 let mut req_result = {
2146 let client = &self.hub.client;
2147 dlg.pre_request();
2148 let mut req_builder = hyper::Request::builder()
2149 .method(hyper::Method::POST)
2150 .uri(url.as_str())
2151 .header(USER_AGENT, self.hub._user_agent.clone());
2152
2153 if let Some(token) = token.as_ref() {
2154 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2155 }
2156
2157 let request = req_builder
2158 .header(CONTENT_TYPE, json_mime_type.to_string())
2159 .header(CONTENT_LENGTH, request_size as u64)
2160 .body(common::to_body(
2161 request_value_reader.get_ref().clone().into(),
2162 ));
2163
2164 client.request(request.unwrap()).await
2165 };
2166
2167 match req_result {
2168 Err(err) => {
2169 if let common::Retry::After(d) = dlg.http_error(&err) {
2170 sleep(d).await;
2171 continue;
2172 }
2173 dlg.finished(false);
2174 return Err(common::Error::HttpError(err));
2175 }
2176 Ok(res) => {
2177 let (mut parts, body) = res.into_parts();
2178 let mut body = common::Body::new(body);
2179 if !parts.status.is_success() {
2180 let bytes = common::to_bytes(body).await.unwrap_or_default();
2181 let error = serde_json::from_str(&common::to_string(&bytes));
2182 let response = common::to_response(parts, bytes.into());
2183
2184 if let common::Retry::After(d) =
2185 dlg.http_failure(&response, error.as_ref().ok())
2186 {
2187 sleep(d).await;
2188 continue;
2189 }
2190
2191 dlg.finished(false);
2192
2193 return Err(match error {
2194 Ok(value) => common::Error::BadRequest(value),
2195 _ => common::Error::Failure(response),
2196 });
2197 }
2198 let response = {
2199 let bytes = common::to_bytes(body).await.unwrap_or_default();
2200 let encoded = common::to_string(&bytes);
2201 match serde_json::from_str(&encoded) {
2202 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2203 Err(error) => {
2204 dlg.response_json_decode_error(&encoded, &error);
2205 return Err(common::Error::JsonDecodeError(
2206 encoded.to_string(),
2207 error,
2208 ));
2209 }
2210 }
2211 };
2212
2213 dlg.finished(true);
2214 return Ok(response);
2215 }
2216 }
2217 }
2218 }
2219
2220 ///
2221 /// Sets the *request* property to the given value.
2222 ///
2223 /// Even though the property as already been set when instantiating this call,
2224 /// we provide this method for API completeness.
2225 pub fn request(mut self, new_value: Row) -> TableRowCreateCall<'a, C> {
2226 self._request = new_value;
2227 self
2228 }
2229 /// Required. The parent table where this row will be created. Format: tables/{table}
2230 ///
2231 /// Sets the *parent* path property to the given value.
2232 ///
2233 /// Even though the property as already been set when instantiating this call,
2234 /// we provide this method for API completeness.
2235 pub fn parent(mut self, new_value: &str) -> TableRowCreateCall<'a, C> {
2236 self._parent = new_value.to_string();
2237 self
2238 }
2239 /// Optional. Column key to use for values in the row. Defaults to user entered name.
2240 ///
2241 /// Sets the *view* query property to the given value.
2242 pub fn view(mut self, new_value: &str) -> TableRowCreateCall<'a, C> {
2243 self._view = Some(new_value.to_string());
2244 self
2245 }
2246 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2247 /// while executing the actual API request.
2248 ///
2249 /// ````text
2250 /// It should be used to handle progress information, and to implement a certain level of resilience.
2251 /// ````
2252 ///
2253 /// Sets the *delegate* property to the given value.
2254 pub fn delegate(
2255 mut self,
2256 new_value: &'a mut dyn common::Delegate,
2257 ) -> TableRowCreateCall<'a, C> {
2258 self._delegate = Some(new_value);
2259 self
2260 }
2261
2262 /// Set any additional parameter of the query string used in the request.
2263 /// It should be used to set parameters which are not yet available through their own
2264 /// setters.
2265 ///
2266 /// Please note that this method must not be used to set any of the known parameters
2267 /// which have their own setter method. If done anyway, the request will fail.
2268 ///
2269 /// # Additional Parameters
2270 ///
2271 /// * *$.xgafv* (query-string) - V1 error format.
2272 /// * *access_token* (query-string) - OAuth access token.
2273 /// * *alt* (query-string) - Data format for response.
2274 /// * *callback* (query-string) - JSONP
2275 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2276 /// * *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.
2277 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2278 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2279 /// * *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.
2280 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2281 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2282 pub fn param<T>(mut self, name: T, value: T) -> TableRowCreateCall<'a, C>
2283 where
2284 T: AsRef<str>,
2285 {
2286 self._additional_params
2287 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2288 self
2289 }
2290
2291 /// Identifies the authorization scope for the method you are building.
2292 ///
2293 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2294 /// [`Scope::Drive`].
2295 ///
2296 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2297 /// tokens for more than one scope.
2298 ///
2299 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2300 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2301 /// sufficient, a read-write scope will do as well.
2302 pub fn add_scope<St>(mut self, scope: St) -> TableRowCreateCall<'a, C>
2303 where
2304 St: AsRef<str>,
2305 {
2306 self._scopes.insert(String::from(scope.as_ref()));
2307 self
2308 }
2309 /// Identifies the authorization scope(s) for the method you are building.
2310 ///
2311 /// See [`Self::add_scope()`] for details.
2312 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowCreateCall<'a, C>
2313 where
2314 I: IntoIterator<Item = St>,
2315 St: AsRef<str>,
2316 {
2317 self._scopes
2318 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2319 self
2320 }
2321
2322 /// Removes all scopes, and no default scope will be used either.
2323 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2324 /// for details).
2325 pub fn clear_scopes(mut self) -> TableRowCreateCall<'a, C> {
2326 self._scopes.clear();
2327 self
2328 }
2329}
2330
2331/// Deletes a row.
2332///
2333/// A builder for the *rows.delete* method supported by a *table* resource.
2334/// It is not used directly, but through a [`TableMethods`] instance.
2335///
2336/// # Example
2337///
2338/// Instantiate a resource method builder
2339///
2340/// ```test_harness,no_run
2341/// # extern crate hyper;
2342/// # extern crate hyper_rustls;
2343/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
2344/// # async fn dox() {
2345/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2346///
2347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2349/// # .with_native_roots()
2350/// # .unwrap()
2351/// # .https_only()
2352/// # .enable_http2()
2353/// # .build();
2354///
2355/// # let executor = hyper_util::rt::TokioExecutor::new();
2356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2357/// # secret,
2358/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2359/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2360/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2361/// # ),
2362/// # ).build().await.unwrap();
2363///
2364/// # let client = hyper_util::client::legacy::Client::builder(
2365/// # hyper_util::rt::TokioExecutor::new()
2366/// # )
2367/// # .build(
2368/// # hyper_rustls::HttpsConnectorBuilder::new()
2369/// # .with_native_roots()
2370/// # .unwrap()
2371/// # .https_or_http()
2372/// # .enable_http2()
2373/// # .build()
2374/// # );
2375/// # let mut hub = Area120Tables::new(client, auth);
2376/// // You can configure optional parameters by calling the respective setters at will, and
2377/// // execute the final call using `doit()`.
2378/// // Values shown here are possibly random and not representative !
2379/// let result = hub.tables().rows_delete("name")
2380/// .doit().await;
2381/// # }
2382/// ```
2383pub struct TableRowDeleteCall<'a, C>
2384where
2385 C: 'a,
2386{
2387 hub: &'a Area120Tables<C>,
2388 _name: String,
2389 _delegate: Option<&'a mut dyn common::Delegate>,
2390 _additional_params: HashMap<String, String>,
2391 _scopes: BTreeSet<String>,
2392}
2393
2394impl<'a, C> common::CallBuilder for TableRowDeleteCall<'a, C> {}
2395
2396impl<'a, C> TableRowDeleteCall<'a, C>
2397where
2398 C: common::Connector,
2399{
2400 /// Perform the operation you have build so far.
2401 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2402 use std::borrow::Cow;
2403 use std::io::{Read, Seek};
2404
2405 use common::{url::Params, ToParts};
2406 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2407
2408 let mut dd = common::DefaultDelegate;
2409 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2410 dlg.begin(common::MethodInfo {
2411 id: "area120tables.tables.rows.delete",
2412 http_method: hyper::Method::DELETE,
2413 });
2414
2415 for &field in ["alt", "name"].iter() {
2416 if self._additional_params.contains_key(field) {
2417 dlg.finished(false);
2418 return Err(common::Error::FieldClash(field));
2419 }
2420 }
2421
2422 let mut params = Params::with_capacity(3 + self._additional_params.len());
2423 params.push("name", self._name);
2424
2425 params.extend(self._additional_params.iter());
2426
2427 params.push("alt", "json");
2428 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
2429 if self._scopes.is_empty() {
2430 self._scopes.insert(Scope::Drive.as_ref().to_string());
2431 }
2432
2433 #[allow(clippy::single_element_loop)]
2434 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2435 url = params.uri_replacement(url, param_name, find_this, true);
2436 }
2437 {
2438 let to_remove = ["name"];
2439 params.remove_params(&to_remove);
2440 }
2441
2442 let url = params.parse_with_url(&url);
2443
2444 loop {
2445 let token = match self
2446 .hub
2447 .auth
2448 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2449 .await
2450 {
2451 Ok(token) => token,
2452 Err(e) => match dlg.token(e) {
2453 Ok(token) => token,
2454 Err(e) => {
2455 dlg.finished(false);
2456 return Err(common::Error::MissingToken(e));
2457 }
2458 },
2459 };
2460 let mut req_result = {
2461 let client = &self.hub.client;
2462 dlg.pre_request();
2463 let mut req_builder = hyper::Request::builder()
2464 .method(hyper::Method::DELETE)
2465 .uri(url.as_str())
2466 .header(USER_AGENT, self.hub._user_agent.clone());
2467
2468 if let Some(token) = token.as_ref() {
2469 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2470 }
2471
2472 let request = req_builder
2473 .header(CONTENT_LENGTH, 0_u64)
2474 .body(common::to_body::<String>(None));
2475
2476 client.request(request.unwrap()).await
2477 };
2478
2479 match req_result {
2480 Err(err) => {
2481 if let common::Retry::After(d) = dlg.http_error(&err) {
2482 sleep(d).await;
2483 continue;
2484 }
2485 dlg.finished(false);
2486 return Err(common::Error::HttpError(err));
2487 }
2488 Ok(res) => {
2489 let (mut parts, body) = res.into_parts();
2490 let mut body = common::Body::new(body);
2491 if !parts.status.is_success() {
2492 let bytes = common::to_bytes(body).await.unwrap_or_default();
2493 let error = serde_json::from_str(&common::to_string(&bytes));
2494 let response = common::to_response(parts, bytes.into());
2495
2496 if let common::Retry::After(d) =
2497 dlg.http_failure(&response, error.as_ref().ok())
2498 {
2499 sleep(d).await;
2500 continue;
2501 }
2502
2503 dlg.finished(false);
2504
2505 return Err(match error {
2506 Ok(value) => common::Error::BadRequest(value),
2507 _ => common::Error::Failure(response),
2508 });
2509 }
2510 let response = {
2511 let bytes = common::to_bytes(body).await.unwrap_or_default();
2512 let encoded = common::to_string(&bytes);
2513 match serde_json::from_str(&encoded) {
2514 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2515 Err(error) => {
2516 dlg.response_json_decode_error(&encoded, &error);
2517 return Err(common::Error::JsonDecodeError(
2518 encoded.to_string(),
2519 error,
2520 ));
2521 }
2522 }
2523 };
2524
2525 dlg.finished(true);
2526 return Ok(response);
2527 }
2528 }
2529 }
2530 }
2531
2532 /// Required. The name of the row to delete. Format: tables/{table}/rows/{row}
2533 ///
2534 /// Sets the *name* path property to the given value.
2535 ///
2536 /// Even though the property as already been set when instantiating this call,
2537 /// we provide this method for API completeness.
2538 pub fn name(mut self, new_value: &str) -> TableRowDeleteCall<'a, C> {
2539 self._name = new_value.to_string();
2540 self
2541 }
2542 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2543 /// while executing the actual API request.
2544 ///
2545 /// ````text
2546 /// It should be used to handle progress information, and to implement a certain level of resilience.
2547 /// ````
2548 ///
2549 /// Sets the *delegate* property to the given value.
2550 pub fn delegate(
2551 mut self,
2552 new_value: &'a mut dyn common::Delegate,
2553 ) -> TableRowDeleteCall<'a, C> {
2554 self._delegate = Some(new_value);
2555 self
2556 }
2557
2558 /// Set any additional parameter of the query string used in the request.
2559 /// It should be used to set parameters which are not yet available through their own
2560 /// setters.
2561 ///
2562 /// Please note that this method must not be used to set any of the known parameters
2563 /// which have their own setter method. If done anyway, the request will fail.
2564 ///
2565 /// # Additional Parameters
2566 ///
2567 /// * *$.xgafv* (query-string) - V1 error format.
2568 /// * *access_token* (query-string) - OAuth access token.
2569 /// * *alt* (query-string) - Data format for response.
2570 /// * *callback* (query-string) - JSONP
2571 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2572 /// * *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.
2573 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2574 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2575 /// * *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.
2576 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2577 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2578 pub fn param<T>(mut self, name: T, value: T) -> TableRowDeleteCall<'a, C>
2579 where
2580 T: AsRef<str>,
2581 {
2582 self._additional_params
2583 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2584 self
2585 }
2586
2587 /// Identifies the authorization scope for the method you are building.
2588 ///
2589 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2590 /// [`Scope::Drive`].
2591 ///
2592 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2593 /// tokens for more than one scope.
2594 ///
2595 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2596 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2597 /// sufficient, a read-write scope will do as well.
2598 pub fn add_scope<St>(mut self, scope: St) -> TableRowDeleteCall<'a, C>
2599 where
2600 St: AsRef<str>,
2601 {
2602 self._scopes.insert(String::from(scope.as_ref()));
2603 self
2604 }
2605 /// Identifies the authorization scope(s) for the method you are building.
2606 ///
2607 /// See [`Self::add_scope()`] for details.
2608 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowDeleteCall<'a, C>
2609 where
2610 I: IntoIterator<Item = St>,
2611 St: AsRef<str>,
2612 {
2613 self._scopes
2614 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2615 self
2616 }
2617
2618 /// Removes all scopes, and no default scope will be used either.
2619 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2620 /// for details).
2621 pub fn clear_scopes(mut self) -> TableRowDeleteCall<'a, C> {
2622 self._scopes.clear();
2623 self
2624 }
2625}
2626
2627/// Gets a row. Returns NOT_FOUND if the row does not exist in the table.
2628///
2629/// A builder for the *rows.get* method supported by a *table* resource.
2630/// It is not used directly, but through a [`TableMethods`] instance.
2631///
2632/// # Example
2633///
2634/// Instantiate a resource method builder
2635///
2636/// ```test_harness,no_run
2637/// # extern crate hyper;
2638/// # extern crate hyper_rustls;
2639/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
2640/// # async fn dox() {
2641/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2642///
2643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2644/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2645/// # .with_native_roots()
2646/// # .unwrap()
2647/// # .https_only()
2648/// # .enable_http2()
2649/// # .build();
2650///
2651/// # let executor = hyper_util::rt::TokioExecutor::new();
2652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2653/// # secret,
2654/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2655/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2656/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2657/// # ),
2658/// # ).build().await.unwrap();
2659///
2660/// # let client = hyper_util::client::legacy::Client::builder(
2661/// # hyper_util::rt::TokioExecutor::new()
2662/// # )
2663/// # .build(
2664/// # hyper_rustls::HttpsConnectorBuilder::new()
2665/// # .with_native_roots()
2666/// # .unwrap()
2667/// # .https_or_http()
2668/// # .enable_http2()
2669/// # .build()
2670/// # );
2671/// # let mut hub = Area120Tables::new(client, auth);
2672/// // You can configure optional parameters by calling the respective setters at will, and
2673/// // execute the final call using `doit()`.
2674/// // Values shown here are possibly random and not representative !
2675/// let result = hub.tables().rows_get("name")
2676/// .view("ut")
2677/// .doit().await;
2678/// # }
2679/// ```
2680pub struct TableRowGetCall<'a, C>
2681where
2682 C: 'a,
2683{
2684 hub: &'a Area120Tables<C>,
2685 _name: String,
2686 _view: Option<String>,
2687 _delegate: Option<&'a mut dyn common::Delegate>,
2688 _additional_params: HashMap<String, String>,
2689 _scopes: BTreeSet<String>,
2690}
2691
2692impl<'a, C> common::CallBuilder for TableRowGetCall<'a, C> {}
2693
2694impl<'a, C> TableRowGetCall<'a, C>
2695where
2696 C: common::Connector,
2697{
2698 /// Perform the operation you have build so far.
2699 pub async fn doit(mut self) -> common::Result<(common::Response, Row)> {
2700 use std::borrow::Cow;
2701 use std::io::{Read, Seek};
2702
2703 use common::{url::Params, ToParts};
2704 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2705
2706 let mut dd = common::DefaultDelegate;
2707 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2708 dlg.begin(common::MethodInfo {
2709 id: "area120tables.tables.rows.get",
2710 http_method: hyper::Method::GET,
2711 });
2712
2713 for &field in ["alt", "name", "view"].iter() {
2714 if self._additional_params.contains_key(field) {
2715 dlg.finished(false);
2716 return Err(common::Error::FieldClash(field));
2717 }
2718 }
2719
2720 let mut params = Params::with_capacity(4 + self._additional_params.len());
2721 params.push("name", self._name);
2722 if let Some(value) = self._view.as_ref() {
2723 params.push("view", value);
2724 }
2725
2726 params.extend(self._additional_params.iter());
2727
2728 params.push("alt", "json");
2729 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
2730 if self._scopes.is_empty() {
2731 self._scopes
2732 .insert(Scope::DriveReadonly.as_ref().to_string());
2733 }
2734
2735 #[allow(clippy::single_element_loop)]
2736 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2737 url = params.uri_replacement(url, param_name, find_this, true);
2738 }
2739 {
2740 let to_remove = ["name"];
2741 params.remove_params(&to_remove);
2742 }
2743
2744 let url = params.parse_with_url(&url);
2745
2746 loop {
2747 let token = match self
2748 .hub
2749 .auth
2750 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2751 .await
2752 {
2753 Ok(token) => token,
2754 Err(e) => match dlg.token(e) {
2755 Ok(token) => token,
2756 Err(e) => {
2757 dlg.finished(false);
2758 return Err(common::Error::MissingToken(e));
2759 }
2760 },
2761 };
2762 let mut req_result = {
2763 let client = &self.hub.client;
2764 dlg.pre_request();
2765 let mut req_builder = hyper::Request::builder()
2766 .method(hyper::Method::GET)
2767 .uri(url.as_str())
2768 .header(USER_AGENT, self.hub._user_agent.clone());
2769
2770 if let Some(token) = token.as_ref() {
2771 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2772 }
2773
2774 let request = req_builder
2775 .header(CONTENT_LENGTH, 0_u64)
2776 .body(common::to_body::<String>(None));
2777
2778 client.request(request.unwrap()).await
2779 };
2780
2781 match req_result {
2782 Err(err) => {
2783 if let common::Retry::After(d) = dlg.http_error(&err) {
2784 sleep(d).await;
2785 continue;
2786 }
2787 dlg.finished(false);
2788 return Err(common::Error::HttpError(err));
2789 }
2790 Ok(res) => {
2791 let (mut parts, body) = res.into_parts();
2792 let mut body = common::Body::new(body);
2793 if !parts.status.is_success() {
2794 let bytes = common::to_bytes(body).await.unwrap_or_default();
2795 let error = serde_json::from_str(&common::to_string(&bytes));
2796 let response = common::to_response(parts, bytes.into());
2797
2798 if let common::Retry::After(d) =
2799 dlg.http_failure(&response, error.as_ref().ok())
2800 {
2801 sleep(d).await;
2802 continue;
2803 }
2804
2805 dlg.finished(false);
2806
2807 return Err(match error {
2808 Ok(value) => common::Error::BadRequest(value),
2809 _ => common::Error::Failure(response),
2810 });
2811 }
2812 let response = {
2813 let bytes = common::to_bytes(body).await.unwrap_or_default();
2814 let encoded = common::to_string(&bytes);
2815 match serde_json::from_str(&encoded) {
2816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2817 Err(error) => {
2818 dlg.response_json_decode_error(&encoded, &error);
2819 return Err(common::Error::JsonDecodeError(
2820 encoded.to_string(),
2821 error,
2822 ));
2823 }
2824 }
2825 };
2826
2827 dlg.finished(true);
2828 return Ok(response);
2829 }
2830 }
2831 }
2832 }
2833
2834 /// Required. The name of the row to retrieve. Format: tables/{table}/rows/{row}
2835 ///
2836 /// Sets the *name* path property to the given value.
2837 ///
2838 /// Even though the property as already been set when instantiating this call,
2839 /// we provide this method for API completeness.
2840 pub fn name(mut self, new_value: &str) -> TableRowGetCall<'a, C> {
2841 self._name = new_value.to_string();
2842 self
2843 }
2844 /// Optional. Column key to use for values in the row. Defaults to user entered name.
2845 ///
2846 /// Sets the *view* query property to the given value.
2847 pub fn view(mut self, new_value: &str) -> TableRowGetCall<'a, C> {
2848 self._view = Some(new_value.to_string());
2849 self
2850 }
2851 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2852 /// while executing the actual API request.
2853 ///
2854 /// ````text
2855 /// It should be used to handle progress information, and to implement a certain level of resilience.
2856 /// ````
2857 ///
2858 /// Sets the *delegate* property to the given value.
2859 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TableRowGetCall<'a, C> {
2860 self._delegate = Some(new_value);
2861 self
2862 }
2863
2864 /// Set any additional parameter of the query string used in the request.
2865 /// It should be used to set parameters which are not yet available through their own
2866 /// setters.
2867 ///
2868 /// Please note that this method must not be used to set any of the known parameters
2869 /// which have their own setter method. If done anyway, the request will fail.
2870 ///
2871 /// # Additional Parameters
2872 ///
2873 /// * *$.xgafv* (query-string) - V1 error format.
2874 /// * *access_token* (query-string) - OAuth access token.
2875 /// * *alt* (query-string) - Data format for response.
2876 /// * *callback* (query-string) - JSONP
2877 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2878 /// * *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.
2879 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2880 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2881 /// * *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.
2882 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2883 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2884 pub fn param<T>(mut self, name: T, value: T) -> TableRowGetCall<'a, C>
2885 where
2886 T: AsRef<str>,
2887 {
2888 self._additional_params
2889 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2890 self
2891 }
2892
2893 /// Identifies the authorization scope for the method you are building.
2894 ///
2895 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2896 /// [`Scope::DriveReadonly`].
2897 ///
2898 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2899 /// tokens for more than one scope.
2900 ///
2901 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2902 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2903 /// sufficient, a read-write scope will do as well.
2904 pub fn add_scope<St>(mut self, scope: St) -> TableRowGetCall<'a, C>
2905 where
2906 St: AsRef<str>,
2907 {
2908 self._scopes.insert(String::from(scope.as_ref()));
2909 self
2910 }
2911 /// Identifies the authorization scope(s) for the method you are building.
2912 ///
2913 /// See [`Self::add_scope()`] for details.
2914 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowGetCall<'a, C>
2915 where
2916 I: IntoIterator<Item = St>,
2917 St: AsRef<str>,
2918 {
2919 self._scopes
2920 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2921 self
2922 }
2923
2924 /// Removes all scopes, and no default scope will be used either.
2925 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2926 /// for details).
2927 pub fn clear_scopes(mut self) -> TableRowGetCall<'a, C> {
2928 self._scopes.clear();
2929 self
2930 }
2931}
2932
2933/// Lists rows in a table. Returns NOT_FOUND if the table does not exist.
2934///
2935/// A builder for the *rows.list* method supported by a *table* resource.
2936/// It is not used directly, but through a [`TableMethods`] instance.
2937///
2938/// # Example
2939///
2940/// Instantiate a resource method builder
2941///
2942/// ```test_harness,no_run
2943/// # extern crate hyper;
2944/// # extern crate hyper_rustls;
2945/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
2946/// # async fn dox() {
2947/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2948///
2949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2951/// # .with_native_roots()
2952/// # .unwrap()
2953/// # .https_only()
2954/// # .enable_http2()
2955/// # .build();
2956///
2957/// # let executor = hyper_util::rt::TokioExecutor::new();
2958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2959/// # secret,
2960/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2961/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2962/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2963/// # ),
2964/// # ).build().await.unwrap();
2965///
2966/// # let client = hyper_util::client::legacy::Client::builder(
2967/// # hyper_util::rt::TokioExecutor::new()
2968/// # )
2969/// # .build(
2970/// # hyper_rustls::HttpsConnectorBuilder::new()
2971/// # .with_native_roots()
2972/// # .unwrap()
2973/// # .https_or_http()
2974/// # .enable_http2()
2975/// # .build()
2976/// # );
2977/// # let mut hub = Area120Tables::new(client, auth);
2978/// // You can configure optional parameters by calling the respective setters at will, and
2979/// // execute the final call using `doit()`.
2980/// // Values shown here are possibly random and not representative !
2981/// let result = hub.tables().rows_list("parent")
2982/// .view("rebum.")
2983/// .page_token("est")
2984/// .page_size(-50)
2985/// .order_by("ipsum")
2986/// .filter("est")
2987/// .doit().await;
2988/// # }
2989/// ```
2990pub struct TableRowListCall<'a, C>
2991where
2992 C: 'a,
2993{
2994 hub: &'a Area120Tables<C>,
2995 _parent: String,
2996 _view: Option<String>,
2997 _page_token: Option<String>,
2998 _page_size: Option<i32>,
2999 _order_by: Option<String>,
3000 _filter: Option<String>,
3001 _delegate: Option<&'a mut dyn common::Delegate>,
3002 _additional_params: HashMap<String, String>,
3003 _scopes: BTreeSet<String>,
3004}
3005
3006impl<'a, C> common::CallBuilder for TableRowListCall<'a, C> {}
3007
3008impl<'a, C> TableRowListCall<'a, C>
3009where
3010 C: common::Connector,
3011{
3012 /// Perform the operation you have build so far.
3013 pub async fn doit(mut self) -> common::Result<(common::Response, ListRowsResponse)> {
3014 use std::borrow::Cow;
3015 use std::io::{Read, Seek};
3016
3017 use common::{url::Params, ToParts};
3018 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3019
3020 let mut dd = common::DefaultDelegate;
3021 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3022 dlg.begin(common::MethodInfo {
3023 id: "area120tables.tables.rows.list",
3024 http_method: hyper::Method::GET,
3025 });
3026
3027 for &field in [
3028 "alt",
3029 "parent",
3030 "view",
3031 "pageToken",
3032 "pageSize",
3033 "orderBy",
3034 "filter",
3035 ]
3036 .iter()
3037 {
3038 if self._additional_params.contains_key(field) {
3039 dlg.finished(false);
3040 return Err(common::Error::FieldClash(field));
3041 }
3042 }
3043
3044 let mut params = Params::with_capacity(8 + self._additional_params.len());
3045 params.push("parent", self._parent);
3046 if let Some(value) = self._view.as_ref() {
3047 params.push("view", value);
3048 }
3049 if let Some(value) = self._page_token.as_ref() {
3050 params.push("pageToken", value);
3051 }
3052 if let Some(value) = self._page_size.as_ref() {
3053 params.push("pageSize", value.to_string());
3054 }
3055 if let Some(value) = self._order_by.as_ref() {
3056 params.push("orderBy", value);
3057 }
3058 if let Some(value) = self._filter.as_ref() {
3059 params.push("filter", value);
3060 }
3061
3062 params.extend(self._additional_params.iter());
3063
3064 params.push("alt", "json");
3065 let mut url = self.hub._base_url.clone() + "v1alpha1/{+parent}/rows";
3066 if self._scopes.is_empty() {
3067 self._scopes
3068 .insert(Scope::DriveReadonly.as_ref().to_string());
3069 }
3070
3071 #[allow(clippy::single_element_loop)]
3072 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3073 url = params.uri_replacement(url, param_name, find_this, true);
3074 }
3075 {
3076 let to_remove = ["parent"];
3077 params.remove_params(&to_remove);
3078 }
3079
3080 let url = params.parse_with_url(&url);
3081
3082 loop {
3083 let token = match self
3084 .hub
3085 .auth
3086 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3087 .await
3088 {
3089 Ok(token) => token,
3090 Err(e) => match dlg.token(e) {
3091 Ok(token) => token,
3092 Err(e) => {
3093 dlg.finished(false);
3094 return Err(common::Error::MissingToken(e));
3095 }
3096 },
3097 };
3098 let mut req_result = {
3099 let client = &self.hub.client;
3100 dlg.pre_request();
3101 let mut req_builder = hyper::Request::builder()
3102 .method(hyper::Method::GET)
3103 .uri(url.as_str())
3104 .header(USER_AGENT, self.hub._user_agent.clone());
3105
3106 if let Some(token) = token.as_ref() {
3107 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3108 }
3109
3110 let request = req_builder
3111 .header(CONTENT_LENGTH, 0_u64)
3112 .body(common::to_body::<String>(None));
3113
3114 client.request(request.unwrap()).await
3115 };
3116
3117 match req_result {
3118 Err(err) => {
3119 if let common::Retry::After(d) = dlg.http_error(&err) {
3120 sleep(d).await;
3121 continue;
3122 }
3123 dlg.finished(false);
3124 return Err(common::Error::HttpError(err));
3125 }
3126 Ok(res) => {
3127 let (mut parts, body) = res.into_parts();
3128 let mut body = common::Body::new(body);
3129 if !parts.status.is_success() {
3130 let bytes = common::to_bytes(body).await.unwrap_or_default();
3131 let error = serde_json::from_str(&common::to_string(&bytes));
3132 let response = common::to_response(parts, bytes.into());
3133
3134 if let common::Retry::After(d) =
3135 dlg.http_failure(&response, error.as_ref().ok())
3136 {
3137 sleep(d).await;
3138 continue;
3139 }
3140
3141 dlg.finished(false);
3142
3143 return Err(match error {
3144 Ok(value) => common::Error::BadRequest(value),
3145 _ => common::Error::Failure(response),
3146 });
3147 }
3148 let response = {
3149 let bytes = common::to_bytes(body).await.unwrap_or_default();
3150 let encoded = common::to_string(&bytes);
3151 match serde_json::from_str(&encoded) {
3152 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3153 Err(error) => {
3154 dlg.response_json_decode_error(&encoded, &error);
3155 return Err(common::Error::JsonDecodeError(
3156 encoded.to_string(),
3157 error,
3158 ));
3159 }
3160 }
3161 };
3162
3163 dlg.finished(true);
3164 return Ok(response);
3165 }
3166 }
3167 }
3168 }
3169
3170 /// Required. The parent table. Format: tables/{table}
3171 ///
3172 /// Sets the *parent* path property to the given value.
3173 ///
3174 /// Even though the property as already been set when instantiating this call,
3175 /// we provide this method for API completeness.
3176 pub fn parent(mut self, new_value: &str) -> TableRowListCall<'a, C> {
3177 self._parent = new_value.to_string();
3178 self
3179 }
3180 /// Optional. Column key to use for values in the row. Defaults to user entered name.
3181 ///
3182 /// Sets the *view* query property to the given value.
3183 pub fn view(mut self, new_value: &str) -> TableRowListCall<'a, C> {
3184 self._view = Some(new_value.to_string());
3185 self
3186 }
3187 /// A page token, received from a previous `ListRows` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListRows` must match the call that provided the page token.
3188 ///
3189 /// Sets the *page token* query property to the given value.
3190 pub fn page_token(mut self, new_value: &str) -> TableRowListCall<'a, C> {
3191 self._page_token = Some(new_value.to_string());
3192 self
3193 }
3194 /// The maximum number of rows to return. The service may return fewer than this value. If unspecified, at most 50 rows are returned. The maximum value is 1,000; values above 1,000 are coerced to 1,000.
3195 ///
3196 /// Sets the *page size* query property to the given value.
3197 pub fn page_size(mut self, new_value: i32) -> TableRowListCall<'a, C> {
3198 self._page_size = Some(new_value);
3199 self
3200 }
3201 /// Optional. Sorting order for the list of rows on createTime/updateTime.
3202 ///
3203 /// Sets the *order by* query property to the given value.
3204 pub fn order_by(mut self, new_value: &str) -> TableRowListCall<'a, C> {
3205 self._order_by = Some(new_value.to_string());
3206 self
3207 }
3208 /// Optional. Filter to only include resources matching the requirements. For more information, see [Filtering list results](https://support.google.com/area120-tables/answer/10503371).
3209 ///
3210 /// Sets the *filter* query property to the given value.
3211 pub fn filter(mut self, new_value: &str) -> TableRowListCall<'a, C> {
3212 self._filter = Some(new_value.to_string());
3213 self
3214 }
3215 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3216 /// while executing the actual API request.
3217 ///
3218 /// ````text
3219 /// It should be used to handle progress information, and to implement a certain level of resilience.
3220 /// ````
3221 ///
3222 /// Sets the *delegate* property to the given value.
3223 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TableRowListCall<'a, C> {
3224 self._delegate = Some(new_value);
3225 self
3226 }
3227
3228 /// Set any additional parameter of the query string used in the request.
3229 /// It should be used to set parameters which are not yet available through their own
3230 /// setters.
3231 ///
3232 /// Please note that this method must not be used to set any of the known parameters
3233 /// which have their own setter method. If done anyway, the request will fail.
3234 ///
3235 /// # Additional Parameters
3236 ///
3237 /// * *$.xgafv* (query-string) - V1 error format.
3238 /// * *access_token* (query-string) - OAuth access token.
3239 /// * *alt* (query-string) - Data format for response.
3240 /// * *callback* (query-string) - JSONP
3241 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3242 /// * *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.
3243 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3244 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3245 /// * *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.
3246 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3247 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3248 pub fn param<T>(mut self, name: T, value: T) -> TableRowListCall<'a, C>
3249 where
3250 T: AsRef<str>,
3251 {
3252 self._additional_params
3253 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3254 self
3255 }
3256
3257 /// Identifies the authorization scope for the method you are building.
3258 ///
3259 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3260 /// [`Scope::DriveReadonly`].
3261 ///
3262 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3263 /// tokens for more than one scope.
3264 ///
3265 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3266 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3267 /// sufficient, a read-write scope will do as well.
3268 pub fn add_scope<St>(mut self, scope: St) -> TableRowListCall<'a, C>
3269 where
3270 St: AsRef<str>,
3271 {
3272 self._scopes.insert(String::from(scope.as_ref()));
3273 self
3274 }
3275 /// Identifies the authorization scope(s) for the method you are building.
3276 ///
3277 /// See [`Self::add_scope()`] for details.
3278 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowListCall<'a, C>
3279 where
3280 I: IntoIterator<Item = St>,
3281 St: AsRef<str>,
3282 {
3283 self._scopes
3284 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3285 self
3286 }
3287
3288 /// Removes all scopes, and no default scope will be used either.
3289 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3290 /// for details).
3291 pub fn clear_scopes(mut self) -> TableRowListCall<'a, C> {
3292 self._scopes.clear();
3293 self
3294 }
3295}
3296
3297/// Updates a row.
3298///
3299/// A builder for the *rows.patch* method supported by a *table* resource.
3300/// It is not used directly, but through a [`TableMethods`] instance.
3301///
3302/// # Example
3303///
3304/// Instantiate a resource method builder
3305///
3306/// ```test_harness,no_run
3307/// # extern crate hyper;
3308/// # extern crate hyper_rustls;
3309/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
3310/// use area120tables1_alpha1::api::Row;
3311/// # async fn dox() {
3312/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3313///
3314/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3315/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3316/// # .with_native_roots()
3317/// # .unwrap()
3318/// # .https_only()
3319/// # .enable_http2()
3320/// # .build();
3321///
3322/// # let executor = hyper_util::rt::TokioExecutor::new();
3323/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3324/// # secret,
3325/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3326/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3327/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3328/// # ),
3329/// # ).build().await.unwrap();
3330///
3331/// # let client = hyper_util::client::legacy::Client::builder(
3332/// # hyper_util::rt::TokioExecutor::new()
3333/// # )
3334/// # .build(
3335/// # hyper_rustls::HttpsConnectorBuilder::new()
3336/// # .with_native_roots()
3337/// # .unwrap()
3338/// # .https_or_http()
3339/// # .enable_http2()
3340/// # .build()
3341/// # );
3342/// # let mut hub = Area120Tables::new(client, auth);
3343/// // As the method needs a request, you would usually fill it with the desired information
3344/// // into the respective structure. Some of the parts shown here might not be applicable !
3345/// // Values shown here are possibly random and not representative !
3346/// let mut req = Row::default();
3347///
3348/// // You can configure optional parameters by calling the respective setters at will, and
3349/// // execute the final call using `doit()`.
3350/// // Values shown here are possibly random and not representative !
3351/// let result = hub.tables().rows_patch(req, "name")
3352/// .view("ea")
3353/// .update_mask(FieldMask::new::<&str>(&[]))
3354/// .doit().await;
3355/// # }
3356/// ```
3357pub struct TableRowPatchCall<'a, C>
3358where
3359 C: 'a,
3360{
3361 hub: &'a Area120Tables<C>,
3362 _request: Row,
3363 _name: String,
3364 _view: Option<String>,
3365 _update_mask: Option<common::FieldMask>,
3366 _delegate: Option<&'a mut dyn common::Delegate>,
3367 _additional_params: HashMap<String, String>,
3368 _scopes: BTreeSet<String>,
3369}
3370
3371impl<'a, C> common::CallBuilder for TableRowPatchCall<'a, C> {}
3372
3373impl<'a, C> TableRowPatchCall<'a, C>
3374where
3375 C: common::Connector,
3376{
3377 /// Perform the operation you have build so far.
3378 pub async fn doit(mut self) -> common::Result<(common::Response, Row)> {
3379 use std::borrow::Cow;
3380 use std::io::{Read, Seek};
3381
3382 use common::{url::Params, ToParts};
3383 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3384
3385 let mut dd = common::DefaultDelegate;
3386 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3387 dlg.begin(common::MethodInfo {
3388 id: "area120tables.tables.rows.patch",
3389 http_method: hyper::Method::PATCH,
3390 });
3391
3392 for &field in ["alt", "name", "view", "updateMask"].iter() {
3393 if self._additional_params.contains_key(field) {
3394 dlg.finished(false);
3395 return Err(common::Error::FieldClash(field));
3396 }
3397 }
3398
3399 let mut params = Params::with_capacity(6 + self._additional_params.len());
3400 params.push("name", self._name);
3401 if let Some(value) = self._view.as_ref() {
3402 params.push("view", value);
3403 }
3404 if let Some(value) = self._update_mask.as_ref() {
3405 params.push("updateMask", value.to_string());
3406 }
3407
3408 params.extend(self._additional_params.iter());
3409
3410 params.push("alt", "json");
3411 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
3412 if self._scopes.is_empty() {
3413 self._scopes.insert(Scope::Drive.as_ref().to_string());
3414 }
3415
3416 #[allow(clippy::single_element_loop)]
3417 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3418 url = params.uri_replacement(url, param_name, find_this, true);
3419 }
3420 {
3421 let to_remove = ["name"];
3422 params.remove_params(&to_remove);
3423 }
3424
3425 let url = params.parse_with_url(&url);
3426
3427 let mut json_mime_type = mime::APPLICATION_JSON;
3428 let mut request_value_reader = {
3429 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3430 common::remove_json_null_values(&mut value);
3431 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3432 serde_json::to_writer(&mut dst, &value).unwrap();
3433 dst
3434 };
3435 let request_size = request_value_reader
3436 .seek(std::io::SeekFrom::End(0))
3437 .unwrap();
3438 request_value_reader
3439 .seek(std::io::SeekFrom::Start(0))
3440 .unwrap();
3441
3442 loop {
3443 let token = match self
3444 .hub
3445 .auth
3446 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3447 .await
3448 {
3449 Ok(token) => token,
3450 Err(e) => match dlg.token(e) {
3451 Ok(token) => token,
3452 Err(e) => {
3453 dlg.finished(false);
3454 return Err(common::Error::MissingToken(e));
3455 }
3456 },
3457 };
3458 request_value_reader
3459 .seek(std::io::SeekFrom::Start(0))
3460 .unwrap();
3461 let mut req_result = {
3462 let client = &self.hub.client;
3463 dlg.pre_request();
3464 let mut req_builder = hyper::Request::builder()
3465 .method(hyper::Method::PATCH)
3466 .uri(url.as_str())
3467 .header(USER_AGENT, self.hub._user_agent.clone());
3468
3469 if let Some(token) = token.as_ref() {
3470 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3471 }
3472
3473 let request = req_builder
3474 .header(CONTENT_TYPE, json_mime_type.to_string())
3475 .header(CONTENT_LENGTH, request_size as u64)
3476 .body(common::to_body(
3477 request_value_reader.get_ref().clone().into(),
3478 ));
3479
3480 client.request(request.unwrap()).await
3481 };
3482
3483 match req_result {
3484 Err(err) => {
3485 if let common::Retry::After(d) = dlg.http_error(&err) {
3486 sleep(d).await;
3487 continue;
3488 }
3489 dlg.finished(false);
3490 return Err(common::Error::HttpError(err));
3491 }
3492 Ok(res) => {
3493 let (mut parts, body) = res.into_parts();
3494 let mut body = common::Body::new(body);
3495 if !parts.status.is_success() {
3496 let bytes = common::to_bytes(body).await.unwrap_or_default();
3497 let error = serde_json::from_str(&common::to_string(&bytes));
3498 let response = common::to_response(parts, bytes.into());
3499
3500 if let common::Retry::After(d) =
3501 dlg.http_failure(&response, error.as_ref().ok())
3502 {
3503 sleep(d).await;
3504 continue;
3505 }
3506
3507 dlg.finished(false);
3508
3509 return Err(match error {
3510 Ok(value) => common::Error::BadRequest(value),
3511 _ => common::Error::Failure(response),
3512 });
3513 }
3514 let response = {
3515 let bytes = common::to_bytes(body).await.unwrap_or_default();
3516 let encoded = common::to_string(&bytes);
3517 match serde_json::from_str(&encoded) {
3518 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3519 Err(error) => {
3520 dlg.response_json_decode_error(&encoded, &error);
3521 return Err(common::Error::JsonDecodeError(
3522 encoded.to_string(),
3523 error,
3524 ));
3525 }
3526 }
3527 };
3528
3529 dlg.finished(true);
3530 return Ok(response);
3531 }
3532 }
3533 }
3534 }
3535
3536 ///
3537 /// Sets the *request* property to the given value.
3538 ///
3539 /// Even though the property as already been set when instantiating this call,
3540 /// we provide this method for API completeness.
3541 pub fn request(mut self, new_value: Row) -> TableRowPatchCall<'a, C> {
3542 self._request = new_value;
3543 self
3544 }
3545 /// The resource name of the row. Row names have the form `tables/{table}/rows/{row}`. The name is ignored when creating a row.
3546 ///
3547 /// Sets the *name* path property to the given value.
3548 ///
3549 /// Even though the property as already been set when instantiating this call,
3550 /// we provide this method for API completeness.
3551 pub fn name(mut self, new_value: &str) -> TableRowPatchCall<'a, C> {
3552 self._name = new_value.to_string();
3553 self
3554 }
3555 /// Optional. Column key to use for values in the row. Defaults to user entered name.
3556 ///
3557 /// Sets the *view* query property to the given value.
3558 pub fn view(mut self, new_value: &str) -> TableRowPatchCall<'a, C> {
3559 self._view = Some(new_value.to_string());
3560 self
3561 }
3562 /// The list of fields to update.
3563 ///
3564 /// Sets the *update mask* query property to the given value.
3565 pub fn update_mask(mut self, new_value: common::FieldMask) -> TableRowPatchCall<'a, C> {
3566 self._update_mask = Some(new_value);
3567 self
3568 }
3569 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3570 /// while executing the actual API request.
3571 ///
3572 /// ````text
3573 /// It should be used to handle progress information, and to implement a certain level of resilience.
3574 /// ````
3575 ///
3576 /// Sets the *delegate* property to the given value.
3577 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TableRowPatchCall<'a, C> {
3578 self._delegate = Some(new_value);
3579 self
3580 }
3581
3582 /// Set any additional parameter of the query string used in the request.
3583 /// It should be used to set parameters which are not yet available through their own
3584 /// setters.
3585 ///
3586 /// Please note that this method must not be used to set any of the known parameters
3587 /// which have their own setter method. If done anyway, the request will fail.
3588 ///
3589 /// # Additional Parameters
3590 ///
3591 /// * *$.xgafv* (query-string) - V1 error format.
3592 /// * *access_token* (query-string) - OAuth access token.
3593 /// * *alt* (query-string) - Data format for response.
3594 /// * *callback* (query-string) - JSONP
3595 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3596 /// * *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.
3597 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3598 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3599 /// * *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.
3600 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3601 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3602 pub fn param<T>(mut self, name: T, value: T) -> TableRowPatchCall<'a, C>
3603 where
3604 T: AsRef<str>,
3605 {
3606 self._additional_params
3607 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3608 self
3609 }
3610
3611 /// Identifies the authorization scope for the method you are building.
3612 ///
3613 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3614 /// [`Scope::Drive`].
3615 ///
3616 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3617 /// tokens for more than one scope.
3618 ///
3619 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3620 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3621 /// sufficient, a read-write scope will do as well.
3622 pub fn add_scope<St>(mut self, scope: St) -> TableRowPatchCall<'a, C>
3623 where
3624 St: AsRef<str>,
3625 {
3626 self._scopes.insert(String::from(scope.as_ref()));
3627 self
3628 }
3629 /// Identifies the authorization scope(s) for the method you are building.
3630 ///
3631 /// See [`Self::add_scope()`] for details.
3632 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableRowPatchCall<'a, C>
3633 where
3634 I: IntoIterator<Item = St>,
3635 St: AsRef<str>,
3636 {
3637 self._scopes
3638 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3639 self
3640 }
3641
3642 /// Removes all scopes, and no default scope will be used either.
3643 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3644 /// for details).
3645 pub fn clear_scopes(mut self) -> TableRowPatchCall<'a, C> {
3646 self._scopes.clear();
3647 self
3648 }
3649}
3650
3651/// Gets a table. Returns NOT_FOUND if the table does not exist.
3652///
3653/// A builder for the *get* method supported by a *table* resource.
3654/// It is not used directly, but through a [`TableMethods`] instance.
3655///
3656/// # Example
3657///
3658/// Instantiate a resource method builder
3659///
3660/// ```test_harness,no_run
3661/// # extern crate hyper;
3662/// # extern crate hyper_rustls;
3663/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
3664/// # async fn dox() {
3665/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3666///
3667/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3668/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3669/// # .with_native_roots()
3670/// # .unwrap()
3671/// # .https_only()
3672/// # .enable_http2()
3673/// # .build();
3674///
3675/// # let executor = hyper_util::rt::TokioExecutor::new();
3676/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3677/// # secret,
3678/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3679/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3680/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3681/// # ),
3682/// # ).build().await.unwrap();
3683///
3684/// # let client = hyper_util::client::legacy::Client::builder(
3685/// # hyper_util::rt::TokioExecutor::new()
3686/// # )
3687/// # .build(
3688/// # hyper_rustls::HttpsConnectorBuilder::new()
3689/// # .with_native_roots()
3690/// # .unwrap()
3691/// # .https_or_http()
3692/// # .enable_http2()
3693/// # .build()
3694/// # );
3695/// # let mut hub = Area120Tables::new(client, auth);
3696/// // You can configure optional parameters by calling the respective setters at will, and
3697/// // execute the final call using `doit()`.
3698/// // Values shown here are possibly random and not representative !
3699/// let result = hub.tables().get("name")
3700/// .doit().await;
3701/// # }
3702/// ```
3703pub struct TableGetCall<'a, C>
3704where
3705 C: 'a,
3706{
3707 hub: &'a Area120Tables<C>,
3708 _name: String,
3709 _delegate: Option<&'a mut dyn common::Delegate>,
3710 _additional_params: HashMap<String, String>,
3711 _scopes: BTreeSet<String>,
3712}
3713
3714impl<'a, C> common::CallBuilder for TableGetCall<'a, C> {}
3715
3716impl<'a, C> TableGetCall<'a, C>
3717where
3718 C: common::Connector,
3719{
3720 /// Perform the operation you have build so far.
3721 pub async fn doit(mut self) -> common::Result<(common::Response, Table)> {
3722 use std::borrow::Cow;
3723 use std::io::{Read, Seek};
3724
3725 use common::{url::Params, ToParts};
3726 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3727
3728 let mut dd = common::DefaultDelegate;
3729 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3730 dlg.begin(common::MethodInfo {
3731 id: "area120tables.tables.get",
3732 http_method: hyper::Method::GET,
3733 });
3734
3735 for &field in ["alt", "name"].iter() {
3736 if self._additional_params.contains_key(field) {
3737 dlg.finished(false);
3738 return Err(common::Error::FieldClash(field));
3739 }
3740 }
3741
3742 let mut params = Params::with_capacity(3 + self._additional_params.len());
3743 params.push("name", self._name);
3744
3745 params.extend(self._additional_params.iter());
3746
3747 params.push("alt", "json");
3748 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
3749 if self._scopes.is_empty() {
3750 self._scopes
3751 .insert(Scope::DriveReadonly.as_ref().to_string());
3752 }
3753
3754 #[allow(clippy::single_element_loop)]
3755 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3756 url = params.uri_replacement(url, param_name, find_this, true);
3757 }
3758 {
3759 let to_remove = ["name"];
3760 params.remove_params(&to_remove);
3761 }
3762
3763 let url = params.parse_with_url(&url);
3764
3765 loop {
3766 let token = match self
3767 .hub
3768 .auth
3769 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3770 .await
3771 {
3772 Ok(token) => token,
3773 Err(e) => match dlg.token(e) {
3774 Ok(token) => token,
3775 Err(e) => {
3776 dlg.finished(false);
3777 return Err(common::Error::MissingToken(e));
3778 }
3779 },
3780 };
3781 let mut req_result = {
3782 let client = &self.hub.client;
3783 dlg.pre_request();
3784 let mut req_builder = hyper::Request::builder()
3785 .method(hyper::Method::GET)
3786 .uri(url.as_str())
3787 .header(USER_AGENT, self.hub._user_agent.clone());
3788
3789 if let Some(token) = token.as_ref() {
3790 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3791 }
3792
3793 let request = req_builder
3794 .header(CONTENT_LENGTH, 0_u64)
3795 .body(common::to_body::<String>(None));
3796
3797 client.request(request.unwrap()).await
3798 };
3799
3800 match req_result {
3801 Err(err) => {
3802 if let common::Retry::After(d) = dlg.http_error(&err) {
3803 sleep(d).await;
3804 continue;
3805 }
3806 dlg.finished(false);
3807 return Err(common::Error::HttpError(err));
3808 }
3809 Ok(res) => {
3810 let (mut parts, body) = res.into_parts();
3811 let mut body = common::Body::new(body);
3812 if !parts.status.is_success() {
3813 let bytes = common::to_bytes(body).await.unwrap_or_default();
3814 let error = serde_json::from_str(&common::to_string(&bytes));
3815 let response = common::to_response(parts, bytes.into());
3816
3817 if let common::Retry::After(d) =
3818 dlg.http_failure(&response, error.as_ref().ok())
3819 {
3820 sleep(d).await;
3821 continue;
3822 }
3823
3824 dlg.finished(false);
3825
3826 return Err(match error {
3827 Ok(value) => common::Error::BadRequest(value),
3828 _ => common::Error::Failure(response),
3829 });
3830 }
3831 let response = {
3832 let bytes = common::to_bytes(body).await.unwrap_or_default();
3833 let encoded = common::to_string(&bytes);
3834 match serde_json::from_str(&encoded) {
3835 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3836 Err(error) => {
3837 dlg.response_json_decode_error(&encoded, &error);
3838 return Err(common::Error::JsonDecodeError(
3839 encoded.to_string(),
3840 error,
3841 ));
3842 }
3843 }
3844 };
3845
3846 dlg.finished(true);
3847 return Ok(response);
3848 }
3849 }
3850 }
3851 }
3852
3853 /// Required. The name of the table to retrieve. Format: tables/{table}
3854 ///
3855 /// Sets the *name* path property to the given value.
3856 ///
3857 /// Even though the property as already been set when instantiating this call,
3858 /// we provide this method for API completeness.
3859 pub fn name(mut self, new_value: &str) -> TableGetCall<'a, C> {
3860 self._name = new_value.to_string();
3861 self
3862 }
3863 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3864 /// while executing the actual API request.
3865 ///
3866 /// ````text
3867 /// It should be used to handle progress information, and to implement a certain level of resilience.
3868 /// ````
3869 ///
3870 /// Sets the *delegate* property to the given value.
3871 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TableGetCall<'a, C> {
3872 self._delegate = Some(new_value);
3873 self
3874 }
3875
3876 /// Set any additional parameter of the query string used in the request.
3877 /// It should be used to set parameters which are not yet available through their own
3878 /// setters.
3879 ///
3880 /// Please note that this method must not be used to set any of the known parameters
3881 /// which have their own setter method. If done anyway, the request will fail.
3882 ///
3883 /// # Additional Parameters
3884 ///
3885 /// * *$.xgafv* (query-string) - V1 error format.
3886 /// * *access_token* (query-string) - OAuth access token.
3887 /// * *alt* (query-string) - Data format for response.
3888 /// * *callback* (query-string) - JSONP
3889 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3890 /// * *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.
3891 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3892 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3893 /// * *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.
3894 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3895 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3896 pub fn param<T>(mut self, name: T, value: T) -> TableGetCall<'a, C>
3897 where
3898 T: AsRef<str>,
3899 {
3900 self._additional_params
3901 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3902 self
3903 }
3904
3905 /// Identifies the authorization scope for the method you are building.
3906 ///
3907 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3908 /// [`Scope::DriveReadonly`].
3909 ///
3910 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3911 /// tokens for more than one scope.
3912 ///
3913 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3914 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3915 /// sufficient, a read-write scope will do as well.
3916 pub fn add_scope<St>(mut self, scope: St) -> TableGetCall<'a, C>
3917 where
3918 St: AsRef<str>,
3919 {
3920 self._scopes.insert(String::from(scope.as_ref()));
3921 self
3922 }
3923 /// Identifies the authorization scope(s) for the method you are building.
3924 ///
3925 /// See [`Self::add_scope()`] for details.
3926 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableGetCall<'a, C>
3927 where
3928 I: IntoIterator<Item = St>,
3929 St: AsRef<str>,
3930 {
3931 self._scopes
3932 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3933 self
3934 }
3935
3936 /// Removes all scopes, and no default scope will be used either.
3937 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3938 /// for details).
3939 pub fn clear_scopes(mut self) -> TableGetCall<'a, C> {
3940 self._scopes.clear();
3941 self
3942 }
3943}
3944
3945/// Lists tables for the user.
3946///
3947/// A builder for the *list* method supported by a *table* resource.
3948/// It is not used directly, but through a [`TableMethods`] instance.
3949///
3950/// # Example
3951///
3952/// Instantiate a resource method builder
3953///
3954/// ```test_harness,no_run
3955/// # extern crate hyper;
3956/// # extern crate hyper_rustls;
3957/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
3958/// # async fn dox() {
3959/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3960///
3961/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3962/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3963/// # .with_native_roots()
3964/// # .unwrap()
3965/// # .https_only()
3966/// # .enable_http2()
3967/// # .build();
3968///
3969/// # let executor = hyper_util::rt::TokioExecutor::new();
3970/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3971/// # secret,
3972/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3973/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3974/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3975/// # ),
3976/// # ).build().await.unwrap();
3977///
3978/// # let client = hyper_util::client::legacy::Client::builder(
3979/// # hyper_util::rt::TokioExecutor::new()
3980/// # )
3981/// # .build(
3982/// # hyper_rustls::HttpsConnectorBuilder::new()
3983/// # .with_native_roots()
3984/// # .unwrap()
3985/// # .https_or_http()
3986/// # .enable_http2()
3987/// # .build()
3988/// # );
3989/// # let mut hub = Area120Tables::new(client, auth);
3990/// // You can configure optional parameters by calling the respective setters at will, and
3991/// // execute the final call using `doit()`.
3992/// // Values shown here are possibly random and not representative !
3993/// let result = hub.tables().list()
3994/// .page_token("Lorem")
3995/// .page_size(-25)
3996/// .order_by("labore")
3997/// .doit().await;
3998/// # }
3999/// ```
4000pub struct TableListCall<'a, C>
4001where
4002 C: 'a,
4003{
4004 hub: &'a Area120Tables<C>,
4005 _page_token: Option<String>,
4006 _page_size: Option<i32>,
4007 _order_by: Option<String>,
4008 _delegate: Option<&'a mut dyn common::Delegate>,
4009 _additional_params: HashMap<String, String>,
4010 _scopes: BTreeSet<String>,
4011}
4012
4013impl<'a, C> common::CallBuilder for TableListCall<'a, C> {}
4014
4015impl<'a, C> TableListCall<'a, C>
4016where
4017 C: common::Connector,
4018{
4019 /// Perform the operation you have build so far.
4020 pub async fn doit(mut self) -> common::Result<(common::Response, ListTablesResponse)> {
4021 use std::borrow::Cow;
4022 use std::io::{Read, Seek};
4023
4024 use common::{url::Params, ToParts};
4025 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4026
4027 let mut dd = common::DefaultDelegate;
4028 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4029 dlg.begin(common::MethodInfo {
4030 id: "area120tables.tables.list",
4031 http_method: hyper::Method::GET,
4032 });
4033
4034 for &field in ["alt", "pageToken", "pageSize", "orderBy"].iter() {
4035 if self._additional_params.contains_key(field) {
4036 dlg.finished(false);
4037 return Err(common::Error::FieldClash(field));
4038 }
4039 }
4040
4041 let mut params = Params::with_capacity(5 + self._additional_params.len());
4042 if let Some(value) = self._page_token.as_ref() {
4043 params.push("pageToken", value);
4044 }
4045 if let Some(value) = self._page_size.as_ref() {
4046 params.push("pageSize", value.to_string());
4047 }
4048 if let Some(value) = self._order_by.as_ref() {
4049 params.push("orderBy", value);
4050 }
4051
4052 params.extend(self._additional_params.iter());
4053
4054 params.push("alt", "json");
4055 let mut url = self.hub._base_url.clone() + "v1alpha1/tables";
4056 if self._scopes.is_empty() {
4057 self._scopes
4058 .insert(Scope::DriveReadonly.as_ref().to_string());
4059 }
4060
4061 let url = params.parse_with_url(&url);
4062
4063 loop {
4064 let token = match self
4065 .hub
4066 .auth
4067 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4068 .await
4069 {
4070 Ok(token) => token,
4071 Err(e) => match dlg.token(e) {
4072 Ok(token) => token,
4073 Err(e) => {
4074 dlg.finished(false);
4075 return Err(common::Error::MissingToken(e));
4076 }
4077 },
4078 };
4079 let mut req_result = {
4080 let client = &self.hub.client;
4081 dlg.pre_request();
4082 let mut req_builder = hyper::Request::builder()
4083 .method(hyper::Method::GET)
4084 .uri(url.as_str())
4085 .header(USER_AGENT, self.hub._user_agent.clone());
4086
4087 if let Some(token) = token.as_ref() {
4088 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4089 }
4090
4091 let request = req_builder
4092 .header(CONTENT_LENGTH, 0_u64)
4093 .body(common::to_body::<String>(None));
4094
4095 client.request(request.unwrap()).await
4096 };
4097
4098 match req_result {
4099 Err(err) => {
4100 if let common::Retry::After(d) = dlg.http_error(&err) {
4101 sleep(d).await;
4102 continue;
4103 }
4104 dlg.finished(false);
4105 return Err(common::Error::HttpError(err));
4106 }
4107 Ok(res) => {
4108 let (mut parts, body) = res.into_parts();
4109 let mut body = common::Body::new(body);
4110 if !parts.status.is_success() {
4111 let bytes = common::to_bytes(body).await.unwrap_or_default();
4112 let error = serde_json::from_str(&common::to_string(&bytes));
4113 let response = common::to_response(parts, bytes.into());
4114
4115 if let common::Retry::After(d) =
4116 dlg.http_failure(&response, error.as_ref().ok())
4117 {
4118 sleep(d).await;
4119 continue;
4120 }
4121
4122 dlg.finished(false);
4123
4124 return Err(match error {
4125 Ok(value) => common::Error::BadRequest(value),
4126 _ => common::Error::Failure(response),
4127 });
4128 }
4129 let response = {
4130 let bytes = common::to_bytes(body).await.unwrap_or_default();
4131 let encoded = common::to_string(&bytes);
4132 match serde_json::from_str(&encoded) {
4133 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4134 Err(error) => {
4135 dlg.response_json_decode_error(&encoded, &error);
4136 return Err(common::Error::JsonDecodeError(
4137 encoded.to_string(),
4138 error,
4139 ));
4140 }
4141 }
4142 };
4143
4144 dlg.finished(true);
4145 return Ok(response);
4146 }
4147 }
4148 }
4149 }
4150
4151 /// A page token, received from a previous `ListTables` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListTables` must match the call that provided the page token.
4152 ///
4153 /// Sets the *page token* query property to the given value.
4154 pub fn page_token(mut self, new_value: &str) -> TableListCall<'a, C> {
4155 self._page_token = Some(new_value.to_string());
4156 self
4157 }
4158 /// The maximum number of tables to return. The service may return fewer than this value. If unspecified, at most 20 tables are returned. The maximum value is 100; values above 100 are coerced to 100.
4159 ///
4160 /// Sets the *page size* query property to the given value.
4161 pub fn page_size(mut self, new_value: i32) -> TableListCall<'a, C> {
4162 self._page_size = Some(new_value);
4163 self
4164 }
4165 /// Optional. Sorting order for the list of tables on createTime/updateTime.
4166 ///
4167 /// Sets the *order by* query property to the given value.
4168 pub fn order_by(mut self, new_value: &str) -> TableListCall<'a, C> {
4169 self._order_by = Some(new_value.to_string());
4170 self
4171 }
4172 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4173 /// while executing the actual API request.
4174 ///
4175 /// ````text
4176 /// It should be used to handle progress information, and to implement a certain level of resilience.
4177 /// ````
4178 ///
4179 /// Sets the *delegate* property to the given value.
4180 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TableListCall<'a, C> {
4181 self._delegate = Some(new_value);
4182 self
4183 }
4184
4185 /// Set any additional parameter of the query string used in the request.
4186 /// It should be used to set parameters which are not yet available through their own
4187 /// setters.
4188 ///
4189 /// Please note that this method must not be used to set any of the known parameters
4190 /// which have their own setter method. If done anyway, the request will fail.
4191 ///
4192 /// # Additional Parameters
4193 ///
4194 /// * *$.xgafv* (query-string) - V1 error format.
4195 /// * *access_token* (query-string) - OAuth access token.
4196 /// * *alt* (query-string) - Data format for response.
4197 /// * *callback* (query-string) - JSONP
4198 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4199 /// * *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.
4200 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4201 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4202 /// * *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.
4203 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4204 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4205 pub fn param<T>(mut self, name: T, value: T) -> TableListCall<'a, C>
4206 where
4207 T: AsRef<str>,
4208 {
4209 self._additional_params
4210 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4211 self
4212 }
4213
4214 /// Identifies the authorization scope for the method you are building.
4215 ///
4216 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4217 /// [`Scope::DriveReadonly`].
4218 ///
4219 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4220 /// tokens for more than one scope.
4221 ///
4222 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4223 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4224 /// sufficient, a read-write scope will do as well.
4225 pub fn add_scope<St>(mut self, scope: St) -> TableListCall<'a, C>
4226 where
4227 St: AsRef<str>,
4228 {
4229 self._scopes.insert(String::from(scope.as_ref()));
4230 self
4231 }
4232 /// Identifies the authorization scope(s) for the method you are building.
4233 ///
4234 /// See [`Self::add_scope()`] for details.
4235 pub fn add_scopes<I, St>(mut self, scopes: I) -> TableListCall<'a, C>
4236 where
4237 I: IntoIterator<Item = St>,
4238 St: AsRef<str>,
4239 {
4240 self._scopes
4241 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4242 self
4243 }
4244
4245 /// Removes all scopes, and no default scope will be used either.
4246 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4247 /// for details).
4248 pub fn clear_scopes(mut self) -> TableListCall<'a, C> {
4249 self._scopes.clear();
4250 self
4251 }
4252}
4253
4254/// Gets a workspace. Returns NOT_FOUND if the workspace does not exist.
4255///
4256/// A builder for the *get* method supported by a *workspace* resource.
4257/// It is not used directly, but through a [`WorkspaceMethods`] instance.
4258///
4259/// # Example
4260///
4261/// Instantiate a resource method builder
4262///
4263/// ```test_harness,no_run
4264/// # extern crate hyper;
4265/// # extern crate hyper_rustls;
4266/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
4267/// # async fn dox() {
4268/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4269///
4270/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4271/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4272/// # .with_native_roots()
4273/// # .unwrap()
4274/// # .https_only()
4275/// # .enable_http2()
4276/// # .build();
4277///
4278/// # let executor = hyper_util::rt::TokioExecutor::new();
4279/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4280/// # secret,
4281/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4282/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4283/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4284/// # ),
4285/// # ).build().await.unwrap();
4286///
4287/// # let client = hyper_util::client::legacy::Client::builder(
4288/// # hyper_util::rt::TokioExecutor::new()
4289/// # )
4290/// # .build(
4291/// # hyper_rustls::HttpsConnectorBuilder::new()
4292/// # .with_native_roots()
4293/// # .unwrap()
4294/// # .https_or_http()
4295/// # .enable_http2()
4296/// # .build()
4297/// # );
4298/// # let mut hub = Area120Tables::new(client, auth);
4299/// // You can configure optional parameters by calling the respective setters at will, and
4300/// // execute the final call using `doit()`.
4301/// // Values shown here are possibly random and not representative !
4302/// let result = hub.workspaces().get("name")
4303/// .doit().await;
4304/// # }
4305/// ```
4306pub struct WorkspaceGetCall<'a, C>
4307where
4308 C: 'a,
4309{
4310 hub: &'a Area120Tables<C>,
4311 _name: String,
4312 _delegate: Option<&'a mut dyn common::Delegate>,
4313 _additional_params: HashMap<String, String>,
4314 _scopes: BTreeSet<String>,
4315}
4316
4317impl<'a, C> common::CallBuilder for WorkspaceGetCall<'a, C> {}
4318
4319impl<'a, C> WorkspaceGetCall<'a, C>
4320where
4321 C: common::Connector,
4322{
4323 /// Perform the operation you have build so far.
4324 pub async fn doit(mut self) -> common::Result<(common::Response, Workspace)> {
4325 use std::borrow::Cow;
4326 use std::io::{Read, Seek};
4327
4328 use common::{url::Params, ToParts};
4329 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4330
4331 let mut dd = common::DefaultDelegate;
4332 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4333 dlg.begin(common::MethodInfo {
4334 id: "area120tables.workspaces.get",
4335 http_method: hyper::Method::GET,
4336 });
4337
4338 for &field in ["alt", "name"].iter() {
4339 if self._additional_params.contains_key(field) {
4340 dlg.finished(false);
4341 return Err(common::Error::FieldClash(field));
4342 }
4343 }
4344
4345 let mut params = Params::with_capacity(3 + self._additional_params.len());
4346 params.push("name", self._name);
4347
4348 params.extend(self._additional_params.iter());
4349
4350 params.push("alt", "json");
4351 let mut url = self.hub._base_url.clone() + "v1alpha1/{+name}";
4352 if self._scopes.is_empty() {
4353 self._scopes
4354 .insert(Scope::DriveReadonly.as_ref().to_string());
4355 }
4356
4357 #[allow(clippy::single_element_loop)]
4358 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4359 url = params.uri_replacement(url, param_name, find_this, true);
4360 }
4361 {
4362 let to_remove = ["name"];
4363 params.remove_params(&to_remove);
4364 }
4365
4366 let url = params.parse_with_url(&url);
4367
4368 loop {
4369 let token = match self
4370 .hub
4371 .auth
4372 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4373 .await
4374 {
4375 Ok(token) => token,
4376 Err(e) => match dlg.token(e) {
4377 Ok(token) => token,
4378 Err(e) => {
4379 dlg.finished(false);
4380 return Err(common::Error::MissingToken(e));
4381 }
4382 },
4383 };
4384 let mut req_result = {
4385 let client = &self.hub.client;
4386 dlg.pre_request();
4387 let mut req_builder = hyper::Request::builder()
4388 .method(hyper::Method::GET)
4389 .uri(url.as_str())
4390 .header(USER_AGENT, self.hub._user_agent.clone());
4391
4392 if let Some(token) = token.as_ref() {
4393 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4394 }
4395
4396 let request = req_builder
4397 .header(CONTENT_LENGTH, 0_u64)
4398 .body(common::to_body::<String>(None));
4399
4400 client.request(request.unwrap()).await
4401 };
4402
4403 match req_result {
4404 Err(err) => {
4405 if let common::Retry::After(d) = dlg.http_error(&err) {
4406 sleep(d).await;
4407 continue;
4408 }
4409 dlg.finished(false);
4410 return Err(common::Error::HttpError(err));
4411 }
4412 Ok(res) => {
4413 let (mut parts, body) = res.into_parts();
4414 let mut body = common::Body::new(body);
4415 if !parts.status.is_success() {
4416 let bytes = common::to_bytes(body).await.unwrap_or_default();
4417 let error = serde_json::from_str(&common::to_string(&bytes));
4418 let response = common::to_response(parts, bytes.into());
4419
4420 if let common::Retry::After(d) =
4421 dlg.http_failure(&response, error.as_ref().ok())
4422 {
4423 sleep(d).await;
4424 continue;
4425 }
4426
4427 dlg.finished(false);
4428
4429 return Err(match error {
4430 Ok(value) => common::Error::BadRequest(value),
4431 _ => common::Error::Failure(response),
4432 });
4433 }
4434 let response = {
4435 let bytes = common::to_bytes(body).await.unwrap_or_default();
4436 let encoded = common::to_string(&bytes);
4437 match serde_json::from_str(&encoded) {
4438 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4439 Err(error) => {
4440 dlg.response_json_decode_error(&encoded, &error);
4441 return Err(common::Error::JsonDecodeError(
4442 encoded.to_string(),
4443 error,
4444 ));
4445 }
4446 }
4447 };
4448
4449 dlg.finished(true);
4450 return Ok(response);
4451 }
4452 }
4453 }
4454 }
4455
4456 /// Required. The name of the workspace to retrieve. Format: workspaces/{workspace}
4457 ///
4458 /// Sets the *name* path property to the given value.
4459 ///
4460 /// Even though the property as already been set when instantiating this call,
4461 /// we provide this method for API completeness.
4462 pub fn name(mut self, new_value: &str) -> WorkspaceGetCall<'a, C> {
4463 self._name = new_value.to_string();
4464 self
4465 }
4466 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4467 /// while executing the actual API request.
4468 ///
4469 /// ````text
4470 /// It should be used to handle progress information, and to implement a certain level of resilience.
4471 /// ````
4472 ///
4473 /// Sets the *delegate* property to the given value.
4474 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> WorkspaceGetCall<'a, C> {
4475 self._delegate = Some(new_value);
4476 self
4477 }
4478
4479 /// Set any additional parameter of the query string used in the request.
4480 /// It should be used to set parameters which are not yet available through their own
4481 /// setters.
4482 ///
4483 /// Please note that this method must not be used to set any of the known parameters
4484 /// which have their own setter method. If done anyway, the request will fail.
4485 ///
4486 /// # Additional Parameters
4487 ///
4488 /// * *$.xgafv* (query-string) - V1 error format.
4489 /// * *access_token* (query-string) - OAuth access token.
4490 /// * *alt* (query-string) - Data format for response.
4491 /// * *callback* (query-string) - JSONP
4492 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4493 /// * *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.
4494 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4495 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4496 /// * *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.
4497 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4498 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4499 pub fn param<T>(mut self, name: T, value: T) -> WorkspaceGetCall<'a, C>
4500 where
4501 T: AsRef<str>,
4502 {
4503 self._additional_params
4504 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4505 self
4506 }
4507
4508 /// Identifies the authorization scope for the method you are building.
4509 ///
4510 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4511 /// [`Scope::DriveReadonly`].
4512 ///
4513 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4514 /// tokens for more than one scope.
4515 ///
4516 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4517 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4518 /// sufficient, a read-write scope will do as well.
4519 pub fn add_scope<St>(mut self, scope: St) -> WorkspaceGetCall<'a, C>
4520 where
4521 St: AsRef<str>,
4522 {
4523 self._scopes.insert(String::from(scope.as_ref()));
4524 self
4525 }
4526 /// Identifies the authorization scope(s) for the method you are building.
4527 ///
4528 /// See [`Self::add_scope()`] for details.
4529 pub fn add_scopes<I, St>(mut self, scopes: I) -> WorkspaceGetCall<'a, C>
4530 where
4531 I: IntoIterator<Item = St>,
4532 St: AsRef<str>,
4533 {
4534 self._scopes
4535 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4536 self
4537 }
4538
4539 /// Removes all scopes, and no default scope will be used either.
4540 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4541 /// for details).
4542 pub fn clear_scopes(mut self) -> WorkspaceGetCall<'a, C> {
4543 self._scopes.clear();
4544 self
4545 }
4546}
4547
4548/// Lists workspaces for the user.
4549///
4550/// A builder for the *list* method supported by a *workspace* resource.
4551/// It is not used directly, but through a [`WorkspaceMethods`] instance.
4552///
4553/// # Example
4554///
4555/// Instantiate a resource method builder
4556///
4557/// ```test_harness,no_run
4558/// # extern crate hyper;
4559/// # extern crate hyper_rustls;
4560/// # extern crate google_area120tables1_alpha1 as area120tables1_alpha1;
4561/// # async fn dox() {
4562/// # use area120tables1_alpha1::{Area120Tables, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4563///
4564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4565/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4566/// # .with_native_roots()
4567/// # .unwrap()
4568/// # .https_only()
4569/// # .enable_http2()
4570/// # .build();
4571///
4572/// # let executor = hyper_util::rt::TokioExecutor::new();
4573/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4574/// # secret,
4575/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4576/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4577/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4578/// # ),
4579/// # ).build().await.unwrap();
4580///
4581/// # let client = hyper_util::client::legacy::Client::builder(
4582/// # hyper_util::rt::TokioExecutor::new()
4583/// # )
4584/// # .build(
4585/// # hyper_rustls::HttpsConnectorBuilder::new()
4586/// # .with_native_roots()
4587/// # .unwrap()
4588/// # .https_or_http()
4589/// # .enable_http2()
4590/// # .build()
4591/// # );
4592/// # let mut hub = Area120Tables::new(client, auth);
4593/// // You can configure optional parameters by calling the respective setters at will, and
4594/// // execute the final call using `doit()`.
4595/// // Values shown here are possibly random and not representative !
4596/// let result = hub.workspaces().list()
4597/// .page_token("duo")
4598/// .page_size(-80)
4599/// .doit().await;
4600/// # }
4601/// ```
4602pub struct WorkspaceListCall<'a, C>
4603where
4604 C: 'a,
4605{
4606 hub: &'a Area120Tables<C>,
4607 _page_token: Option<String>,
4608 _page_size: Option<i32>,
4609 _delegate: Option<&'a mut dyn common::Delegate>,
4610 _additional_params: HashMap<String, String>,
4611 _scopes: BTreeSet<String>,
4612}
4613
4614impl<'a, C> common::CallBuilder for WorkspaceListCall<'a, C> {}
4615
4616impl<'a, C> WorkspaceListCall<'a, C>
4617where
4618 C: common::Connector,
4619{
4620 /// Perform the operation you have build so far.
4621 pub async fn doit(mut self) -> common::Result<(common::Response, ListWorkspacesResponse)> {
4622 use std::borrow::Cow;
4623 use std::io::{Read, Seek};
4624
4625 use common::{url::Params, ToParts};
4626 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4627
4628 let mut dd = common::DefaultDelegate;
4629 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4630 dlg.begin(common::MethodInfo {
4631 id: "area120tables.workspaces.list",
4632 http_method: hyper::Method::GET,
4633 });
4634
4635 for &field in ["alt", "pageToken", "pageSize"].iter() {
4636 if self._additional_params.contains_key(field) {
4637 dlg.finished(false);
4638 return Err(common::Error::FieldClash(field));
4639 }
4640 }
4641
4642 let mut params = Params::with_capacity(4 + self._additional_params.len());
4643 if let Some(value) = self._page_token.as_ref() {
4644 params.push("pageToken", value);
4645 }
4646 if let Some(value) = self._page_size.as_ref() {
4647 params.push("pageSize", value.to_string());
4648 }
4649
4650 params.extend(self._additional_params.iter());
4651
4652 params.push("alt", "json");
4653 let mut url = self.hub._base_url.clone() + "v1alpha1/workspaces";
4654 if self._scopes.is_empty() {
4655 self._scopes
4656 .insert(Scope::DriveReadonly.as_ref().to_string());
4657 }
4658
4659 let url = params.parse_with_url(&url);
4660
4661 loop {
4662 let token = match self
4663 .hub
4664 .auth
4665 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4666 .await
4667 {
4668 Ok(token) => token,
4669 Err(e) => match dlg.token(e) {
4670 Ok(token) => token,
4671 Err(e) => {
4672 dlg.finished(false);
4673 return Err(common::Error::MissingToken(e));
4674 }
4675 },
4676 };
4677 let mut req_result = {
4678 let client = &self.hub.client;
4679 dlg.pre_request();
4680 let mut req_builder = hyper::Request::builder()
4681 .method(hyper::Method::GET)
4682 .uri(url.as_str())
4683 .header(USER_AGENT, self.hub._user_agent.clone());
4684
4685 if let Some(token) = token.as_ref() {
4686 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4687 }
4688
4689 let request = req_builder
4690 .header(CONTENT_LENGTH, 0_u64)
4691 .body(common::to_body::<String>(None));
4692
4693 client.request(request.unwrap()).await
4694 };
4695
4696 match req_result {
4697 Err(err) => {
4698 if let common::Retry::After(d) = dlg.http_error(&err) {
4699 sleep(d).await;
4700 continue;
4701 }
4702 dlg.finished(false);
4703 return Err(common::Error::HttpError(err));
4704 }
4705 Ok(res) => {
4706 let (mut parts, body) = res.into_parts();
4707 let mut body = common::Body::new(body);
4708 if !parts.status.is_success() {
4709 let bytes = common::to_bytes(body).await.unwrap_or_default();
4710 let error = serde_json::from_str(&common::to_string(&bytes));
4711 let response = common::to_response(parts, bytes.into());
4712
4713 if let common::Retry::After(d) =
4714 dlg.http_failure(&response, error.as_ref().ok())
4715 {
4716 sleep(d).await;
4717 continue;
4718 }
4719
4720 dlg.finished(false);
4721
4722 return Err(match error {
4723 Ok(value) => common::Error::BadRequest(value),
4724 _ => common::Error::Failure(response),
4725 });
4726 }
4727 let response = {
4728 let bytes = common::to_bytes(body).await.unwrap_or_default();
4729 let encoded = common::to_string(&bytes);
4730 match serde_json::from_str(&encoded) {
4731 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4732 Err(error) => {
4733 dlg.response_json_decode_error(&encoded, &error);
4734 return Err(common::Error::JsonDecodeError(
4735 encoded.to_string(),
4736 error,
4737 ));
4738 }
4739 }
4740 };
4741
4742 dlg.finished(true);
4743 return Ok(response);
4744 }
4745 }
4746 }
4747 }
4748
4749 /// A page token, received from a previous `ListWorkspaces` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListWorkspaces` must match the call that provided the page token.
4750 ///
4751 /// Sets the *page token* query property to the given value.
4752 pub fn page_token(mut self, new_value: &str) -> WorkspaceListCall<'a, C> {
4753 self._page_token = Some(new_value.to_string());
4754 self
4755 }
4756 /// The maximum number of workspaces to return. The service may return fewer than this value. If unspecified, at most 10 workspaces are returned. The maximum value is 25; values above 25 are coerced to 25.
4757 ///
4758 /// Sets the *page size* query property to the given value.
4759 pub fn page_size(mut self, new_value: i32) -> WorkspaceListCall<'a, C> {
4760 self._page_size = Some(new_value);
4761 self
4762 }
4763 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4764 /// while executing the actual API request.
4765 ///
4766 /// ````text
4767 /// It should be used to handle progress information, and to implement a certain level of resilience.
4768 /// ````
4769 ///
4770 /// Sets the *delegate* property to the given value.
4771 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> WorkspaceListCall<'a, C> {
4772 self._delegate = Some(new_value);
4773 self
4774 }
4775
4776 /// Set any additional parameter of the query string used in the request.
4777 /// It should be used to set parameters which are not yet available through their own
4778 /// setters.
4779 ///
4780 /// Please note that this method must not be used to set any of the known parameters
4781 /// which have their own setter method. If done anyway, the request will fail.
4782 ///
4783 /// # Additional Parameters
4784 ///
4785 /// * *$.xgafv* (query-string) - V1 error format.
4786 /// * *access_token* (query-string) - OAuth access token.
4787 /// * *alt* (query-string) - Data format for response.
4788 /// * *callback* (query-string) - JSONP
4789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4790 /// * *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.
4791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4793 /// * *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.
4794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4796 pub fn param<T>(mut self, name: T, value: T) -> WorkspaceListCall<'a, C>
4797 where
4798 T: AsRef<str>,
4799 {
4800 self._additional_params
4801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4802 self
4803 }
4804
4805 /// Identifies the authorization scope for the method you are building.
4806 ///
4807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4808 /// [`Scope::DriveReadonly`].
4809 ///
4810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4811 /// tokens for more than one scope.
4812 ///
4813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4815 /// sufficient, a read-write scope will do as well.
4816 pub fn add_scope<St>(mut self, scope: St) -> WorkspaceListCall<'a, C>
4817 where
4818 St: AsRef<str>,
4819 {
4820 self._scopes.insert(String::from(scope.as_ref()));
4821 self
4822 }
4823 /// Identifies the authorization scope(s) for the method you are building.
4824 ///
4825 /// See [`Self::add_scope()`] for details.
4826 pub fn add_scopes<I, St>(mut self, scopes: I) -> WorkspaceListCall<'a, C>
4827 where
4828 I: IntoIterator<Item = St>,
4829 St: AsRef<str>,
4830 {
4831 self._scopes
4832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4833 self
4834 }
4835
4836 /// Removes all scopes, and no default scope will be used either.
4837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4838 /// for details).
4839 pub fn clear_scopes(mut self) -> WorkspaceListCall<'a, C> {
4840 self._scopes.clear();
4841 self
4842 }
4843}