google_cloud_bigquery/http/table/
list.rs

1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::table::{Clustering, RangePartitioning, TableReference, TimePartitioning};
4
5#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
6#[serde(rename_all = "camelCase")]
7pub struct ListTablesRequest {
8    /// The maximum number of results to return in a single response page.
9    /// Leverage the page tokens to iterate through the entire collection.
10    pub max_results: Option<i64>,
11}
12
13#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
14#[serde(rename_all = "camelCase")]
15pub struct View {
16    /// True if view is defined in legacy SQL dialect, false if in GoogleSQL.
17    pub use_legacy_sql: bool,
18}
19
20#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
21#[serde(rename_all = "camelCase")]
22pub struct TableOverview {
23    /// The resource type.
24    pub kind: String,
25    /// An opaque ID of the table.
26    pub id: String,
27    /// A reference uniquely identifying table..
28    pub table_reference: TableReference,
29    /// The user-friendly name for this table.
30    pub friendly_name: Option<String>,
31    /// The labels associated with this table. You can use these to organize and group your tables.
32    /// An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
33    pub labels: Option<std::collections::HashMap<String, String>>,
34    /// The time-based partitioning for this table.
35    pub time_partitioning: Option<TimePartitioning>,
36    /// The range partitioning for this table..
37    pub range_partitioning: Option<RangePartitioning>,
38    /// Clustering specification for this table, if configured.
39    pub clustering: Option<Clustering>,
40    /// Output only. The time when this table was created, in milliseconds since the epoch.
41    #[serde(deserialize_with = "crate::http::from_str")]
42    pub creation_time: i64,
43    /// OThe time when this table expires, in milliseconds since the epoch. If not present, the table will persist indefinitely. Expired tables will be deleted and their storage reclaimed.
44    #[serde(deserialize_with = "crate::http::from_str_option")]
45    #[serde(default)]
46    pub expiration_time: Option<i64>,
47    /// The type of table.
48    #[serde(rename(deserialize = "type"))]
49    pub table_type: String,
50    /// Additional details for a view.
51    pub view: Option<View>,
52}
53
54#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug)]
55#[serde(rename_all = "camelCase")]
56pub struct ListTablesResponse {
57    /// Output only. The resource type. This property always returns the value "bigquery#datasetList"
58    pub kind: String,
59    /// Output only. A hash value of the results page.
60    /// You can use this property to determine if the page has changed since the last request.
61    pub etag: String,
62    /// An array of the dataset resources in the project.
63    /// Each resource contains basic information.
64    /// For full information about a particular dataset resource, use the Datasets: get method.
65    /// This property is omitted when there are no datasets in the project.
66    pub tables: Vec<TableOverview>,
67    /// A token that can be used to request the next results page.
68    /// This property is omitted on the final results page.
69    pub next_page_token: Option<String>,
70    /// The total number of tables in the dataset.
71    pub total_items: i32,
72}
73
74pub fn build(
75    base_url: &str,
76    client: &Client,
77    project_id: &str,
78    dataset_id: &str,
79    req: &ListTablesRequest,
80    page_token: Option<String>,
81) -> RequestBuilder {
82    let url = format!("{}/projects/{}/datasets/{}/tables", base_url, project_id, dataset_id);
83    let builder = client.get(url).query(req).query(req);
84    if let Some(page_token) = page_token {
85        builder.query(&[("pageToken", page_token.as_str())])
86    } else {
87        builder
88    }
89}