google_cloud_bigquery/http/table/
list.rs1use 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 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 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 pub kind: String,
25 pub id: String,
27 pub table_reference: TableReference,
29 pub friendly_name: Option<String>,
31 pub labels: Option<std::collections::HashMap<String, String>>,
34 pub time_partitioning: Option<TimePartitioning>,
36 pub range_partitioning: Option<RangePartitioning>,
38 pub clustering: Option<Clustering>,
40 #[serde(deserialize_with = "crate::http::from_str")]
42 pub creation_time: i64,
43 #[serde(deserialize_with = "crate::http::from_str_option")]
45 #[serde(default)]
46 pub expiration_time: Option<i64>,
47 #[serde(rename(deserialize = "type"))]
49 pub table_type: String,
50 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 pub kind: String,
59 pub etag: String,
62 pub tables: Vec<TableOverview>,
67 pub next_page_token: Option<String>,
70 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}