google_cloud_bigquery/http/dataset/
mod.rs

1use crate::http::routine::RoutineReference;
2use crate::http::table::TableReference;
3use crate::http::types::{Collation, EncryptionConfiguration};
4
5pub mod delete;
6pub mod get;
7pub mod insert;
8pub mod list;
9pub mod patch;
10
11#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
12#[serde(rename_all = "camelCase")]
13pub struct GcpTag {
14    /// Required. The namespaced friendly name of the tag key, e.g. "12345/environment" where 12345 is org id.
15    pub tag_key: String,
16    /// Required. The friendly short name of the tag value, e.g. "production"
17    pub tag_value: String,
18}
19
20#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
21#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
22pub enum StorageBillingModel {
23    /// Value not set.
24    #[default]
25    StorageBillingModelUnspecified,
26    /// Billing for logical bytes.
27    Logical,
28    /// Billing for physical bytes.
29    Physical,
30}
31
32#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
33#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
34pub enum TargetType {
35    /// This entry applies to views in the dataset.
36    #[default]
37    Views,
38    /// Do not use. You must set a target type explicitly.
39    TargetTypeUnspecified,
40}
41
42#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
43#[serde(rename_all = "camelCase")]
44pub struct LinkedDatasetSource {
45    /// The source dataset reference contains project numbers and not project ids.
46    pub source_dataset: DatasetReference,
47}
48
49#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
50#[serde(rename_all = "camelCase")]
51pub struct DatasetReference {
52    /// Required. A unique ID for this dataset, without the project name.
53    /// The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_).
54    /// The maximum length is 1,024 characters.
55    pub dataset_id: String,
56    /// The ID of the project containing this dataset.
57    pub project_id: String,
58}
59
60#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
61#[serde(rename_all = "camelCase")]
62pub struct DatasetAccessEntry {
63    /// The dataset this entry applies to
64    pub dataset: DatasetReference,
65    /// Which resources in the dataset this entry applies to.
66    /// Currently, only views are supported, but additional target types may be added in the future.
67    pub target_types: Vec<TargetType>,
68}
69
70#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
71#[serde(rename_all = "camelCase")]
72pub enum SpecialGroup {
73    #[default]
74    ProjectOwners,
75    ProjectReaders,
76    ProjectWriters,
77    AllAuthenticatedUsers,
78}
79
80#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
81#[serde(rename_all = "camelCase")]
82pub struct Access {
83    /// An IAM role ID that should be granted to the user, group, or domain specified in this access entry.
84    /// The following legacy mappings will be applied:
85    ///     OWNER <=> roles/bigquery.dataOwner
86    ///     WRITER <=> roles/bigquery.dataEditor
87    ///     READER <=> roles/bigquery.dataViewer
88    /// This field will accept any of the above formats, but will return only the legacy format.
89    /// For example, if you set this field to "roles/bigquery.dataOwner", it will be returned back as "OWNER".
90    pub role: String,
91    /// [Pick one] An email address of a user to grant access to.
92    /// For example: fred@example.com.
93    /// Maps to IAM policy member "user:EMAIL" or "serviceAccount:EMAIL".
94    pub user_by_email: Option<String>,
95    /// [Pick one] An email address of a Google Group to grant access to.
96    /// Maps to IAM policy member "group:GROUP".
97    pub group_by_email: Option<String>,
98    /// [Pick one] A domain to grant access to.
99    /// Any users signed in with the domain specified will be granted the specified access.
100    /// Example: "example.com".
101    /// Maps to IAM policy member "domain:DOMAIN".
102    pub domain: Option<String>,
103    /// [Pick one] A special group to grant access to.
104    /// Possible values include:
105    ///     projectOwners: Owners of the enclosing project.
106    ///     projectReaders: Readers of the enclosing project.
107    ///     projectWriters: Writers of the enclosing project.
108    ///     allAuthenticatedUsers: All authenticated BigQuery users.
109    /// Maps to similarly-named IAM members.
110    pub special_group: Option<SpecialGroup>,
111    /// [Pick one] Some other type of member that appears in the IAM Policy but isn't a user,
112    /// group, domain, or special group.
113    pub iam_member: Option<String>,
114    /// [Pick one] A view from a different dataset to grant access to.
115    /// Queries executed against that view will have read access to views/tables/routines in this dataset.
116    /// The role field is not required when this field is set. If that view is updated by any user,
117    /// access to the view needs to be granted again via an update operation.
118    pub view: Option<TableReference>,
119    /// [Pick one] A routine from a different dataset to grant access to.
120    /// Queries executed against that routine will have read access to views/tables/routines in this dataset.
121    /// Only UDF is supported for now. The role field is not required when this field is set.
122    /// If that routine is updated by any user,
123    /// access to the routine needs to be granted again via an update operation.
124    pub routine: Option<RoutineReference>,
125    /// [Pick one] A grant authorizing all resources of a particular type in a particular dataset access to this dataset.
126    /// Only views are supported for now. The role field is not required when this field is set.
127    /// If that dataset is deleted and re-created, its access needs to be granted again via an update operation.
128    pub dataset: Option<DatasetAccessEntry>,
129}
130
131#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug, Default)]
132#[serde(rename_all = "camelCase")]
133pub struct Dataset {
134    /// Output only. The resource type.
135    pub kind: String,
136    /// Output only. A hash of the resource.
137    pub etag: String,
138    /// Output only. The fully-qualified unique name of the dataset in the format projectId:datasetId.
139    /// The dataset name without the project name is given in the datasetId field. When creating a new dataset,
140    /// leave this field blank, and instead specify the datasetId field.
141    pub id: String,
142    /// Output only. A URL that can be used to access the resource again.
143    /// You can use this URL in Get or Update requests to the resource.
144    pub self_link: String,
145    /// Required. A reference that identifies the dataset.
146    pub dataset_reference: DatasetReference,
147    /// Optional. A descriptive name for the dataset.
148    pub friendly_name: Option<String>,
149    /// Optional. Optional. A user-friendly description of the dataset.
150    pub description: Option<String>,
151    /// Optional. The default lifetime of all tables in the dataset, in milliseconds.
152    /// The minimum lifetime value is 3600000 milliseconds (one hour).
153    /// To clear an existing default expiration with a PATCH request, set to 0. Once this property is set,
154    /// all newly-created tables in the dataset will have an expirationTime property set to
155    /// the creation time plus the value in this property,
156    /// and changing the value will only affect new tables, not existing ones.
157    /// When the expirationTime for a given table is reached, that table will be deleted automatically.
158    /// If a table's expirationTime is modified or removed before the table expires,
159    /// or if you provide an explicit expirationTime when creating a table,
160    /// that value takes precedence over the default expiration time indicated by this property.
161    #[serde(deserialize_with = "crate::http::from_str_option")]
162    #[serde(default)]
163    pub default_table_expiration_ms: Option<i64>,
164    /// This default partition expiration, expressed in milliseconds.
165    ///
166    /// When new time-partitioned tables are created in a dataset where this property is set,
167    /// the table will inherit this value, propagated as the TimePartitioning.expirationMs property on the new table.
168    /// If you set TimePartitioning.expirationMs explicitly when creating a table,
169    /// the defaultPartitionExpirationMs of the containing dataset is ignored.
170    ///
171    /// When creating a partitioned table, if defaultPartitionExpirationMs is set,
172    /// the defaultTableExpirationMs value is ignored and the table will not be inherit a table expiration deadline.
173    #[serde(deserialize_with = "crate::http::from_str_option")]
174    #[serde(default)]
175    pub default_partition_expiration_ms: Option<i64>,
176    /// The labels associated with this dataset.
177    /// You can use these to organize and group your datasets.
178    /// You can set this property when inserting or updating a dataset.
179    /// See Creating and Updating Dataset Labels for more information.
180    ///
181    /// An object containing a list of "key": value pairs.
182    /// Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
183    pub labels: Option<std::collections::HashMap<String, String>>,
184    /// Optional. An array of objects that define dataset access for one or more entities.
185    /// You can set this property when inserting or updating a dataset
186    /// in order to control who is allowed to access the data.
187    /// If unspecified at dataset creation time, BigQuery adds default dataset access for the following entities:
188    ///     access.specialGroup: projectReaders;
189    ///     access.role: READER;
190    ///     access.specialGroup: projectWriters;
191    ///     access.role: WRITER;
192    ///     access.specialGroup: projectOwners;
193    ///     access.role: OWNER;
194    ///     access.userByEmail: [dataset creator email];
195    ///     access.role: OWNER;
196    pub access: Vec<Access>,
197    /// Output only. The time when this dataset was created, in milliseconds since the epoch.
198    #[serde(deserialize_with = "crate::http::from_str")]
199    pub creation_time: i64,
200    /// Output only. The date when this dataset was last modified, in milliseconds since the epoch.
201    #[serde(deserialize_with = "crate::http::from_str")]
202    pub last_modified_time: i64,
203    /// The geographic location where the dataset should reside.
204    /// See https://cloud.google.com/bigquery/docs/locations for supported locations.
205    pub location: String,
206    /// The default encryption key for all tables in the dataset.
207    /// Once this property is set, all newly-created partitioned tables in the dataset will have encryption key set to this value,
208    /// unless table creation request (or query) overrides the key.
209    pub default_encryption_configuration: Option<EncryptionConfiguration>,
210    /// Output only. Reserved for future use.
211    pub satisfies_pzs: Option<bool>,
212    /// Optional. The source when the dataset is of type LINKED.
213    pub linked_dataset_source: Option<LinkedDatasetSource>,
214    /// Optional. TRUE if the dataset and its table names are case-insensitive, otherwise FALSE.
215    /// By default, this is FALSE, which means the dataset and its table names are case-sensitive.
216    /// This field does not affect routine references.
217    pub is_case_insensitive: Option<bool>,
218    /// Optional. Defines the default collation specification of future tables created in the dataset.
219    /// If a table is created in this dataset without table-level default collation,
220    /// then the table inherits the dataset default collation,
221    /// which is applied to the string fields that do not have explicit collation specified.
222    /// A change to this field affects only tables created afterwards,
223    /// and does not alter the existing tables.
224    /// The following values are supported:
225    ///
226    /// 'und:ci': undetermined locale, case insensitive.
227    /// '': empty string. Default to case-sensitive behavior.
228    pub default_collation: Option<Collation>,
229    /// Optional. Defines the time travel window in hours.
230    /// The value can be from 48 to 168 hours (2 to 7 days).
231    /// The default value is 168 hours if this is not set.
232    #[serde(deserialize_with = "crate::http::from_str_option")]
233    #[serde(default)]
234    pub max_time_travel_hours: Option<i64>,
235    /// Output only. Tags for the Dataset.
236    pub tags: Option<Vec<GcpTag>>,
237    /// Optional. Updates storageBillingModel for the dataset.
238    pub storage_billing_model: Option<StorageBillingModel>,
239}