Skip to content
This repository was archived by the owner on Dec 10, 2023. It is now read-only.

Commit 6a3d7ec

Browse files
feat: InfoType categories were added to built-in infoTypes (#409)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 460542545 Source-Link: googleapis/googleapis@898fcea Source-Link: https://github.com/googleapis/googleapis-gen/commit/e97b0c9527bb7172a3f8f3bc411de83468fd6a77 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTk3YjBjOTUyN2JiNzE3MmEzZjhmM2JjNDExZGU4MzQ2OGZkNmE3NyJ9 fix(deps): require google-api-core>=1.32.0,>=2.8.0 PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae686d9cde4fc3e36d0ac02efb8643b15890c1ed Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4075a8514f676691ec156688a5bbf183aa9893ce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9
1 parent 2db1e55 commit 6a3d7ec

File tree

13 files changed

+225
-39
lines changed

13 files changed

+225
-39
lines changed

google/cloud/dlp/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
HybridInspectResponse,
8282
HybridInspectStatistics,
8383
ImageLocation,
84+
InfoTypeCategory,
8485
InfoTypeDescription,
8586
InfoTypeStats,
8687
InfoTypeSummary,
@@ -255,6 +256,7 @@
255256
"HybridInspectResponse",
256257
"HybridInspectStatistics",
257258
"ImageLocation",
259+
"InfoTypeCategory",
258260
"InfoTypeDescription",
259261
"InfoTypeStats",
260262
"InfoTypeSummary",

google/cloud/dlp_v2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
HybridInspectResponse,
8181
HybridInspectStatistics,
8282
ImageLocation,
83+
InfoTypeCategory,
8384
InfoTypeDescription,
8485
InfoTypeStats,
8586
InfoTypeSummary,
@@ -273,6 +274,7 @@
273274
"HybridOptions",
274275
"ImageLocation",
275276
"InfoType",
277+
"InfoTypeCategory",
276278
"InfoTypeDescription",
277279
"InfoTypeStats",
278280
"InfoTypeSummary",

google/cloud/dlp_v2/services/dlp_service/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def __init__(
549549
quota_project_id=client_options.quota_project_id,
550550
client_info=client_info,
551551
always_use_jwt_access=True,
552+
api_audience=client_options.api_audience,
552553
)
553554

554555
def inspect_content(

google/cloud/dlp_v2/services/dlp_service/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
quota_project_id: Optional[str] = None,
5656
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5757
always_use_jwt_access: Optional[bool] = False,
58+
api_audience: Optional[str] = None,
5859
**kwargs,
5960
) -> None:
6061
"""Instantiate the transport.
@@ -82,11 +83,6 @@ def __init__(
8283
be used for service account credentials.
8384
"""
8485

85-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
86-
if ":" not in host:
87-
host += ":443"
88-
self._host = host
89-
9086
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9187

9288
# Save the scopes.
@@ -107,6 +103,11 @@ def __init__(
107103
credentials, _ = google.auth.default(
108104
**scopes_kwargs, quota_project_id=quota_project_id
109105
)
106+
# Don't apply audience if the credentials file passed from user.
107+
if hasattr(credentials, "with_gdch_audience"):
108+
credentials = credentials.with_gdch_audience(
109+
api_audience if api_audience else host
110+
)
110111

111112
# If the credentials are service account credentials, then always try to use self signed JWT.
112113
if (
@@ -119,6 +120,11 @@ def __init__(
119120
# Save the credentials.
120121
self._credentials = credentials
121122

123+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
124+
if ":" not in host:
125+
host += ":443"
126+
self._host = host
127+
122128
def _prep_wrapped_messages(self, client_info):
123129
# Precompute the wrapped methods.
124130
self._wrapped_methods = {

google/cloud/dlp_v2/services/dlp_service/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
quota_project_id: Optional[str] = None,
6868
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6969
always_use_jwt_access: Optional[bool] = False,
70+
api_audience: Optional[str] = None,
7071
) -> None:
7172
"""Instantiate the transport.
7273
@@ -162,6 +163,7 @@ def __init__(
162163
quota_project_id=quota_project_id,
163164
client_info=client_info,
164165
always_use_jwt_access=always_use_jwt_access,
166+
api_audience=api_audience,
165167
)
166168

167169
if not self._grpc_channel:

google/cloud/dlp_v2/services/dlp_service/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def __init__(
112112
quota_project_id=None,
113113
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
114114
always_use_jwt_access: Optional[bool] = False,
115+
api_audience: Optional[str] = None,
115116
) -> None:
116117
"""Instantiate the transport.
117118
@@ -207,6 +208,7 @@ def __init__(
207208
quota_project_id=quota_project_id,
208209
client_info=client_info,
209210
always_use_jwt_access=always_use_jwt_access,
211+
api_audience=api_audience,
210212
)
211213

212214
if not self._grpc_channel:

google/cloud/dlp_v2/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
HybridInspectResponse,
7979
HybridInspectStatistics,
8080
ImageLocation,
81+
InfoTypeCategory,
8182
InfoTypeDescription,
8283
InfoTypeStats,
8384
InfoTypeSummary,
@@ -250,6 +251,7 @@
250251
"HybridInspectResponse",
251252
"HybridInspectStatistics",
252253
"ImageLocation",
254+
"InfoTypeCategory",
253255
"InfoTypeDescription",
254256
"InfoTypeStats",
255257
"InfoTypeSummary",

google/cloud/dlp_v2/types/dlp.py

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"InspectDataSourceDetails",
7373
"HybridInspectStatistics",
7474
"InfoTypeDescription",
75+
"InfoTypeCategory",
7576
"ListInfoTypesRequest",
7677
"ListInfoTypesResponse",
7778
"RiskAnalysisJobConfig",
@@ -423,10 +424,10 @@ class InspectConfig(proto.Message):
423424
findings returned. This is not used for data
424425
profiling.
425426
include_quote (bool):
426-
When true, a contextual quote from the data
427-
that triggered a finding is included in the
428-
response; see Finding.quote. This is not used
429-
for data profiling.
427+
When true, a contextual quote from the data that triggered a
428+
finding is included in the response; see
429+
[Finding.quote][google.privacy.dlp.v2.Finding.quote]. This
430+
is not used for data profiling.
430431
exclude_info_types (bool):
431432
When true, excludes type information of the
432433
findings. This is not used for data profiling.
@@ -1907,6 +1908,8 @@ class InfoTypeDescription(proto.Message):
19071908
description (str):
19081909
Description of the infotype. Translated when
19091910
language is provided in the request.
1911+
categories (Sequence[google.cloud.dlp_v2.types.InfoTypeCategory]):
1912+
The category of the infoType.
19101913
"""
19111914

19121915
name = proto.Field(
@@ -1926,6 +1929,128 @@ class InfoTypeDescription(proto.Message):
19261929
proto.STRING,
19271930
number=4,
19281931
)
1932+
categories = proto.RepeatedField(
1933+
proto.MESSAGE,
1934+
number=10,
1935+
message="InfoTypeCategory",
1936+
)
1937+
1938+
1939+
class InfoTypeCategory(proto.Message):
1940+
r"""Classification of infoTypes to organize them according to
1941+
geographic location, industry, and data type.
1942+
1943+
This message has `oneof`_ fields (mutually exclusive fields).
1944+
For each oneof, at most one member field can be set at the same time.
1945+
Setting any member of the oneof automatically clears all other
1946+
members.
1947+
1948+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1949+
1950+
Attributes:
1951+
location_category (google.cloud.dlp_v2.types.InfoTypeCategory.LocationCategory):
1952+
The region or country that issued the ID or
1953+
document represented by the infoType.
1954+
1955+
This field is a member of `oneof`_ ``category``.
1956+
industry_category (google.cloud.dlp_v2.types.InfoTypeCategory.IndustryCategory):
1957+
The group of relevant businesses where this
1958+
infoType is commonly used
1959+
1960+
This field is a member of `oneof`_ ``category``.
1961+
type_category (google.cloud.dlp_v2.types.InfoTypeCategory.TypeCategory):
1962+
The class of identifiers where this infoType
1963+
belongs
1964+
1965+
This field is a member of `oneof`_ ``category``.
1966+
"""
1967+
1968+
class LocationCategory(proto.Enum):
1969+
r"""Enum of the current locations.
1970+
We might add more locations in the future.
1971+
"""
1972+
LOCATION_UNSPECIFIED = 0
1973+
GLOBAL = 1
1974+
ARGENTINA = 2
1975+
AUSTRALIA = 3
1976+
BELGIUM = 4
1977+
BRAZIL = 5
1978+
CANADA = 6
1979+
CHILE = 7
1980+
CHINA = 8
1981+
COLOMBIA = 9
1982+
DENMARK = 10
1983+
FRANCE = 11
1984+
FINLAND = 12
1985+
GERMANY = 13
1986+
HONG_KONG = 14
1987+
INDIA = 15
1988+
INDONESIA = 16
1989+
IRELAND = 17
1990+
ISRAEL = 18
1991+
ITALY = 19
1992+
JAPAN = 20
1993+
KOREA = 21
1994+
MEXICO = 22
1995+
THE_NETHERLANDS = 23
1996+
NORWAY = 24
1997+
PARAGUAY = 25
1998+
PERU = 26
1999+
POLAND = 27
2000+
PORTUGAL = 28
2001+
SINGAPORE = 29
2002+
SOUTH_AFRICA = 30
2003+
SPAIN = 31
2004+
SWEDEN = 32
2005+
TAIWAN = 33
2006+
THAILAND = 34
2007+
TURKEY = 35
2008+
UNITED_KINGDOM = 36
2009+
UNITED_STATES = 37
2010+
URUGUAY = 38
2011+
VENEZUELA = 39
2012+
INTERNAL = 40
2013+
2014+
class IndustryCategory(proto.Enum):
2015+
r"""Enum of the current industries in the category.
2016+
We might add more industries in the future.
2017+
"""
2018+
INDUSTRY_UNSPECIFIED = 0
2019+
FINANCE = 1
2020+
HEALTH = 2
2021+
TELECOMMUNICATIONS = 3
2022+
2023+
class TypeCategory(proto.Enum):
2024+
r"""Enum of the current types in the category.
2025+
We might add more types in the future.
2026+
"""
2027+
TYPE_UNSPECIFIED = 0
2028+
PII = 1
2029+
SPII = 2
2030+
DEMOGRAPHIC = 3
2031+
CREDENTIAL = 4
2032+
GOVERNMENT_ID = 5
2033+
DOCUMENT = 6
2034+
CONTEXTUAL_INFORMATION = 7
2035+
2036+
location_category = proto.Field(
2037+
proto.ENUM,
2038+
number=1,
2039+
oneof="category",
2040+
enum=LocationCategory,
2041+
)
2042+
industry_category = proto.Field(
2043+
proto.ENUM,
2044+
number=2,
2045+
oneof="category",
2046+
enum=IndustryCategory,
2047+
)
2048+
type_category = proto.Field(
2049+
proto.ENUM,
2050+
number=3,
2051+
oneof="category",
2052+
enum=TypeCategory,
2053+
)
19292054

19302055

19312056
class ListInfoTypesRequest(proto.Message):

google/cloud/dlp_v2/types/storage.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,12 @@ class Proximity(proto.Message):
324324
325325
Attributes:
326326
window_before (int):
327-
Number of characters before the finding to
328-
consider.
327+
Number of characters before the finding to consider. For
328+
tabular data, if you want to modify the likelihood of an
329+
entire column of findngs, set this to 1. For more
330+
information, see [Hotword example: Set the match likelihood
331+
of a table column]
332+
(https://cloud.google.com/dlp/docs/creating-custom-infotypes-likelihood#match-column-values).
329333
window_after (int):
330334
Number of characters after the finding to
331335
consider.
@@ -392,18 +396,20 @@ class HotwordRule(proto.Message):
392396
Regular expression pattern defining what
393397
qualifies as a hotword.
394398
proximity (google.cloud.dlp_v2.types.CustomInfoType.DetectionRule.Proximity):
395-
Proximity of the finding within which the
396-
entire hotword must reside. The total length of
397-
the window cannot exceed 1000 characters. Note
398-
that the finding itself will be included in the
399-
window, so that hotwords may be used to match
400-
substrings of the finding itself. For example,
401-
the certainty of a phone number regex "\(\d{3}\)
402-
\d{3}-\d{4}" could be adjusted upwards if the
403-
area code is known to be the local area code of
404-
a company office using the hotword regex
405-
"\(xxx\)", where "xxx" is the area code in
406-
question.
399+
Range of characters within which the entire hotword must
400+
reside. The total length of the window cannot exceed 1000
401+
characters. The finding itself will be included in the
402+
window, so that hotwords can be used to match substrings of
403+
the finding itself. Suppose you want Cloud DLP to promote
404+
the likelihood of the phone number regex "(\d{3})
405+
\\d{3}-\d{4}" if the area code is known to be the area code
406+
of a company's office. In this case, use the hotword regex
407+
"(xxx)", where "xxx" is the area code in question.
408+
409+
For tabular data, if you want to modify the likelihood of an
410+
entire column of findngs, see [Hotword example: Set the
411+
match likelihood of a table column]
412+
(https://cloud.google.com/dlp/docs/creating-custom-infotypes-likelihood#match-column-values).
407413
likelihood_adjustment (google.cloud.dlp_v2.types.CustomInfoType.DetectionRule.LikelihoodAdjustment):
408414
Likelihood adjustment to apply to all
409415
matching findings.

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
version = "3.7.1"
2525
release_status = "Development Status :: 5 - Production/Stable"
2626
dependencies = [
27-
# NOTE: Maintainers, please do not require google-api-core>=2.x.x
28-
# Until this issue is closed
29-
# https://github.com/googleapis/google-cloud-python/issues/10566
30-
"google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0",
27+
"google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
3128
"proto-plus >= 1.15.0, <2.0.0dev",
3229
"protobuf >= 3.19.0, <4.0.0dev",
3330
]

0 commit comments

Comments
 (0)