google_cloud_bigquery/http/dataset/list.rs
1use std::collections::HashMap;
2
3use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
4
5use crate::http::dataset::DatasetReference;
6
7#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct ListDatasetsRequest {
10 /// The maximum number of results to return in a single response page.
11 /// Leverage the page tokens to iterate through the entire collection.
12 pub max_results: Option<i32>,
13 /// Whether to list all datasets, including hidden ones.
14 pub all: bool,
15 /// An expression for filtering the results of the request by label.
16 /// The syntax is "labels.<name>[:<value>]".
17 /// Multiple filters can be ANDed together by connecting with a space.
18 /// Example: "labels.department:receiving labels.active".
19 /// See Filtering datasets using labels for details.
20 pub filter: String,
21}
22
23#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug)]
24#[serde(rename_all = "camelCase")]
25pub struct DatasetOverview {
26 /// The resource type.
27 /// This property always returns the value "bigquery#dataset"
28 pub kind: String,
29 /// The fully-qualified, unique, opaque ID of the dataset.
30 pub id: String,
31 /// The dataset reference.
32 /// Use this property to access specific parts of the dataset's ID, such as project ID or dataset ID.
33 pub dataset_reference: DatasetReference,
34 /// The labels associated with this dataset. You can use these to organize and group your datasets.
35 /// An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
36 pub labels: Option<HashMap<String, String>>,
37 /// An alternate name for the dataset. The friendly name is purely decorative in nature.
38 pub friendly_name: Option<String>,
39 /// The geographic location where the dataset resides.
40 pub location: Option<String>,
41}
42
43#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug)]
44#[serde(rename_all = "camelCase")]
45pub struct ListDatasetsResponse {
46 /// Output only. The resource type. This property always returns the value "bigquery#datasetList"
47 pub kind: String,
48 /// Output only. A hash value of the results page.
49 /// You can use this property to determine if the page has changed since the last request.
50 pub etag: String,
51 /// An array of the dataset resources in the project.
52 /// Each resource contains basic information.
53 /// For full information about a particular dataset resource, use the Datasets: get method.
54 /// This property is omitted when there are no datasets in the project.
55 pub datasets: Vec<DatasetOverview>,
56 /// A token that can be used to request the next results page.
57 /// This property is omitted on the final results page.
58 pub next_page_token: Option<String>,
59}
60
61pub fn build(
62 base_url: &str,
63 client: &Client,
64 project_id: &str,
65 req: Option<&ListDatasetsRequest>,
66 page_token: Option<String>,
67) -> RequestBuilder {
68 let url = format!("{}/projects/{}/datasets", base_url, project_id);
69 let mut builder = client.get(url);
70 builder = if let Some(req) = req {
71 builder.query(req)
72 } else {
73 builder
74 };
75 if let Some(page_token) = page_token {
76 builder.query(&[("pageToken", page_token.as_str())])
77 } else {
78 builder
79 }
80}