1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
// This file is @generated by prost-build.
/// Request message for the CreateDataPolicy method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateDataPolicyRequest {
    /// Required. Resource name of the project that the data policy will belong to. The
    /// format is `projects/{project_number}/locations/{location_id}`.
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// Required. The data policy to create. The `name` field does not need to be
    /// provided for the data policy creation.
    #[prost(message, optional, tag = "2")]
    pub data_policy: ::core::option::Option<DataPolicy>,
}
/// Response message for the UpdateDataPolicy method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateDataPolicyRequest {
    /// Required. Update the data policy's metadata.
    ///
    /// The target data policy is determined by the `name` field.
    /// Other fields are updated to the specified values based on the field masks.
    #[prost(message, optional, tag = "1")]
    pub data_policy: ::core::option::Option<DataPolicy>,
    /// The update mask applies to the resource. For the `FieldMask` definition,
    /// see
    /// <https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask>
    /// If not set, defaults to all of the fields that are allowed to update.
    ///
    /// Updates to the `name` and `dataPolicyId` fields are not allowed.
    #[prost(message, optional, tag = "2")]
    pub update_mask: ::core::option::Option<::prost_types::FieldMask>,
}
/// Request message for the DeleteDataPolicy method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteDataPolicyRequest {
    /// Required. Resource name of the data policy to delete. Format is
    /// `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the GetDataPolicy method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetDataPolicyRequest {
    /// Required. Resource name of the requested data policy. Format is
    /// `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
}
/// Request message for the ListDataPolicies method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListDataPoliciesRequest {
    /// Required. Resource name of the project for which to list data policies. Format is
    /// `projects/{project_number}/locations/{location_id}`.
    #[prost(string, tag = "1")]
    pub parent: ::prost::alloc::string::String,
    /// The maximum number of data policies to return. Must be a value between 1
    /// and 1000.
    /// If not set, defaults to 50.
    #[prost(int32, tag = "2")]
    pub page_size: i32,
    /// The `nextPageToken` value returned from a previous list request, if any. If
    /// not set, defaults to an empty string.
    #[prost(string, tag = "3")]
    pub page_token: ::prost::alloc::string::String,
}
/// Response message for the ListDataPolicies method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListDataPoliciesResponse {
    /// Data policies that belong to the requested project.
    #[prost(message, repeated, tag = "1")]
    pub data_policies: ::prost::alloc::vec::Vec<DataPolicy>,
    /// Token used to retrieve the next page of results, or empty if there are no
    /// more results.
    #[prost(string, tag = "2")]
    pub next_page_token: ::prost::alloc::string::String,
}
/// Represents the label-policy binding.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DataPolicy {
    /// Output only. Resource name of this data policy, in the format of
    /// `projects/{project_number}/locations/{location_id}/dataPolicies/{data_policy_id}`.
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// Type of data policy.
    #[prost(enumeration = "data_policy::DataPolicyType", tag = "2")]
    pub data_policy_type: i32,
    /// User-assigned (human readable) ID of the data policy that needs to be
    /// unique within a project. Used as {data_policy_id} in part of the resource
    /// name.
    #[prost(string, tag = "3")]
    pub data_policy_id: ::prost::alloc::string::String,
    /// Label that is bound to this data policy.
    #[prost(oneof = "data_policy::MatchingLabel", tags = "4")]
    pub matching_label: ::core::option::Option<data_policy::MatchingLabel>,
    /// The policy that is bound to this data policy.
    #[prost(oneof = "data_policy::Policy", tags = "5")]
    pub policy: ::core::option::Option<data_policy::Policy>,
}
/// Nested message and enum types in `DataPolicy`.
pub mod data_policy {
    /// A list of supported data policy types.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum DataPolicyType {
        /// Default value for the data policy type. This should not be used.
        Unspecified = 0,
        /// Used to create a data policy for column-level security, without data
        /// masking.
        ColumnLevelSecurityPolicy = 3,
        /// Used to create a data policy for data masking.
        DataMaskingPolicy = 2,
    }
    impl DataPolicyType {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                DataPolicyType::Unspecified => "DATA_POLICY_TYPE_UNSPECIFIED",
                DataPolicyType::ColumnLevelSecurityPolicy => {
                    "COLUMN_LEVEL_SECURITY_POLICY"
                }
                DataPolicyType::DataMaskingPolicy => "DATA_MASKING_POLICY",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "DATA_POLICY_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
                "COLUMN_LEVEL_SECURITY_POLICY" => Some(Self::ColumnLevelSecurityPolicy),
                "DATA_MASKING_POLICY" => Some(Self::DataMaskingPolicy),
                _ => None,
            }
        }
    }
    /// Label that is bound to this data policy.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum MatchingLabel {
        /// Policy tag resource name, in the format of
        /// `projects/{project_number}/locations/{location_id}/taxonomies/{taxonomy_id}/policyTags/{policyTag_id}`.
        #[prost(string, tag = "4")]
        PolicyTag(::prost::alloc::string::String),
    }
    /// The policy that is bound to this data policy.
    #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
    pub enum Policy {
        /// The data masking policy that specifies the data masking rule to use.
        #[prost(message, tag = "5")]
        DataMaskingPolicy(super::DataMaskingPolicy),
    }
}
/// The data masking policy that is used to specify data masking rule.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DataMaskingPolicy {
    /// A masking expression to bind to the data masking rule.
    #[prost(oneof = "data_masking_policy::MaskingExpression", tags = "1")]
    pub masking_expression: ::core::option::Option<
        data_masking_policy::MaskingExpression,
    >,
}
/// Nested message and enum types in `DataMaskingPolicy`.
pub mod data_masking_policy {
    /// The available masking rules. Learn more here:
    /// <https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options.>
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum PredefinedExpression {
        /// Default, unspecified predefined expression. No masking will take place
        /// since no expression is specified.
        Unspecified = 0,
        /// Masking expression to replace data with SHA-256 hash.
        Sha256 = 3,
        /// Masking expression to replace data with NULLs.
        AlwaysNull = 5,
        /// Masking expression to replace data with their default masking values.
        /// The default masking values for each type listed as below:
        ///
        /// * STRING: ""
        /// * BYTES: b''
        /// * INTEGER: 0
        /// * FLOAT: 0.0
        /// * NUMERIC: 0
        /// * BOOLEAN: FALSE
        /// * TIMESTAMP: 0001-01-01 00:00:00 UTC
        /// * DATE: 0001-01-01
        /// * TIME: 00:00:00
        /// * DATETIME: 0001-01-01T00:00:00
        /// * GEOGRAPHY: POINT(0 0)
        /// * BIGNUMERIC: 0
        /// * ARRAY: \[\]
        /// * STRUCT: NOT_APPLICABLE
        /// * JSON: NULL
        DefaultMaskingValue = 7,
    }
    impl PredefinedExpression {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                PredefinedExpression::Unspecified => "PREDEFINED_EXPRESSION_UNSPECIFIED",
                PredefinedExpression::Sha256 => "SHA256",
                PredefinedExpression::AlwaysNull => "ALWAYS_NULL",
                PredefinedExpression::DefaultMaskingValue => "DEFAULT_MASKING_VALUE",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "PREDEFINED_EXPRESSION_UNSPECIFIED" => Some(Self::Unspecified),
                "SHA256" => Some(Self::Sha256),
                "ALWAYS_NULL" => Some(Self::AlwaysNull),
                "DEFAULT_MASKING_VALUE" => Some(Self::DefaultMaskingValue),
                _ => None,
            }
        }
    }
    /// A masking expression to bind to the data masking rule.
    #[derive(Clone, Copy, PartialEq, ::prost::Oneof)]
    pub enum MaskingExpression {
        /// A predefined masking expression.
        #[prost(enumeration = "PredefinedExpression", tag = "1")]
        PredefinedExpression(i32),
    }
}
/// Generated client implementations.
pub mod data_policy_service_client {
    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Data Policy Service provides APIs for managing the label-policy bindings.
    #[derive(Debug, Clone)]
    pub struct DataPolicyServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl<T> DataPolicyServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> DataPolicyServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            DataPolicyServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Creates a new data policy under a project with the given `dataPolicyId`
        /// (used as the display name), policy tag, and data policy type.
        pub async fn create_data_policy(
            &mut self,
            request: impl tonic::IntoRequest<super::CreateDataPolicyRequest>,
        ) -> std::result::Result<tonic::Response<super::DataPolicy>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/CreateDataPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "CreateDataPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Updates the metadata for an existing data policy. The target data policy
        /// can be specified by the resource name.
        pub async fn update_data_policy(
            &mut self,
            request: impl tonic::IntoRequest<super::UpdateDataPolicyRequest>,
        ) -> std::result::Result<tonic::Response<super::DataPolicy>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/UpdateDataPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "UpdateDataPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Deletes the data policy specified by its resource name.
        pub async fn delete_data_policy(
            &mut self,
            request: impl tonic::IntoRequest<super::DeleteDataPolicyRequest>,
        ) -> std::result::Result<tonic::Response<()>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/DeleteDataPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "DeleteDataPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Gets the data policy specified by its resource name.
        pub async fn get_data_policy(
            &mut self,
            request: impl tonic::IntoRequest<super::GetDataPolicyRequest>,
        ) -> std::result::Result<tonic::Response<super::DataPolicy>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetDataPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "GetDataPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// List all of the data policies in the specified parent project.
        pub async fn list_data_policies(
            &mut self,
            request: impl tonic::IntoRequest<super::ListDataPoliciesRequest>,
        ) -> std::result::Result<
            tonic::Response<super::ListDataPoliciesResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/ListDataPolicies",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "ListDataPolicies",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Gets the IAM policy for the specified data policy.
        pub async fn get_iam_policy(
            &mut self,
            request: impl tonic::IntoRequest<
                super::super::super::super::super::iam::v1::GetIamPolicyRequest,
            >,
        ) -> std::result::Result<
            tonic::Response<super::super::super::super::super::iam::v1::Policy>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetIamPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "GetIamPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Sets the IAM policy for the specified data policy.
        pub async fn set_iam_policy(
            &mut self,
            request: impl tonic::IntoRequest<
                super::super::super::super::super::iam::v1::SetIamPolicyRequest,
            >,
        ) -> std::result::Result<
            tonic::Response<super::super::super::super::super::iam::v1::Policy>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/SetIamPolicy",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "SetIamPolicy",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Returns the caller's permission on the specified data policy resource.
        pub async fn test_iam_permissions(
            &mut self,
            request: impl tonic::IntoRequest<
                super::super::super::super::super::iam::v1::TestIamPermissionsRequest,
            >,
        ) -> std::result::Result<
            tonic::Response<
                super::super::super::super::super::iam::v1::TestIamPermissionsResponse,
            >,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/TestIamPermissions",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService",
                        "TestIamPermissions",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}