google_cloud_bigquery/http/job/
cancel.rs

1use reqwest::header::CONTENT_LENGTH;
2use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
3
4use crate::http::job::Job;
5
6#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct CancelJobRequest {
9    /// The geographic location of the job. You must specify the location to run the job for the following scenarios:
10    ///
11    /// If the location to run a job is not in the us or the eu multi-regional location
12    /// If the job's location is in a single region (for example, us-central1)
13    /// For more information, see https://cloud.google.com/bigquery/docs/locations#specifying_your_location.
14    pub location: Option<String>,
15}
16
17#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
18#[serde(rename_all = "camelCase")]
19pub struct CancelJobResponse {
20    /// The resource type of the response.
21    pub kind: String,
22    /// The final state of the job
23    pub job: Job,
24}
25
26pub fn build(
27    base_url: &str,
28    client: &Client,
29    project_id: &str,
30    job_id: &str,
31    data: &CancelJobRequest,
32) -> RequestBuilder {
33    let url = format!("{}/projects/{}/jobs/{}/cancel", base_url, project_id, job_id);
34    client.post(url).query(data).header(CONTENT_LENGTH, 0)
35}