/
policytagmanager.py
550 lines (464 loc) · 15.7 KB
/
policytagmanager.py
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
# -*- coding: utf-8 -*-
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations
from typing import MutableMapping, MutableSequence
from google.protobuf import field_mask_pb2 # type: ignore
import proto # type: ignore
from google.cloud.datacatalog_v1.types import common, timestamps
__protobuf__ = proto.module(
package="google.cloud.datacatalog.v1",
manifest={
"Taxonomy",
"PolicyTag",
"CreateTaxonomyRequest",
"DeleteTaxonomyRequest",
"UpdateTaxonomyRequest",
"ListTaxonomiesRequest",
"ListTaxonomiesResponse",
"GetTaxonomyRequest",
"CreatePolicyTagRequest",
"DeletePolicyTagRequest",
"UpdatePolicyTagRequest",
"ListPolicyTagsRequest",
"ListPolicyTagsResponse",
"GetPolicyTagRequest",
},
)
class Taxonomy(proto.Message):
r"""A taxonomy is a collection of hierarchical policy tags that classify
data along a common axis.
For example, a "data sensitivity" taxonomy might contain the
following policy tags:
::
+ PII
+ Account number
+ Age
+ SSN
+ Zipcode
+ Financials
+ Revenue
A "data origin" taxonomy might contain the following policy tags:
::
+ User data
+ Employee data
+ Partner data
+ Public data
Attributes:
name (str):
Identifier. Resource name of this taxonomy in
URL format.
Note: Policy tag manager generates unique
taxonomy IDs.
display_name (str):
Required. User-defined name of this taxonomy.
The name can't start or end with spaces, must
contain only Unicode letters, numbers,
underscores, dashes, and spaces, and be at most
200 bytes long when encoded in UTF-8.
The taxonomy display name must be unique within
an organization.
description (str):
Optional. Description of this taxonomy. If
not set, defaults to empty.
The description must contain only Unicode
characters, tabs, newlines, carriage returns,
and page breaks, and be at most 2000 bytes long
when encoded in UTF-8.
policy_tag_count (int):
Output only. Number of policy tags in this
taxonomy.
taxonomy_timestamps (google.cloud.datacatalog_v1.types.SystemTimestamps):
Output only. Creation and modification
timestamps of this taxonomy.
activated_policy_types (MutableSequence[google.cloud.datacatalog_v1.types.Taxonomy.PolicyType]):
Optional. A list of policy types that are
activated for this taxonomy. If not set,
defaults to an empty list.
service (google.cloud.datacatalog_v1.types.Taxonomy.Service):
Output only. Identity of the service which
owns the Taxonomy. This field is only populated
when the taxonomy is created by a Google Cloud
service. Currently only 'DATAPLEX' is supported.
"""
class PolicyType(proto.Enum):
r"""Defines policy types where the policy tags can be used for.
Values:
POLICY_TYPE_UNSPECIFIED (0):
Unspecified policy type.
FINE_GRAINED_ACCESS_CONTROL (1):
Fine-grained access control policy that
enables access control on tagged sub-resources.
"""
POLICY_TYPE_UNSPECIFIED = 0
FINE_GRAINED_ACCESS_CONTROL = 1
class Service(proto.Message):
r"""The source system of the Taxonomy.
Attributes:
name (google.cloud.datacatalog_v1.types.ManagingSystem):
The Google Cloud service name.
identity (str):
The service agent for the service.
"""
name: common.ManagingSystem = proto.Field(
proto.ENUM,
number=1,
enum=common.ManagingSystem,
)
identity: str = proto.Field(
proto.STRING,
number=2,
)
name: str = proto.Field(
proto.STRING,
number=1,
)
display_name: str = proto.Field(
proto.STRING,
number=2,
)
description: str = proto.Field(
proto.STRING,
number=3,
)
policy_tag_count: int = proto.Field(
proto.INT32,
number=4,
)
taxonomy_timestamps: timestamps.SystemTimestamps = proto.Field(
proto.MESSAGE,
number=5,
message=timestamps.SystemTimestamps,
)
activated_policy_types: MutableSequence[PolicyType] = proto.RepeatedField(
proto.ENUM,
number=6,
enum=PolicyType,
)
service: Service = proto.Field(
proto.MESSAGE,
number=7,
message=Service,
)
class PolicyTag(proto.Message):
r"""Denotes one policy tag in a taxonomy, for example, SSN.
Policy tags can be defined in a hierarchy. For example:
::
+ Geolocation
+ LatLong
+ City
+ ZipCode
Where the "Geolocation" policy tag contains three children.
Attributes:
name (str):
Identifier. Resource name of this policy tag
in the URL format.
The policy tag manager generates unique taxonomy
IDs and policy tag IDs.
display_name (str):
Required. User-defined name of this policy
tag.
The name can't start or end with spaces and must
be unique within the parent taxonomy, contain
only Unicode letters, numbers, underscores,
dashes and spaces, and be at most 200 bytes long
when encoded in UTF-8.
description (str):
Description of this policy tag. If not set,
defaults to empty.
The description must contain only Unicode
characters, tabs, newlines, carriage returns and
page breaks, and be at most 2000 bytes long when
encoded in UTF-8.
parent_policy_tag (str):
Resource name of this policy tag's parent
policy tag. If empty, this is a top level tag.
If not set, defaults to an empty string.
For example, for the "LatLong" policy tag in the
example above, this field contains the resource
name of the "Geolocation" policy tag, and, for
"Geolocation", this field is empty.
child_policy_tags (MutableSequence[str]):
Output only. Resource names of child policy
tags of this policy tag.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
display_name: str = proto.Field(
proto.STRING,
number=2,
)
description: str = proto.Field(
proto.STRING,
number=3,
)
parent_policy_tag: str = proto.Field(
proto.STRING,
number=4,
)
child_policy_tags: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=5,
)
class CreateTaxonomyRequest(proto.Message):
r"""Request message for
[CreateTaxonomy][google.cloud.datacatalog.v1.PolicyTagManager.CreateTaxonomy].
Attributes:
parent (str):
Required. Resource name of the project that
the taxonomy will belong to.
taxonomy (google.cloud.datacatalog_v1.types.Taxonomy):
The taxonomy to create.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
taxonomy: "Taxonomy" = proto.Field(
proto.MESSAGE,
number=2,
message="Taxonomy",
)
class DeleteTaxonomyRequest(proto.Message):
r"""Request message for
[DeleteTaxonomy][google.cloud.datacatalog.v1.PolicyTagManager.DeleteTaxonomy].
Attributes:
name (str):
Required. Resource name of the taxonomy to
delete.
Note: All policy tags in this taxonomy are also
deleted.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
class UpdateTaxonomyRequest(proto.Message):
r"""Request message for
[UpdateTaxonomy][google.cloud.datacatalog.v1.PolicyTagManager.UpdateTaxonomy].
Attributes:
taxonomy (google.cloud.datacatalog_v1.types.Taxonomy):
The taxonomy to update. You can update only
its description, display name, and activated
policy types.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Specifies fields to update. If not set, defaults to all
fields you can update.
For more information, see [FieldMask]
(https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask).
"""
taxonomy: "Taxonomy" = proto.Field(
proto.MESSAGE,
number=1,
message="Taxonomy",
)
update_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
)
class ListTaxonomiesRequest(proto.Message):
r"""Request message for
[ListTaxonomies][google.cloud.datacatalog.v1.PolicyTagManager.ListTaxonomies].
Attributes:
parent (str):
Required. Resource name of the project to
list the taxonomies of.
page_size (int):
The maximum number of items to return. Must
be a value between 1 and 1000 inclusively. If
not set, defaults to 50.
page_token (str):
The pagination token of the next results
page. If not set, the first page is returned.
The token is returned in the response to a
previous list request.
filter (str):
Supported field for filter is 'service' and
value is 'dataplex'. Eg: service=dataplex.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
page_size: int = proto.Field(
proto.INT32,
number=2,
)
page_token: str = proto.Field(
proto.STRING,
number=3,
)
filter: str = proto.Field(
proto.STRING,
number=4,
)
class ListTaxonomiesResponse(proto.Message):
r"""Response message for
[ListTaxonomies][google.cloud.datacatalog.v1.PolicyTagManager.ListTaxonomies].
Attributes:
taxonomies (MutableSequence[google.cloud.datacatalog_v1.types.Taxonomy]):
Taxonomies that the project contains.
next_page_token (str):
Pagination token of the next results page.
Empty if there are no more results in the list.
"""
@property
def raw_page(self):
return self
taxonomies: MutableSequence["Taxonomy"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Taxonomy",
)
next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
class GetTaxonomyRequest(proto.Message):
r"""Request message for
[GetTaxonomy][google.cloud.datacatalog.v1.PolicyTagManager.GetTaxonomy].
Attributes:
name (str):
Required. Resource name of the taxonomy to
get.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
class CreatePolicyTagRequest(proto.Message):
r"""Request message for
[CreatePolicyTag][google.cloud.datacatalog.v1.PolicyTagManager.CreatePolicyTag].
Attributes:
parent (str):
Required. Resource name of the taxonomy that
the policy tag will belong to.
policy_tag (google.cloud.datacatalog_v1.types.PolicyTag):
The policy tag to create.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
policy_tag: "PolicyTag" = proto.Field(
proto.MESSAGE,
number=2,
message="PolicyTag",
)
class DeletePolicyTagRequest(proto.Message):
r"""Request message for
[DeletePolicyTag][google.cloud.datacatalog.v1.PolicyTagManager.DeletePolicyTag].
Attributes:
name (str):
Required. Resource name of the policy tag to
delete.
Note: All of its descendant policy tags are also
deleted.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
class UpdatePolicyTagRequest(proto.Message):
r"""Request message for
[UpdatePolicyTag][google.cloud.datacatalog.v1.PolicyTagManager.UpdatePolicyTag].
Attributes:
policy_tag (google.cloud.datacatalog_v1.types.PolicyTag):
The policy tag to update. You can update only
its description, display name, and parent policy
tag fields.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Specifies the fields to update.
You can update only display name, description, and parent
policy tag. If not set, defaults to all updatable fields.
For more information, see [FieldMask]
(https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask).
"""
policy_tag: "PolicyTag" = proto.Field(
proto.MESSAGE,
number=1,
message="PolicyTag",
)
update_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
)
class ListPolicyTagsRequest(proto.Message):
r"""Request message for
[ListPolicyTags][google.cloud.datacatalog.v1.PolicyTagManager.ListPolicyTags].
Attributes:
parent (str):
Required. Resource name of the taxonomy to
list the policy tags of.
page_size (int):
The maximum number of items to return. Must
be a value between 1 and 1000 inclusively.
If not set, defaults to 50.
page_token (str):
The pagination token of the next results
page. If not set, returns the first page.
The token is returned in the response to a
previous list request.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
page_size: int = proto.Field(
proto.INT32,
number=2,
)
page_token: str = proto.Field(
proto.STRING,
number=3,
)
class ListPolicyTagsResponse(proto.Message):
r"""Response message for
[ListPolicyTags][google.cloud.datacatalog.v1.PolicyTagManager.ListPolicyTags].
Attributes:
policy_tags (MutableSequence[google.cloud.datacatalog_v1.types.PolicyTag]):
The policy tags that belong to the taxonomy.
next_page_token (str):
Pagination token of the next results page.
Empty if there are no more results in the list.
"""
@property
def raw_page(self):
return self
policy_tags: MutableSequence["PolicyTag"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="PolicyTag",
)
next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
class GetPolicyTagRequest(proto.Message):
r"""Request message for
[GetPolicyTag][google.cloud.datacatalog.v1.PolicyTagManager.GetPolicyTag].
Attributes:
name (str):
Required. Resource name of the policy tag.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
__all__ = tuple(sorted(__protobuf__.manifest))