You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
Run the example inspection code on either this site or from the Google documentation
?
Code example
# Import the client libraryimportgoogle.cloud.dlp# Instantiate a client.dlp_client=google.cloud.dlp_v2.DlpServiceClient()
# The string to inspectcontent="Robert Frost"# Construct the item to inspect.item= {"value": content}
# The info types to search for in the content. Required.info_types= [{"name": "FIRST_NAME"}, {"name": "LAST_NAME"}]
# The minimum likelihood to constitute a match. Optional.min_likelihood=google.cloud.dlp_v2.Likelihood.LIKELIHOOD_UNSPECIFIED# The maximum number of findings to report (0 = server maximum). Optional.max_findings=0# Whether to include the matching string in the results. Optional.include_quote=True# Construct the configuration dictionary. Keys which are None may# optionally be omitted entirely.inspect_config= {
"info_types": info_types,
"min_likelihood": min_likelihood,
"include_quote": include_quote,
"limits": {"max_findings_per_request": max_findings},
}
# Convert the project id into a full resource id.parent=f"projects/{project_id}"# Call the API.response=dlp_client.inspect_content(
request={"parent": parent, "inspect_config": inspect_config, "item": item}
)
# Print out the results.ifresponse.result.findings:
forfindinginresponse.result.findings:
try:
print("Quote: {}".format(finding.quote))
exceptAttributeError:
passprint("Info type: {}".format(finding.info_type.name))
# Convert likelihood value to string respresentation.likelihood=finding.likelihood.nameprint("Likelihood: {}".format(likelihood))
else:
print("No findings.")
AttributeError Traceback (most recent call last)
<ipython-input-2-780d6f9179a9> in <module>
----> 1 from google.cloud import dlp_v2
2 from google.oauth2 import service_account
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\__init__.py in <module>
16 #
17
---> 18 from .services.dlp_service import DlpServiceClient
19 from .types.dlp import Action
20 from .types.dlp import ActivateJobTriggerRequest
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\services\dlp_service\__init__.py in <module>
16 #
17
---> 18 from .client import DlpServiceClient
19 from .async_client import DlpServiceAsyncClient
20
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\services\dlp_service\client.py in <module>
31 from google.oauth2 import service_account # type: ignore
32
---> 33 from google.cloud.dlp_v2.services.dlp_service import pagers
34 from google.cloud.dlp_v2.types import dlp
35 from google.protobuf import field_mask_pb2 as field_mask # type: ignore
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\services\dlp_service\pagers.py in <module>
18 from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
19
---> 20 from google.cloud.dlp_v2.types import dlp
21
22
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\types\__init__.py in <module>
40 TableOptions,
41 )
---> 42 from .dlp import (
43 ExcludeInfoTypes,
44 ExclusionRule,
~\AppData\Roaming\Python\Python37\site-packages\google\cloud\dlp_v2\types\dlp.py in <module>
2306
2307
-> 2308 class Value(proto.Message):
2309 r"""Set of primitive values supported by the system. Note that for the
2310 purposes of inspection or transformation, the number of bytes
~\AppData\Roaming\Python\Python37\site-packages\proto\message.py in __new__(mcls, name, bases, attrs)
137 # that index to the field's descriptor.
138 oneofs.setdefault(field.oneof, len(oneofs))
--> 139 field.descriptor.oneof_index = oneofs[field.oneof]
140
141 # If this field references a message, it may be from another
~\AppData\Roaming\Python\Python37\site-packages\proto\fields.py in descriptor(self)
94 type_name = self.enum
95 elif self.enum:
---> 96 type_name = self.enum._meta.full_name
97
98 # Set the descriptor.
c:\users\nhughes\appdata\roaming\python\python37\site-packages\google\protobuf\internal\enum_type_wrapper.py in __getattr__(self, name)
113 pass # fall out to break exception chaining
114 raise AttributeError('Enum {} has no value defined for name {!r}'.format(
--> 115 self._enum_type.name, name))
AttributeError: Enum DayOfWeek has no value defined for name '_meta'
Furthermore this code was working correctly last week
The text was updated successfully, but these errors were encountered:
@NathanHughes Would you mind checking which version of proto-plus is installed? If it is 1.9.0, could you try reverting to 1.8.1 (for the 2.0.0 code)?
Root cause is likely googleapis/proto-plus-python#115. I thought I had pushed a release to revert this last week but it looks like it didn't go through.
#23 ## Environment details
google-cloud-dlp
version: both 1.0.0 and 2.0.0Steps to reproduce
Code example
Stack trace
Version 1.0
Version 2.0
Furthermore this code was working correctly last week
The text was updated successfully, but these errors were encountered: