google_cloud_bigquery/http/row_access_policy/
list.rs

1use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
2use time::OffsetDateTime;
3
4use crate::http::row_access_policy::RowAccessPolicyReference;
5
6#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct ListRowAccessPoliciesRequest {
9    /// The maximum number of results to return in a single response page.
10    /// Leverage the page tokens to iterate through the entire collection.
11    pub page_size: Option<i64>,
12}
13
14#[derive(Clone, PartialEq, serde::Deserialize, serde::Serialize, Debug, Default)]
15#[serde(rename_all = "camelCase")]
16pub struct ListRowAccessPoliciesResponse {
17    /// Row access policies on the requested table.
18    pub row_access_policies: Option<Vec<RowAccessPolicyOverview>>,
19    /// A token to request the next page of results.
20    pub next_page_token: Option<String>,
21}
22
23#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
24#[serde(rename_all = "camelCase")]
25pub struct RowAccessPolicyOverview {
26    /// Required. Reference describing the ID of this row access policy.
27    pub row_access_policy_reference: RowAccessPolicyReference,
28    /// Required.
29    /// A SQL boolean expression that represents the rows defined by this row access policy,
30    /// similar to the boolean expression in a WHERE clause of a SELECT query on a table.
31    /// References to other tables, routines, and temporary functions are not supported.
32    /// Examples:
33    /// region="EU" date_field = CAST('2019-9-27' as DATE)
34    /// nullable_field is not NULL numeric_field BETWEEN 1.0 AND 5.0
35    pub filter_predicate: String,
36    /// Output only. The time when this row access policy was created, in milliseconds since the epoch.
37    #[serde(default, with = "time::serde::rfc3339::option")]
38    pub creation_time: Option<OffsetDateTime>,
39    /// Output only. The time when this row access policy was last modified, in milliseconds since the epoch.
40    #[serde(default, with = "time::serde::rfc3339::option")]
41    pub last_modified_time: Option<OffsetDateTime>,
42}
43
44pub fn build(
45    base_url: &str,
46    client: &Client,
47    project_id: &str,
48    dataset_id: &str,
49    table_id: &str,
50    data: &ListRowAccessPoliciesRequest,
51    page_token: Option<String>,
52) -> RequestBuilder {
53    let url = format!(
54        "{}/projects/{}/datasets/{}/tables/{}/rowAccessPolicies",
55        base_url, project_id, dataset_id, table_id
56    );
57    let builder = client.get(url).query(data);
58    if let Some(page_token) = page_token {
59        builder.query(&[("pageToken", page_token.as_str())])
60    } else {
61        builder
62    }
63}