google_cloud_bigquery/http/model/
list.rs

1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::model::{ModelReference, ModelType};
4
5#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
6#[serde(rename_all = "camelCase")]
7pub struct ListModelsRequest {
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, serde::Deserialize, serde::Serialize, Debug)]
14#[serde(rename_all = "camelCase")]
15pub struct ModelOverview {
16    /// Required. Unique identifier for this model.
17    pub model_reference: ModelReference,
18    /// Output only. The time when this model was created, in millisecs since the epoch.
19    #[serde(deserialize_with = "crate::http::from_str")]
20    pub creation_time: i64,
21    /// Output only. The time when this model was last modified, in millisecs since the epoch.
22    #[serde(deserialize_with = "crate::http::from_str")]
23    pub last_modified_time: u64,
24    /// Output only. Type of the model resource.
25    pub model_type: Option<ModelType>,
26}
27
28#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug)]
29#[serde(rename_all = "camelCase")]
30pub struct ListModelsResponse {
31    /// An array of the dataset resources in the project.
32    /// Each resource contains basic information.
33    /// For full information about a particular dataset resource, use the Datasets: get method.
34    /// This property is omitted when there are no datasets in the project.
35    pub models: Vec<ModelOverview>,
36    /// A token that can be used to request the next results page.
37    /// This property is omitted on the final results page.
38    pub next_page_token: Option<String>,
39}
40
41pub fn build(
42    base_url: &str,
43    client: &Client,
44    project_id: &str,
45    dataset_id: &str,
46    req: &ListModelsRequest,
47    page_token: Option<String>,
48) -> RequestBuilder {
49    let url = format!("{}/projects/{}/datasets/{}/models", base_url, project_id, dataset_id);
50    let builder = client.get(url).query(req).query(req);
51    if let Some(page_token) = page_token {
52        builder.query(&[("pageToken", page_token.as_str())])
53    } else {
54        builder
55    }
56}