google_cloud_bigquery/http/job/
list.rs1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2
3use crate::http::job::{JobConfiguration, JobReference, JobState, JobStatistics, JobStatus};
4use crate::http::types::ErrorProto;
5
6#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
7#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
8pub enum Projection {
9 #[default]
10 Manual,
11 Full,
12}
13
14#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
15#[serde(rename_all = "camelCase")]
16pub struct ListJobsRequest {
17 pub all_users: Option<bool>,
19 pub max_results: Option<i64>,
21 pub min_creation_time: Option<u64>,
24 pub max_creation_time: Option<u64>,
27 pub projection: Option<Projection>,
29 pub state_filter: Option<Vec<JobState>>,
31 pub parent_job_id: String,
33}
34
35#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
36#[serde(rename_all = "camelCase")]
37pub struct JobOverview {
38 pub id: String,
40 pub kind: String,
42 pub job_reference: JobReference,
44 pub state: JobState,
47 pub error_result: Option<ErrorProto>,
49 pub statistics: Option<JobStatistics>,
51 pub configuration: JobConfiguration,
53 pub status: Option<JobStatus>,
55 pub user_email: Option<String>,
57 pub principal_subject: Option<String>,
61}
62
63#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
64#[serde(rename_all = "camelCase")]
65pub struct ListJobsResponse {
66 pub etag: String,
68 pub kind: String,
70 pub next_page_token: Option<String>,
72 pub jobs: Vec<JobOverview>,
74}
75
76pub fn build(
77 base_url: &str,
78 client: &Client,
79 project_id: &str,
80 data: &ListJobsRequest,
81 page_token: Option<String>,
82) -> RequestBuilder {
83 let url = format!("{}/projects/{}/jobs", base_url, project_id);
84 let builder = client.get(url).query(data);
85 if let Some(page_token) = page_token {
86 builder.query(&[("pageToken", page_token.as_str())])
87 } else {
88 builder
89 }
90}