google_cloud_bigquery/http/routine/
list.rs

1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::routine::{Language, RemoteFunctionOptions, RoutineReference, RoutineType};
4
5#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
6#[serde(rename_all = "camelCase")]
7pub struct ListRoutinesRequest {
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    /// If set, then only the Routines matching this filter are returned.
12    /// The current supported form is either "routineType:" or "routineType:",
13    /// where is a RoutineType enum. Example: "routineType:SCALAR_FUNCTION".
14    pub filter: Option<String>,
15}
16
17#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
18#[serde(rename_all = "camelCase")]
19pub struct ListRoutinesResponse {
20    /// Routines in the requested dataset. Unless readMask is set in the request,
21    /// only the following fields are populated: etag, projectId, datasetId, routineId, routineType,
22    /// creationTime, lastModifiedTime, language, and remoteFunctionOptions.
23    pub routines: Vec<RoutineOverview>,
24    /// A token to request the next page of results.
25    pub next_page_token: Option<String>,
26}
27
28#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
29#[serde(rename_all = "camelCase")]
30pub struct RoutineOverview {
31    /// A hash of this resource.
32    pub etag: String,
33    /// Reference describing the ID of this routine.
34    pub routine_reference: RoutineReference,
35    /// The type of routine.
36    pub routine_type: RoutineType,
37    /// The time when this routine was created, in milliseconds since the epoch.
38    #[serde(default, deserialize_with = "crate::http::from_str_option")]
39    pub creation_time: Option<i64>,
40    /// The time when this routine was last modified, in milliseconds since the epoch.
41    #[serde(default, deserialize_with = "crate::http::from_str_option")]
42    pub last_modified_time: Option<i64>,
43    /// Defaults to "SQL" if remoteFunctionOptions field is absent, not set otherwise.
44    pub language: Option<Language>,
45    /// Remote function specific options.
46    pub remote_function_options: Option<RemoteFunctionOptions>,
47}
48
49pub fn build(
50    base_url: &str,
51    client: &Client,
52    project_id: &str,
53    dataset_id: &str,
54    data: &ListRoutinesRequest,
55    page_token: Option<String>,
56) -> RequestBuilder {
57    let url = format!("{}/projects/{}/datasets/{}/routines", base_url, project_id, dataset_id);
58    let builder = client.get(url).query(data);
59    if let Some(page_token) = page_token {
60        builder.query(&[("pageToken", page_token.as_str())])
61    } else {
62        builder
63    }
64}