use reqwest::{Client, RequestBuilder};
use crate::http::routine::{Language, RemoteFunctionOptions, RoutineReference, RoutineType};
#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct ListRoutinesRequest {
pub max_results: Option<i64>,
pub filter: Option<String>,
}
#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct ListRoutinesResponse {
pub routines: Vec<RoutineOverview>,
pub next_page_token: Option<String>,
}
#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct RoutineOverview {
pub etag: String,
pub routine_reference: RoutineReference,
pub routine_type: RoutineType,
#[serde(default, deserialize_with = "crate::http::from_str_option")]
pub creation_time: Option<i64>,
#[serde(default, deserialize_with = "crate::http::from_str_option")]
pub last_modified_time: Option<i64>,
pub language: Option<Language>,
pub remote_function_options: Option<RemoteFunctionOptions>,
}
pub fn build(
base_url: &str,
client: &Client,
project_id: &str,
dataset_id: &str,
data: &ListRoutinesRequest,
page_token: Option<String>,
) -> RequestBuilder {
let url = format!("{}/projects/{}/datasets/{}/routines", base_url, project_id, dataset_id);
let builder = client.get(url).query(data);
if let Some(page_token) = page_token {
builder.query(&[("pageToken", page_token.as_str())])
} else {
builder
}
}