1# -*- coding: utf-8 -*-
2# Copyright 2020 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16from collections import OrderedDict
17from distutils import util
18import os
19import re
20from typing import Dict, Optional, Sequence, Tuple, Type, Union
21import pkg_resources
22
23from google.api_core import client_options as client_options_lib  # type: ignore
24from google.api_core import exceptions as core_exceptions  # type: ignore
25from google.api_core import gapic_v1  # type: ignore
26from google.api_core import retry as retries  # type: ignore
27from google.auth import credentials as ga_credentials  # type: ignore
28from google.auth.transport import mtls  # type: ignore
29from google.auth.transport.grpc import SslCredentials  # type: ignore
30from google.auth.exceptions import MutualTLSChannelError  # type: ignore
31from google.oauth2 import service_account  # type: ignore
32
33OptionalRetry = Union[retries.Retry, object]
34
35from google.cloud.dlp_v2.services.dlp_service import pagers
36from google.cloud.dlp_v2.types import dlp
37from google.protobuf import field_mask_pb2  # type: ignore
38from google.protobuf import timestamp_pb2  # type: ignore
39from .transports.base import DlpServiceTransport, DEFAULT_CLIENT_INFO
40from .transports.grpc import DlpServiceGrpcTransport
41from .transports.grpc_asyncio import DlpServiceGrpcAsyncIOTransport
42
43
44class DlpServiceClientMeta(type):
45    """Metaclass for the DlpService client.
46
47    This provides class-level methods for building and retrieving
48    support objects (e.g. transport) without polluting the client instance
49    objects.
50    """
51
52    _transport_registry = OrderedDict()  # type: Dict[str, Type[DlpServiceTransport]]
53    _transport_registry["grpc"] = DlpServiceGrpcTransport
54    _transport_registry["grpc_asyncio"] = DlpServiceGrpcAsyncIOTransport
55
56    def get_transport_class(cls, label: str = None,) -> Type[DlpServiceTransport]:
57        """Returns an appropriate transport class.
58
59        Args:
60            label: The name of the desired transport. If none is
61                provided, then the first transport in the registry is used.
62
63        Returns:
64            The transport class to use.
65        """
66        # If a specific transport is requested, return that one.
67        if label:
68            return cls._transport_registry[label]
69
70        # No transport is requested; return the default (that is, the first one
71        # in the dictionary).
72        return next(iter(cls._transport_registry.values()))
73
74
75class DlpServiceClient(metaclass=DlpServiceClientMeta):
76    """The Cloud Data Loss Prevention (DLP) API is a service that
77    allows clients to detect the presence of Personally Identifiable
78    Information (PII) and other privacy-sensitive data in user-
79    supplied, unstructured data streams, like text blocks or images.
80    The service also includes methods for sensitive data redaction
81    and scheduling of data scans on Google Cloud Platform based data
82    sets.
83    To learn more about concepts and find how-to guides see
84    https://cloud.google.com/dlp/docs/.
85    """
86
87    @staticmethod
88    def _get_default_mtls_endpoint(api_endpoint):
89        """Converts api endpoint to mTLS endpoint.
90
91        Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
92        "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
93        Args:
94            api_endpoint (Optional[str]): the api endpoint to convert.
95        Returns:
96            str: converted mTLS api endpoint.
97        """
98        if not api_endpoint:
99            return api_endpoint
100
101        mtls_endpoint_re = re.compile(
102            r"(?P<name>[^.]+)(?P<mtls>\.mtls)?(?P<sandbox>\.sandbox)?(?P<googledomain>\.googleapis\.com)?"
103        )
104
105        m = mtls_endpoint_re.match(api_endpoint)
106        name, mtls, sandbox, googledomain = m.groups()
107        if mtls or not googledomain:
108            return api_endpoint
109
110        if sandbox:
111            return api_endpoint.replace(
112                "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
113            )
114
115        return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
116
117    DEFAULT_ENDPOINT = "dlp.googleapis.com"
118    DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__(  # type: ignore
119        DEFAULT_ENDPOINT
120    )
121
122    @classmethod
123    def from_service_account_info(cls, info: dict, *args, **kwargs):
124        """Creates an instance of this client using the provided credentials
125            info.
126
127        Args:
128            info (dict): The service account private key info.
129            args: Additional arguments to pass to the constructor.
130            kwargs: Additional arguments to pass to the constructor.
131
132        Returns:
133            DlpServiceClient: The constructed client.
134        """
135        credentials = service_account.Credentials.from_service_account_info(info)
136        kwargs["credentials"] = credentials
137        return cls(*args, **kwargs)
138
139    @classmethod
140    def from_service_account_file(cls, filename: str, *args, **kwargs):
141        """Creates an instance of this client using the provided credentials
142            file.
143
144        Args:
145            filename (str): The path to the service account private key json
146                file.
147            args: Additional arguments to pass to the constructor.
148            kwargs: Additional arguments to pass to the constructor.
149
150        Returns:
151            DlpServiceClient: The constructed client.
152        """
153        credentials = service_account.Credentials.from_service_account_file(filename)
154        kwargs["credentials"] = credentials
155        return cls(*args, **kwargs)
156
157    from_service_account_json = from_service_account_file
158
159    @property
160    def transport(self) -> DlpServiceTransport:
161        """Returns the transport used by the client instance.
162
163        Returns:
164            DlpServiceTransport: The transport used by the client
165                instance.
166        """
167        return self._transport
168
169    @staticmethod
170    def deidentify_template_path(organization: str, deidentify_template: str,) -> str:
171        """Returns a fully-qualified deidentify_template string."""
172        return "organizations/{organization}/deidentifyTemplates/{deidentify_template}".format(
173            organization=organization, deidentify_template=deidentify_template,
174        )
175
176    @staticmethod
177    def parse_deidentify_template_path(path: str) -> Dict[str, str]:
178        """Parses a deidentify_template path into its component segments."""
179        m = re.match(
180            r"^organizations/(?P<organization>.+?)/deidentifyTemplates/(?P<deidentify_template>.+?)$",
181            path,
182        )
183        return m.groupdict() if m else {}
184
185    @staticmethod
186    def dlp_content_path(project: str,) -> str:
187        """Returns a fully-qualified dlp_content string."""
188        return "projects/{project}/dlpContent".format(project=project,)
189
190    @staticmethod
191    def parse_dlp_content_path(path: str) -> Dict[str, str]:
192        """Parses a dlp_content path into its component segments."""
193        m = re.match(r"^projects/(?P<project>.+?)/dlpContent$", path)
194        return m.groupdict() if m else {}
195
196    @staticmethod
197    def dlp_job_path(project: str, dlp_job: str,) -> str:
198        """Returns a fully-qualified dlp_job string."""
199        return "projects/{project}/dlpJobs/{dlp_job}".format(
200            project=project, dlp_job=dlp_job,
201        )
202
203    @staticmethod
204    def parse_dlp_job_path(path: str) -> Dict[str, str]:
205        """Parses a dlp_job path into its component segments."""
206        m = re.match(r"^projects/(?P<project>.+?)/dlpJobs/(?P<dlp_job>.+?)$", path)
207        return m.groupdict() if m else {}
208
209    @staticmethod
210    def finding_path(project: str, location: str, finding: str,) -> str:
211        """Returns a fully-qualified finding string."""
212        return "projects/{project}/locations/{location}/findings/{finding}".format(
213            project=project, location=location, finding=finding,
214        )
215
216    @staticmethod
217    def parse_finding_path(path: str) -> Dict[str, str]:
218        """Parses a finding path into its component segments."""
219        m = re.match(
220            r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/findings/(?P<finding>.+?)$",
221            path,
222        )
223        return m.groupdict() if m else {}
224
225    @staticmethod
226    def inspect_template_path(organization: str, inspect_template: str,) -> str:
227        """Returns a fully-qualified inspect_template string."""
228        return "organizations/{organization}/inspectTemplates/{inspect_template}".format(
229            organization=organization, inspect_template=inspect_template,
230        )
231
232    @staticmethod
233    def parse_inspect_template_path(path: str) -> Dict[str, str]:
234        """Parses a inspect_template path into its component segments."""
235        m = re.match(
236            r"^organizations/(?P<organization>.+?)/inspectTemplates/(?P<inspect_template>.+?)$",
237            path,
238        )
239        return m.groupdict() if m else {}
240
241    @staticmethod
242    def job_trigger_path(project: str, job_trigger: str,) -> str:
243        """Returns a fully-qualified job_trigger string."""
244        return "projects/{project}/jobTriggers/{job_trigger}".format(
245            project=project, job_trigger=job_trigger,
246        )
247
248    @staticmethod
249    def parse_job_trigger_path(path: str) -> Dict[str, str]:
250        """Parses a job_trigger path into its component segments."""
251        m = re.match(
252            r"^projects/(?P<project>.+?)/jobTriggers/(?P<job_trigger>.+?)$", path
253        )
254        return m.groupdict() if m else {}
255
256    @staticmethod
257    def stored_info_type_path(organization: str, stored_info_type: str,) -> str:
258        """Returns a fully-qualified stored_info_type string."""
259        return "organizations/{organization}/storedInfoTypes/{stored_info_type}".format(
260            organization=organization, stored_info_type=stored_info_type,
261        )
262
263    @staticmethod
264    def parse_stored_info_type_path(path: str) -> Dict[str, str]:
265        """Parses a stored_info_type path into its component segments."""
266        m = re.match(
267            r"^organizations/(?P<organization>.+?)/storedInfoTypes/(?P<stored_info_type>.+?)$",
268            path,
269        )
270        return m.groupdict() if m else {}
271
272    @staticmethod
273    def common_billing_account_path(billing_account: str,) -> str:
274        """Returns a fully-qualified billing_account string."""
275        return "billingAccounts/{billing_account}".format(
276            billing_account=billing_account,
277        )
278
279    @staticmethod
280    def parse_common_billing_account_path(path: str) -> Dict[str, str]:
281        """Parse a billing_account path into its component segments."""
282        m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
283        return m.groupdict() if m else {}
284
285    @staticmethod
286    def common_folder_path(folder: str,) -> str:
287        """Returns a fully-qualified folder string."""
288        return "folders/{folder}".format(folder=folder,)
289
290    @staticmethod
291    def parse_common_folder_path(path: str) -> Dict[str, str]:
292        """Parse a folder path into its component segments."""
293        m = re.match(r"^folders/(?P<folder>.+?)$", path)
294        return m.groupdict() if m else {}
295
296    @staticmethod
297    def common_organization_path(organization: str,) -> str:
298        """Returns a fully-qualified organization string."""
299        return "organizations/{organization}".format(organization=organization,)
300
301    @staticmethod
302    def parse_common_organization_path(path: str) -> Dict[str, str]:
303        """Parse a organization path into its component segments."""
304        m = re.match(r"^organizations/(?P<organization>.+?)$", path)
305        return m.groupdict() if m else {}
306
307    @staticmethod
308    def common_project_path(project: str,) -> str:
309        """Returns a fully-qualified project string."""
310        return "projects/{project}".format(project=project,)
311
312    @staticmethod
313    def parse_common_project_path(path: str) -> Dict[str, str]:
314        """Parse a project path into its component segments."""
315        m = re.match(r"^projects/(?P<project>.+?)$", path)
316        return m.groupdict() if m else {}
317
318    @staticmethod
319    def common_location_path(project: str, location: str,) -> str:
320        """Returns a fully-qualified location string."""
321        return "projects/{project}/locations/{location}".format(
322            project=project, location=location,
323        )
324
325    @staticmethod
326    def parse_common_location_path(path: str) -> Dict[str, str]:
327        """Parse a location path into its component segments."""
328        m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
329        return m.groupdict() if m else {}
330
331    def __init__(
332        self,
333        *,
334        credentials: Optional[ga_credentials.Credentials] = None,
335        transport: Union[str, DlpServiceTransport, None] = None,
336        client_options: Optional[client_options_lib.ClientOptions] = None,
337        client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
338    ) -> None:
339        """Instantiates the dlp service client.
340
341        Args:
342            credentials (Optional[google.auth.credentials.Credentials]): The
343                authorization credentials to attach to requests. These
344                credentials identify the application to the service; if none
345                are specified, the client will attempt to ascertain the
346                credentials from the environment.
347            transport (Union[str, DlpServiceTransport]): The
348                transport to use. If set to None, a transport is chosen
349                automatically.
350            client_options (google.api_core.client_options.ClientOptions): Custom options for the
351                client. It won't take effect if a ``transport`` instance is provided.
352                (1) The ``api_endpoint`` property can be used to override the
353                default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
354                environment variable can also be used to override the endpoint:
355                "always" (always use the default mTLS endpoint), "never" (always
356                use the default regular endpoint) and "auto" (auto switch to the
357                default mTLS endpoint if client certificate is present, this is
358                the default value). However, the ``api_endpoint`` property takes
359                precedence if provided.
360                (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
361                is "true", then the ``client_cert_source`` property can be used
362                to provide client certificate for mutual TLS transport. If
363                not provided, the default SSL client certificate will be used if
364                present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
365                set, no client certificate will be used.
366            client_info (google.api_core.gapic_v1.client_info.ClientInfo):
367                The client info used to send a user-agent string along with
368                API requests. If ``None``, then default info will be used.
369                Generally, you only need to set this if you're developing
370                your own client library.
371
372        Raises:
373            google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
374                creation failed for any reason.
375        """
376        if isinstance(client_options, dict):
377            client_options = client_options_lib.from_dict(client_options)
378        if client_options is None:
379            client_options = client_options_lib.ClientOptions()
380
381        # Create SSL credentials for mutual TLS if needed.
382        use_client_cert = bool(
383            util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
384        )
385
386        client_cert_source_func = None
387        is_mtls = False
388        if use_client_cert:
389            if client_options.client_cert_source:
390                is_mtls = True
391                client_cert_source_func = client_options.client_cert_source
392            else:
393                is_mtls = mtls.has_default_client_cert_source()
394                if is_mtls:
395                    client_cert_source_func = mtls.default_client_cert_source()
396                else:
397                    client_cert_source_func = None
398
399        # Figure out which api endpoint to use.
400        if client_options.api_endpoint is not None:
401            api_endpoint = client_options.api_endpoint
402        else:
403            use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
404            if use_mtls_env == "never":
405                api_endpoint = self.DEFAULT_ENDPOINT
406            elif use_mtls_env == "always":
407                api_endpoint = self.DEFAULT_MTLS_ENDPOINT
408            elif use_mtls_env == "auto":
409                if is_mtls:
410                    api_endpoint = self.DEFAULT_MTLS_ENDPOINT
411                else:
412                    api_endpoint = self.DEFAULT_ENDPOINT
413            else:
414                raise MutualTLSChannelError(
415                    "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted "
416                    "values: never, auto, always"
417                )
418
419        # Save or instantiate the transport.
420        # Ordinarily, we provide the transport, but allowing a custom transport
421        # instance provides an extensibility point for unusual situations.
422        if isinstance(transport, DlpServiceTransport):
423            # transport is a DlpServiceTransport instance.
424            if credentials or client_options.credentials_file:
425                raise ValueError(
426                    "When providing a transport instance, "
427                    "provide its credentials directly."
428                )
429            if client_options.scopes:
430                raise ValueError(
431                    "When providing a transport instance, provide its scopes "
432                    "directly."
433                )
434            self._transport = transport
435        else:
436            Transport = type(self).get_transport_class(transport)
437            self._transport = Transport(
438                credentials=credentials,
439                credentials_file=client_options.credentials_file,
440                host=api_endpoint,
441                scopes=client_options.scopes,
442                client_cert_source_for_mtls=client_cert_source_func,
443                quota_project_id=client_options.quota_project_id,
444                client_info=client_info,
445                always_use_jwt_access=True,
446            )
447
448    def inspect_content(
449        self,
450        request: Union[dlp.InspectContentRequest, dict] = None,
451        *,
452        retry: OptionalRetry = gapic_v1.method.DEFAULT,
453        timeout: float = None,
454        metadata: Sequence[Tuple[str, str]] = (),
455    ) -> dlp.InspectContentResponse:
456        r"""Finds potentially sensitive info in content.
457        This method has limits on input size, processing time,
458        and output size.
459        When no InfoTypes or CustomInfoTypes are specified in
460        this request, the system will automatically choose what
461        detectors to run. By default this may be all types, but
462        may change over time as detectors are updated.
463        For how to guides, see
464        https://cloud.google.com/dlp/docs/inspecting-images and
465        https://cloud.google.com/dlp/docs/inspecting-text,
466
467        Args:
468            request (Union[google.cloud.dlp_v2.types.InspectContentRequest, dict]):
469                The request object. Request to search for potentially
470                sensitive info in a ContentItem.
471            retry (google.api_core.retry.Retry): Designation of what errors, if any,
472                should be retried.
473            timeout (float): The timeout for this request.
474            metadata (Sequence[Tuple[str, str]]): Strings which should be
475                sent along with the request as metadata.
476
477        Returns:
478            google.cloud.dlp_v2.types.InspectContentResponse:
479                Results of inspecting an item.
480        """
481        # Create or coerce a protobuf request object.
482        # Minor optimization to avoid making a copy if the user passes
483        # in a dlp.InspectContentRequest.
484        # There's no risk of modifying the input as we've already verified
485        # there are no flattened fields.
486        if not isinstance(request, dlp.InspectContentRequest):
487            request = dlp.InspectContentRequest(request)
488
489        # Wrap the RPC method; this adds retry and timeout information,
490        # and friendly error handling.
491        rpc = self._transport._wrapped_methods[self._transport.inspect_content]
492
493        # Certain fields should be provided within the metadata header;
494        # add these here.
495        metadata = tuple(metadata) + (
496            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
497        )
498
499        # Send the request.
500        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
501
502        # Done; return the response.
503        return response
504
505    def redact_image(
506        self,
507        request: Union[dlp.RedactImageRequest, dict] = None,
508        *,
509        retry: OptionalRetry = gapic_v1.method.DEFAULT,
510        timeout: float = None,
511        metadata: Sequence[Tuple[str, str]] = (),
512    ) -> dlp.RedactImageResponse:
513        r"""Redacts potentially sensitive info from an image.
514        This method has limits on input size, processing time,
515        and output size. See
516        https://cloud.google.com/dlp/docs/redacting-sensitive-
517        data-images to learn more.
518
519        When no InfoTypes or CustomInfoTypes are specified in
520        this request, the system will automatically choose what
521        detectors to run. By default this may be all types, but
522        may change over time as detectors are updated.
523
524        Args:
525            request (Union[google.cloud.dlp_v2.types.RedactImageRequest, dict]):
526                The request object. Request to search for potentially
527                sensitive info in an image and redact it by covering it
528                with a colored rectangle.
529            retry (google.api_core.retry.Retry): Designation of what errors, if any,
530                should be retried.
531            timeout (float): The timeout for this request.
532            metadata (Sequence[Tuple[str, str]]): Strings which should be
533                sent along with the request as metadata.
534
535        Returns:
536            google.cloud.dlp_v2.types.RedactImageResponse:
537                Results of redacting an image.
538        """
539        # Create or coerce a protobuf request object.
540        # Minor optimization to avoid making a copy if the user passes
541        # in a dlp.RedactImageRequest.
542        # There's no risk of modifying the input as we've already verified
543        # there are no flattened fields.
544        if not isinstance(request, dlp.RedactImageRequest):
545            request = dlp.RedactImageRequest(request)
546
547        # Wrap the RPC method; this adds retry and timeout information,
548        # and friendly error handling.
549        rpc = self._transport._wrapped_methods[self._transport.redact_image]
550
551        # Certain fields should be provided within the metadata header;
552        # add these here.
553        metadata = tuple(metadata) + (
554            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
555        )
556
557        # Send the request.
558        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
559
560        # Done; return the response.
561        return response
562
563    def deidentify_content(
564        self,
565        request: Union[dlp.DeidentifyContentRequest, dict] = None,
566        *,
567        retry: OptionalRetry = gapic_v1.method.DEFAULT,
568        timeout: float = None,
569        metadata: Sequence[Tuple[str, str]] = (),
570    ) -> dlp.DeidentifyContentResponse:
571        r"""De-identifies potentially sensitive info from a
572        ContentItem. This method has limits on input size and
573        output size. See
574        https://cloud.google.com/dlp/docs/deidentify-sensitive-
575        data to learn more.
576
577        When no InfoTypes or CustomInfoTypes are specified in
578        this request, the system will automatically choose what
579        detectors to run. By default this may be all types, but
580        may change over time as detectors are updated.
581
582        Args:
583            request (Union[google.cloud.dlp_v2.types.DeidentifyContentRequest, dict]):
584                The request object. Request to de-identify a list of
585                items.
586            retry (google.api_core.retry.Retry): Designation of what errors, if any,
587                should be retried.
588            timeout (float): The timeout for this request.
589            metadata (Sequence[Tuple[str, str]]): Strings which should be
590                sent along with the request as metadata.
591
592        Returns:
593            google.cloud.dlp_v2.types.DeidentifyContentResponse:
594                Results of de-identifying a
595                ContentItem.
596
597        """
598        # Create or coerce a protobuf request object.
599        # Minor optimization to avoid making a copy if the user passes
600        # in a dlp.DeidentifyContentRequest.
601        # There's no risk of modifying the input as we've already verified
602        # there are no flattened fields.
603        if not isinstance(request, dlp.DeidentifyContentRequest):
604            request = dlp.DeidentifyContentRequest(request)
605
606        # Wrap the RPC method; this adds retry and timeout information,
607        # and friendly error handling.
608        rpc = self._transport._wrapped_methods[self._transport.deidentify_content]
609
610        # Certain fields should be provided within the metadata header;
611        # add these here.
612        metadata = tuple(metadata) + (
613            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
614        )
615
616        # Send the request.
617        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
618
619        # Done; return the response.
620        return response
621
622    def reidentify_content(
623        self,
624        request: Union[dlp.ReidentifyContentRequest, dict] = None,
625        *,
626        retry: OptionalRetry = gapic_v1.method.DEFAULT,
627        timeout: float = None,
628        metadata: Sequence[Tuple[str, str]] = (),
629    ) -> dlp.ReidentifyContentResponse:
630        r"""Re-identifies content that has been de-identified. See
631        https://cloud.google.com/dlp/docs/pseudonymization#re-identification_in_free_text_code_example
632        to learn more.
633
634        Args:
635            request (Union[google.cloud.dlp_v2.types.ReidentifyContentRequest, dict]):
636                The request object. Request to re-identify an item.
637            retry (google.api_core.retry.Retry): Designation of what errors, if any,
638                should be retried.
639            timeout (float): The timeout for this request.
640            metadata (Sequence[Tuple[str, str]]): Strings which should be
641                sent along with the request as metadata.
642
643        Returns:
644            google.cloud.dlp_v2.types.ReidentifyContentResponse:
645                Results of re-identifying a item.
646        """
647        # Create or coerce a protobuf request object.
648        # Minor optimization to avoid making a copy if the user passes
649        # in a dlp.ReidentifyContentRequest.
650        # There's no risk of modifying the input as we've already verified
651        # there are no flattened fields.
652        if not isinstance(request, dlp.ReidentifyContentRequest):
653            request = dlp.ReidentifyContentRequest(request)
654
655        # Wrap the RPC method; this adds retry and timeout information,
656        # and friendly error handling.
657        rpc = self._transport._wrapped_methods[self._transport.reidentify_content]
658
659        # Certain fields should be provided within the metadata header;
660        # add these here.
661        metadata = tuple(metadata) + (
662            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
663        )
664
665        # Send the request.
666        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
667
668        # Done; return the response.
669        return response
670
671    def list_info_types(
672        self,
673        request: Union[dlp.ListInfoTypesRequest, dict] = None,
674        *,
675        parent: str = None,
676        retry: OptionalRetry = gapic_v1.method.DEFAULT,
677        timeout: float = None,
678        metadata: Sequence[Tuple[str, str]] = (),
679    ) -> dlp.ListInfoTypesResponse:
680        r"""Returns a list of the sensitive information types
681        that the DLP API supports. See
682        https://cloud.google.com/dlp/docs/infotypes-reference to
683        learn more.
684
685        Args:
686            request (Union[google.cloud.dlp_v2.types.ListInfoTypesRequest, dict]):
687                The request object. Request for the list of infoTypes.
688            parent (str):
689                The parent resource name.
690
691                The format of this value is as follows:
692
693                ::
694
695                    locations/<var>LOCATION_ID</var>
696
697                This corresponds to the ``parent`` field
698                on the ``request`` instance; if ``request`` is provided, this
699                should not be set.
700            retry (google.api_core.retry.Retry): Designation of what errors, if any,
701                should be retried.
702            timeout (float): The timeout for this request.
703            metadata (Sequence[Tuple[str, str]]): Strings which should be
704                sent along with the request as metadata.
705
706        Returns:
707            google.cloud.dlp_v2.types.ListInfoTypesResponse:
708                Response to the ListInfoTypes
709                request.
710
711        """
712        # Create or coerce a protobuf request object.
713        # Sanity check: If we got a request object, we should *not* have
714        # gotten any keyword arguments that map to the request.
715        has_flattened_params = any([parent])
716        if request is not None and has_flattened_params:
717            raise ValueError(
718                "If the `request` argument is set, then none of "
719                "the individual field arguments should be set."
720            )
721
722        # Minor optimization to avoid making a copy if the user passes
723        # in a dlp.ListInfoTypesRequest.
724        # There's no risk of modifying the input as we've already verified
725        # there are no flattened fields.
726        if not isinstance(request, dlp.ListInfoTypesRequest):
727            request = dlp.ListInfoTypesRequest(request)
728            # If we have keyword arguments corresponding to fields on the
729            # request, apply these.
730            if parent is not None:
731                request.parent = parent
732
733        # Wrap the RPC method; this adds retry and timeout information,
734        # and friendly error handling.
735        rpc = self._transport._wrapped_methods[self._transport.list_info_types]
736
737        # Send the request.
738        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
739
740        # Done; return the response.
741        return response
742
743    def create_inspect_template(
744        self,
745        request: Union[dlp.CreateInspectTemplateRequest, dict] = None,
746        *,
747        parent: str = None,
748        inspect_template: dlp.InspectTemplate = None,
749        retry: OptionalRetry = gapic_v1.method.DEFAULT,
750        timeout: float = None,
751        metadata: Sequence[Tuple[str, str]] = (),
752    ) -> dlp.InspectTemplate:
753        r"""Creates an InspectTemplate for re-using frequently
754        used configuration for inspecting content, images, and
755        storage. See https://cloud.google.com/dlp/docs/creating-
756        templates to learn more.
757
758        Args:
759            request (Union[google.cloud.dlp_v2.types.CreateInspectTemplateRequest, dict]):
760                The request object. Request message for
761                CreateInspectTemplate.
762            parent (str):
763                Required. Parent resource name.
764
765                The format of this value varies depending on the scope
766                of the request (project or organization) and whether you
767                have `specified a processing
768                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
769
770                -  Projects scope, location specified:
771                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
772                -  Projects scope, no location specified (defaults to
773                   global): ``projects/``\ PROJECT_ID
774                -  Organizations scope, location specified:
775                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
776                -  Organizations scope, no location specified (defaults
777                   to global): ``organizations/``\ ORG_ID
778
779                The following example ``parent`` string specifies a
780                parent project with the identifier ``example-project``,
781                and specifies the ``europe-west3`` location for
782                processing data:
783
784                ::
785
786                    parent=projects/example-project/locations/europe-west3
787
788                This corresponds to the ``parent`` field
789                on the ``request`` instance; if ``request`` is provided, this
790                should not be set.
791            inspect_template (google.cloud.dlp_v2.types.InspectTemplate):
792                Required. The InspectTemplate to
793                create.
794
795                This corresponds to the ``inspect_template`` field
796                on the ``request`` instance; if ``request`` is provided, this
797                should not be set.
798            retry (google.api_core.retry.Retry): Designation of what errors, if any,
799                should be retried.
800            timeout (float): The timeout for this request.
801            metadata (Sequence[Tuple[str, str]]): Strings which should be
802                sent along with the request as metadata.
803
804        Returns:
805            google.cloud.dlp_v2.types.InspectTemplate:
806                The inspectTemplate contains a
807                configuration (set of types of sensitive
808                data to be detected) to be used anywhere
809                you otherwise would normally specify
810                InspectConfig. See
811                https://cloud.google.com/dlp/docs/concepts-
812                templates to learn more.
813
814        """
815        # Create or coerce a protobuf request object.
816        # Sanity check: If we got a request object, we should *not* have
817        # gotten any keyword arguments that map to the request.
818        has_flattened_params = any([parent, inspect_template])
819        if request is not None and has_flattened_params:
820            raise ValueError(
821                "If the `request` argument is set, then none of "
822                "the individual field arguments should be set."
823            )
824
825        # Minor optimization to avoid making a copy if the user passes
826        # in a dlp.CreateInspectTemplateRequest.
827        # There's no risk of modifying the input as we've already verified
828        # there are no flattened fields.
829        if not isinstance(request, dlp.CreateInspectTemplateRequest):
830            request = dlp.CreateInspectTemplateRequest(request)
831            # If we have keyword arguments corresponding to fields on the
832            # request, apply these.
833            if parent is not None:
834                request.parent = parent
835            if inspect_template is not None:
836                request.inspect_template = inspect_template
837
838        # Wrap the RPC method; this adds retry and timeout information,
839        # and friendly error handling.
840        rpc = self._transport._wrapped_methods[self._transport.create_inspect_template]
841
842        # Certain fields should be provided within the metadata header;
843        # add these here.
844        metadata = tuple(metadata) + (
845            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
846        )
847
848        # Send the request.
849        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
850
851        # Done; return the response.
852        return response
853
854    def update_inspect_template(
855        self,
856        request: Union[dlp.UpdateInspectTemplateRequest, dict] = None,
857        *,
858        name: str = None,
859        inspect_template: dlp.InspectTemplate = None,
860        update_mask: field_mask_pb2.FieldMask = None,
861        retry: OptionalRetry = gapic_v1.method.DEFAULT,
862        timeout: float = None,
863        metadata: Sequence[Tuple[str, str]] = (),
864    ) -> dlp.InspectTemplate:
865        r"""Updates the InspectTemplate.
866        See https://cloud.google.com/dlp/docs/creating-templates
867        to learn more.
868
869        Args:
870            request (Union[google.cloud.dlp_v2.types.UpdateInspectTemplateRequest, dict]):
871                The request object. Request message for
872                UpdateInspectTemplate.
873            name (str):
874                Required. Resource name of organization and
875                inspectTemplate to be updated, for example
876                ``organizations/433245324/inspectTemplates/432452342``
877                or projects/project-id/inspectTemplates/432452342.
878
879                This corresponds to the ``name`` field
880                on the ``request`` instance; if ``request`` is provided, this
881                should not be set.
882            inspect_template (google.cloud.dlp_v2.types.InspectTemplate):
883                New InspectTemplate value.
884                This corresponds to the ``inspect_template`` field
885                on the ``request`` instance; if ``request`` is provided, this
886                should not be set.
887            update_mask (google.protobuf.field_mask_pb2.FieldMask):
888                Mask to control which fields get
889                updated.
890
891                This corresponds to the ``update_mask`` field
892                on the ``request`` instance; if ``request`` is provided, this
893                should not be set.
894            retry (google.api_core.retry.Retry): Designation of what errors, if any,
895                should be retried.
896            timeout (float): The timeout for this request.
897            metadata (Sequence[Tuple[str, str]]): Strings which should be
898                sent along with the request as metadata.
899
900        Returns:
901            google.cloud.dlp_v2.types.InspectTemplate:
902                The inspectTemplate contains a
903                configuration (set of types of sensitive
904                data to be detected) to be used anywhere
905                you otherwise would normally specify
906                InspectConfig. See
907                https://cloud.google.com/dlp/docs/concepts-
908                templates to learn more.
909
910        """
911        # Create or coerce a protobuf request object.
912        # Sanity check: If we got a request object, we should *not* have
913        # gotten any keyword arguments that map to the request.
914        has_flattened_params = any([name, inspect_template, update_mask])
915        if request is not None and has_flattened_params:
916            raise ValueError(
917                "If the `request` argument is set, then none of "
918                "the individual field arguments should be set."
919            )
920
921        # Minor optimization to avoid making a copy if the user passes
922        # in a dlp.UpdateInspectTemplateRequest.
923        # There's no risk of modifying the input as we've already verified
924        # there are no flattened fields.
925        if not isinstance(request, dlp.UpdateInspectTemplateRequest):
926            request = dlp.UpdateInspectTemplateRequest(request)
927            # If we have keyword arguments corresponding to fields on the
928            # request, apply these.
929            if name is not None:
930                request.name = name
931            if inspect_template is not None:
932                request.inspect_template = inspect_template
933            if update_mask is not None:
934                request.update_mask = update_mask
935
936        # Wrap the RPC method; this adds retry and timeout information,
937        # and friendly error handling.
938        rpc = self._transport._wrapped_methods[self._transport.update_inspect_template]
939
940        # Certain fields should be provided within the metadata header;
941        # add these here.
942        metadata = tuple(metadata) + (
943            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
944        )
945
946        # Send the request.
947        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
948
949        # Done; return the response.
950        return response
951
952    def get_inspect_template(
953        self,
954        request: Union[dlp.GetInspectTemplateRequest, dict] = None,
955        *,
956        name: str = None,
957        retry: OptionalRetry = gapic_v1.method.DEFAULT,
958        timeout: float = None,
959        metadata: Sequence[Tuple[str, str]] = (),
960    ) -> dlp.InspectTemplate:
961        r"""Gets an InspectTemplate.
962        See https://cloud.google.com/dlp/docs/creating-templates
963        to learn more.
964
965        Args:
966            request (Union[google.cloud.dlp_v2.types.GetInspectTemplateRequest, dict]):
967                The request object. Request message for
968                GetInspectTemplate.
969            name (str):
970                Required. Resource name of the organization and
971                inspectTemplate to be read, for example
972                ``organizations/433245324/inspectTemplates/432452342``
973                or projects/project-id/inspectTemplates/432452342.
974
975                This corresponds to the ``name`` field
976                on the ``request`` instance; if ``request`` is provided, this
977                should not be set.
978            retry (google.api_core.retry.Retry): Designation of what errors, if any,
979                should be retried.
980            timeout (float): The timeout for this request.
981            metadata (Sequence[Tuple[str, str]]): Strings which should be
982                sent along with the request as metadata.
983
984        Returns:
985            google.cloud.dlp_v2.types.InspectTemplate:
986                The inspectTemplate contains a
987                configuration (set of types of sensitive
988                data to be detected) to be used anywhere
989                you otherwise would normally specify
990                InspectConfig. See
991                https://cloud.google.com/dlp/docs/concepts-
992                templates to learn more.
993
994        """
995        # Create or coerce a protobuf request object.
996        # Sanity check: If we got a request object, we should *not* have
997        # gotten any keyword arguments that map to the request.
998        has_flattened_params = any([name])
999        if request is not None and has_flattened_params:
1000            raise ValueError(
1001                "If the `request` argument is set, then none of "
1002                "the individual field arguments should be set."
1003            )
1004
1005        # Minor optimization to avoid making a copy if the user passes
1006        # in a dlp.GetInspectTemplateRequest.
1007        # There's no risk of modifying the input as we've already verified
1008        # there are no flattened fields.
1009        if not isinstance(request, dlp.GetInspectTemplateRequest):
1010            request = dlp.GetInspectTemplateRequest(request)
1011            # If we have keyword arguments corresponding to fields on the
1012            # request, apply these.
1013            if name is not None:
1014                request.name = name
1015
1016        # Wrap the RPC method; this adds retry and timeout information,
1017        # and friendly error handling.
1018        rpc = self._transport._wrapped_methods[self._transport.get_inspect_template]
1019
1020        # Certain fields should be provided within the metadata header;
1021        # add these here.
1022        metadata = tuple(metadata) + (
1023            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1024        )
1025
1026        # Send the request.
1027        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1028
1029        # Done; return the response.
1030        return response
1031
1032    def list_inspect_templates(
1033        self,
1034        request: Union[dlp.ListInspectTemplatesRequest, dict] = None,
1035        *,
1036        parent: str = None,
1037        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1038        timeout: float = None,
1039        metadata: Sequence[Tuple[str, str]] = (),
1040    ) -> pagers.ListInspectTemplatesPager:
1041        r"""Lists InspectTemplates.
1042        See https://cloud.google.com/dlp/docs/creating-templates
1043        to learn more.
1044
1045        Args:
1046            request (Union[google.cloud.dlp_v2.types.ListInspectTemplatesRequest, dict]):
1047                The request object. Request message for
1048                ListInspectTemplates.
1049            parent (str):
1050                Required. Parent resource name.
1051
1052                The format of this value varies depending on the scope
1053                of the request (project or organization) and whether you
1054                have `specified a processing
1055                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
1056
1057                -  Projects scope, location specified:
1058                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
1059                -  Projects scope, no location specified (defaults to
1060                   global): ``projects/``\ PROJECT_ID
1061                -  Organizations scope, location specified:
1062                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
1063                -  Organizations scope, no location specified (defaults
1064                   to global): ``organizations/``\ ORG_ID
1065
1066                The following example ``parent`` string specifies a
1067                parent project with the identifier ``example-project``,
1068                and specifies the ``europe-west3`` location for
1069                processing data:
1070
1071                ::
1072
1073                    parent=projects/example-project/locations/europe-west3
1074
1075                This corresponds to the ``parent`` field
1076                on the ``request`` instance; if ``request`` is provided, this
1077                should not be set.
1078            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1079                should be retried.
1080            timeout (float): The timeout for this request.
1081            metadata (Sequence[Tuple[str, str]]): Strings which should be
1082                sent along with the request as metadata.
1083
1084        Returns:
1085            google.cloud.dlp_v2.services.dlp_service.pagers.ListInspectTemplatesPager:
1086                Response message for
1087                ListInspectTemplates.
1088                Iterating over this object will yield
1089                results and resolve additional pages
1090                automatically.
1091
1092        """
1093        # Create or coerce a protobuf request object.
1094        # Sanity check: If we got a request object, we should *not* have
1095        # gotten any keyword arguments that map to the request.
1096        has_flattened_params = any([parent])
1097        if request is not None and has_flattened_params:
1098            raise ValueError(
1099                "If the `request` argument is set, then none of "
1100                "the individual field arguments should be set."
1101            )
1102
1103        # Minor optimization to avoid making a copy if the user passes
1104        # in a dlp.ListInspectTemplatesRequest.
1105        # There's no risk of modifying the input as we've already verified
1106        # there are no flattened fields.
1107        if not isinstance(request, dlp.ListInspectTemplatesRequest):
1108            request = dlp.ListInspectTemplatesRequest(request)
1109            # If we have keyword arguments corresponding to fields on the
1110            # request, apply these.
1111            if parent is not None:
1112                request.parent = parent
1113
1114        # Wrap the RPC method; this adds retry and timeout information,
1115        # and friendly error handling.
1116        rpc = self._transport._wrapped_methods[self._transport.list_inspect_templates]
1117
1118        # Certain fields should be provided within the metadata header;
1119        # add these here.
1120        metadata = tuple(metadata) + (
1121            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1122        )
1123
1124        # Send the request.
1125        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1126
1127        # This method is paged; wrap the response in a pager, which provides
1128        # an `__iter__` convenience method.
1129        response = pagers.ListInspectTemplatesPager(
1130            method=rpc, request=request, response=response, metadata=metadata,
1131        )
1132
1133        # Done; return the response.
1134        return response
1135
1136    def delete_inspect_template(
1137        self,
1138        request: Union[dlp.DeleteInspectTemplateRequest, dict] = None,
1139        *,
1140        name: str = None,
1141        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1142        timeout: float = None,
1143        metadata: Sequence[Tuple[str, str]] = (),
1144    ) -> None:
1145        r"""Deletes an InspectTemplate.
1146        See https://cloud.google.com/dlp/docs/creating-templates
1147        to learn more.
1148
1149        Args:
1150            request (Union[google.cloud.dlp_v2.types.DeleteInspectTemplateRequest, dict]):
1151                The request object. Request message for
1152                DeleteInspectTemplate.
1153            name (str):
1154                Required. Resource name of the organization and
1155                inspectTemplate to be deleted, for example
1156                ``organizations/433245324/inspectTemplates/432452342``
1157                or projects/project-id/inspectTemplates/432452342.
1158
1159                This corresponds to the ``name`` field
1160                on the ``request`` instance; if ``request`` is provided, this
1161                should not be set.
1162            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1163                should be retried.
1164            timeout (float): The timeout for this request.
1165            metadata (Sequence[Tuple[str, str]]): Strings which should be
1166                sent along with the request as metadata.
1167        """
1168        # Create or coerce a protobuf request object.
1169        # Sanity check: If we got a request object, we should *not* have
1170        # gotten any keyword arguments that map to the request.
1171        has_flattened_params = any([name])
1172        if request is not None and has_flattened_params:
1173            raise ValueError(
1174                "If the `request` argument is set, then none of "
1175                "the individual field arguments should be set."
1176            )
1177
1178        # Minor optimization to avoid making a copy if the user passes
1179        # in a dlp.DeleteInspectTemplateRequest.
1180        # There's no risk of modifying the input as we've already verified
1181        # there are no flattened fields.
1182        if not isinstance(request, dlp.DeleteInspectTemplateRequest):
1183            request = dlp.DeleteInspectTemplateRequest(request)
1184            # If we have keyword arguments corresponding to fields on the
1185            # request, apply these.
1186            if name is not None:
1187                request.name = name
1188
1189        # Wrap the RPC method; this adds retry and timeout information,
1190        # and friendly error handling.
1191        rpc = self._transport._wrapped_methods[self._transport.delete_inspect_template]
1192
1193        # Certain fields should be provided within the metadata header;
1194        # add these here.
1195        metadata = tuple(metadata) + (
1196            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1197        )
1198
1199        # Send the request.
1200        rpc(
1201            request, retry=retry, timeout=timeout, metadata=metadata,
1202        )
1203
1204    def create_deidentify_template(
1205        self,
1206        request: Union[dlp.CreateDeidentifyTemplateRequest, dict] = None,
1207        *,
1208        parent: str = None,
1209        deidentify_template: dlp.DeidentifyTemplate = None,
1210        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1211        timeout: float = None,
1212        metadata: Sequence[Tuple[str, str]] = (),
1213    ) -> dlp.DeidentifyTemplate:
1214        r"""Creates a DeidentifyTemplate for re-using frequently
1215        used configuration for de-identifying content, images,
1216        and storage. See
1217        https://cloud.google.com/dlp/docs/creating-templates-
1218        deid to learn more.
1219
1220        Args:
1221            request (Union[google.cloud.dlp_v2.types.CreateDeidentifyTemplateRequest, dict]):
1222                The request object. Request message for
1223                CreateDeidentifyTemplate.
1224            parent (str):
1225                Required. Parent resource name.
1226
1227                The format of this value varies depending on the scope
1228                of the request (project or organization) and whether you
1229                have `specified a processing
1230                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
1231
1232                -  Projects scope, location specified:
1233                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
1234                -  Projects scope, no location specified (defaults to
1235                   global): ``projects/``\ PROJECT_ID
1236                -  Organizations scope, location specified:
1237                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
1238                -  Organizations scope, no location specified (defaults
1239                   to global): ``organizations/``\ ORG_ID
1240
1241                The following example ``parent`` string specifies a
1242                parent project with the identifier ``example-project``,
1243                and specifies the ``europe-west3`` location for
1244                processing data:
1245
1246                ::
1247
1248                    parent=projects/example-project/locations/europe-west3
1249
1250                This corresponds to the ``parent`` field
1251                on the ``request`` instance; if ``request`` is provided, this
1252                should not be set.
1253            deidentify_template (google.cloud.dlp_v2.types.DeidentifyTemplate):
1254                Required. The DeidentifyTemplate to
1255                create.
1256
1257                This corresponds to the ``deidentify_template`` field
1258                on the ``request`` instance; if ``request`` is provided, this
1259                should not be set.
1260            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1261                should be retried.
1262            timeout (float): The timeout for this request.
1263            metadata (Sequence[Tuple[str, str]]): Strings which should be
1264                sent along with the request as metadata.
1265
1266        Returns:
1267            google.cloud.dlp_v2.types.DeidentifyTemplate:
1268                DeidentifyTemplates contains
1269                instructions on how to de-identify
1270                content. See
1271                https://cloud.google.com/dlp/docs/concepts-
1272                templates to learn more.
1273
1274        """
1275        # Create or coerce a protobuf request object.
1276        # Sanity check: If we got a request object, we should *not* have
1277        # gotten any keyword arguments that map to the request.
1278        has_flattened_params = any([parent, deidentify_template])
1279        if request is not None and has_flattened_params:
1280            raise ValueError(
1281                "If the `request` argument is set, then none of "
1282                "the individual field arguments should be set."
1283            )
1284
1285        # Minor optimization to avoid making a copy if the user passes
1286        # in a dlp.CreateDeidentifyTemplateRequest.
1287        # There's no risk of modifying the input as we've already verified
1288        # there are no flattened fields.
1289        if not isinstance(request, dlp.CreateDeidentifyTemplateRequest):
1290            request = dlp.CreateDeidentifyTemplateRequest(request)
1291            # If we have keyword arguments corresponding to fields on the
1292            # request, apply these.
1293            if parent is not None:
1294                request.parent = parent
1295            if deidentify_template is not None:
1296                request.deidentify_template = deidentify_template
1297
1298        # Wrap the RPC method; this adds retry and timeout information,
1299        # and friendly error handling.
1300        rpc = self._transport._wrapped_methods[
1301            self._transport.create_deidentify_template
1302        ]
1303
1304        # Certain fields should be provided within the metadata header;
1305        # add these here.
1306        metadata = tuple(metadata) + (
1307            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1308        )
1309
1310        # Send the request.
1311        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1312
1313        # Done; return the response.
1314        return response
1315
1316    def update_deidentify_template(
1317        self,
1318        request: Union[dlp.UpdateDeidentifyTemplateRequest, dict] = None,
1319        *,
1320        name: str = None,
1321        deidentify_template: dlp.DeidentifyTemplate = None,
1322        update_mask: field_mask_pb2.FieldMask = None,
1323        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1324        timeout: float = None,
1325        metadata: Sequence[Tuple[str, str]] = (),
1326    ) -> dlp.DeidentifyTemplate:
1327        r"""Updates the DeidentifyTemplate.
1328        See https://cloud.google.com/dlp/docs/creating-
1329        templates-deid to learn more.
1330
1331        Args:
1332            request (Union[google.cloud.dlp_v2.types.UpdateDeidentifyTemplateRequest, dict]):
1333                The request object. Request message for
1334                UpdateDeidentifyTemplate.
1335            name (str):
1336                Required. Resource name of organization and deidentify
1337                template to be updated, for example
1338                ``organizations/433245324/deidentifyTemplates/432452342``
1339                or projects/project-id/deidentifyTemplates/432452342.
1340
1341                This corresponds to the ``name`` field
1342                on the ``request`` instance; if ``request`` is provided, this
1343                should not be set.
1344            deidentify_template (google.cloud.dlp_v2.types.DeidentifyTemplate):
1345                New DeidentifyTemplate value.
1346                This corresponds to the ``deidentify_template`` field
1347                on the ``request`` instance; if ``request`` is provided, this
1348                should not be set.
1349            update_mask (google.protobuf.field_mask_pb2.FieldMask):
1350                Mask to control which fields get
1351                updated.
1352
1353                This corresponds to the ``update_mask`` field
1354                on the ``request`` instance; if ``request`` is provided, this
1355                should not be set.
1356            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1357                should be retried.
1358            timeout (float): The timeout for this request.
1359            metadata (Sequence[Tuple[str, str]]): Strings which should be
1360                sent along with the request as metadata.
1361
1362        Returns:
1363            google.cloud.dlp_v2.types.DeidentifyTemplate:
1364                DeidentifyTemplates contains
1365                instructions on how to de-identify
1366                content. See
1367                https://cloud.google.com/dlp/docs/concepts-
1368                templates to learn more.
1369
1370        """
1371        # Create or coerce a protobuf request object.
1372        # Sanity check: If we got a request object, we should *not* have
1373        # gotten any keyword arguments that map to the request.
1374        has_flattened_params = any([name, deidentify_template, update_mask])
1375        if request is not None and has_flattened_params:
1376            raise ValueError(
1377                "If the `request` argument is set, then none of "
1378                "the individual field arguments should be set."
1379            )
1380
1381        # Minor optimization to avoid making a copy if the user passes
1382        # in a dlp.UpdateDeidentifyTemplateRequest.
1383        # There's no risk of modifying the input as we've already verified
1384        # there are no flattened fields.
1385        if not isinstance(request, dlp.UpdateDeidentifyTemplateRequest):
1386            request = dlp.UpdateDeidentifyTemplateRequest(request)
1387            # If we have keyword arguments corresponding to fields on the
1388            # request, apply these.
1389            if name is not None:
1390                request.name = name
1391            if deidentify_template is not None:
1392                request.deidentify_template = deidentify_template
1393            if update_mask is not None:
1394                request.update_mask = update_mask
1395
1396        # Wrap the RPC method; this adds retry and timeout information,
1397        # and friendly error handling.
1398        rpc = self._transport._wrapped_methods[
1399            self._transport.update_deidentify_template
1400        ]
1401
1402        # Certain fields should be provided within the metadata header;
1403        # add these here.
1404        metadata = tuple(metadata) + (
1405            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1406        )
1407
1408        # Send the request.
1409        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1410
1411        # Done; return the response.
1412        return response
1413
1414    def get_deidentify_template(
1415        self,
1416        request: Union[dlp.GetDeidentifyTemplateRequest, dict] = None,
1417        *,
1418        name: str = None,
1419        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1420        timeout: float = None,
1421        metadata: Sequence[Tuple[str, str]] = (),
1422    ) -> dlp.DeidentifyTemplate:
1423        r"""Gets a DeidentifyTemplate.
1424        See https://cloud.google.com/dlp/docs/creating-
1425        templates-deid to learn more.
1426
1427        Args:
1428            request (Union[google.cloud.dlp_v2.types.GetDeidentifyTemplateRequest, dict]):
1429                The request object. Request message for
1430                GetDeidentifyTemplate.
1431            name (str):
1432                Required. Resource name of the organization and
1433                deidentify template to be read, for example
1434                ``organizations/433245324/deidentifyTemplates/432452342``
1435                or projects/project-id/deidentifyTemplates/432452342.
1436
1437                This corresponds to the ``name`` field
1438                on the ``request`` instance; if ``request`` is provided, this
1439                should not be set.
1440            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1441                should be retried.
1442            timeout (float): The timeout for this request.
1443            metadata (Sequence[Tuple[str, str]]): Strings which should be
1444                sent along with the request as metadata.
1445
1446        Returns:
1447            google.cloud.dlp_v2.types.DeidentifyTemplate:
1448                DeidentifyTemplates contains
1449                instructions on how to de-identify
1450                content. See
1451                https://cloud.google.com/dlp/docs/concepts-
1452                templates to learn more.
1453
1454        """
1455        # Create or coerce a protobuf request object.
1456        # Sanity check: If we got a request object, we should *not* have
1457        # gotten any keyword arguments that map to the request.
1458        has_flattened_params = any([name])
1459        if request is not None and has_flattened_params:
1460            raise ValueError(
1461                "If the `request` argument is set, then none of "
1462                "the individual field arguments should be set."
1463            )
1464
1465        # Minor optimization to avoid making a copy if the user passes
1466        # in a dlp.GetDeidentifyTemplateRequest.
1467        # There's no risk of modifying the input as we've already verified
1468        # there are no flattened fields.
1469        if not isinstance(request, dlp.GetDeidentifyTemplateRequest):
1470            request = dlp.GetDeidentifyTemplateRequest(request)
1471            # If we have keyword arguments corresponding to fields on the
1472            # request, apply these.
1473            if name is not None:
1474                request.name = name
1475
1476        # Wrap the RPC method; this adds retry and timeout information,
1477        # and friendly error handling.
1478        rpc = self._transport._wrapped_methods[self._transport.get_deidentify_template]
1479
1480        # Certain fields should be provided within the metadata header;
1481        # add these here.
1482        metadata = tuple(metadata) + (
1483            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1484        )
1485
1486        # Send the request.
1487        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1488
1489        # Done; return the response.
1490        return response
1491
1492    def list_deidentify_templates(
1493        self,
1494        request: Union[dlp.ListDeidentifyTemplatesRequest, dict] = None,
1495        *,
1496        parent: str = None,
1497        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1498        timeout: float = None,
1499        metadata: Sequence[Tuple[str, str]] = (),
1500    ) -> pagers.ListDeidentifyTemplatesPager:
1501        r"""Lists DeidentifyTemplates.
1502        See https://cloud.google.com/dlp/docs/creating-
1503        templates-deid to learn more.
1504
1505        Args:
1506            request (Union[google.cloud.dlp_v2.types.ListDeidentifyTemplatesRequest, dict]):
1507                The request object. Request message for
1508                ListDeidentifyTemplates.
1509            parent (str):
1510                Required. Parent resource name.
1511
1512                The format of this value varies depending on the scope
1513                of the request (project or organization) and whether you
1514                have `specified a processing
1515                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
1516
1517                -  Projects scope, location specified:
1518                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
1519                -  Projects scope, no location specified (defaults to
1520                   global): ``projects/``\ PROJECT_ID
1521                -  Organizations scope, location specified:
1522                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
1523                -  Organizations scope, no location specified (defaults
1524                   to global): ``organizations/``\ ORG_ID
1525
1526                The following example ``parent`` string specifies a
1527                parent project with the identifier ``example-project``,
1528                and specifies the ``europe-west3`` location for
1529                processing data:
1530
1531                ::
1532
1533                    parent=projects/example-project/locations/europe-west3
1534
1535                This corresponds to the ``parent`` field
1536                on the ``request`` instance; if ``request`` is provided, this
1537                should not be set.
1538            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1539                should be retried.
1540            timeout (float): The timeout for this request.
1541            metadata (Sequence[Tuple[str, str]]): Strings which should be
1542                sent along with the request as metadata.
1543
1544        Returns:
1545            google.cloud.dlp_v2.services.dlp_service.pagers.ListDeidentifyTemplatesPager:
1546                Response message for
1547                ListDeidentifyTemplates.
1548                Iterating over this object will yield
1549                results and resolve additional pages
1550                automatically.
1551
1552        """
1553        # Create or coerce a protobuf request object.
1554        # Sanity check: If we got a request object, we should *not* have
1555        # gotten any keyword arguments that map to the request.
1556        has_flattened_params = any([parent])
1557        if request is not None and has_flattened_params:
1558            raise ValueError(
1559                "If the `request` argument is set, then none of "
1560                "the individual field arguments should be set."
1561            )
1562
1563        # Minor optimization to avoid making a copy if the user passes
1564        # in a dlp.ListDeidentifyTemplatesRequest.
1565        # There's no risk of modifying the input as we've already verified
1566        # there are no flattened fields.
1567        if not isinstance(request, dlp.ListDeidentifyTemplatesRequest):
1568            request = dlp.ListDeidentifyTemplatesRequest(request)
1569            # If we have keyword arguments corresponding to fields on the
1570            # request, apply these.
1571            if parent is not None:
1572                request.parent = parent
1573
1574        # Wrap the RPC method; this adds retry and timeout information,
1575        # and friendly error handling.
1576        rpc = self._transport._wrapped_methods[
1577            self._transport.list_deidentify_templates
1578        ]
1579
1580        # Certain fields should be provided within the metadata header;
1581        # add these here.
1582        metadata = tuple(metadata) + (
1583            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1584        )
1585
1586        # Send the request.
1587        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1588
1589        # This method is paged; wrap the response in a pager, which provides
1590        # an `__iter__` convenience method.
1591        response = pagers.ListDeidentifyTemplatesPager(
1592            method=rpc, request=request, response=response, metadata=metadata,
1593        )
1594
1595        # Done; return the response.
1596        return response
1597
1598    def delete_deidentify_template(
1599        self,
1600        request: Union[dlp.DeleteDeidentifyTemplateRequest, dict] = None,
1601        *,
1602        name: str = None,
1603        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1604        timeout: float = None,
1605        metadata: Sequence[Tuple[str, str]] = (),
1606    ) -> None:
1607        r"""Deletes a DeidentifyTemplate.
1608        See https://cloud.google.com/dlp/docs/creating-
1609        templates-deid to learn more.
1610
1611        Args:
1612            request (Union[google.cloud.dlp_v2.types.DeleteDeidentifyTemplateRequest, dict]):
1613                The request object. Request message for
1614                DeleteDeidentifyTemplate.
1615            name (str):
1616                Required. Resource name of the organization and
1617                deidentify template to be deleted, for example
1618                ``organizations/433245324/deidentifyTemplates/432452342``
1619                or projects/project-id/deidentifyTemplates/432452342.
1620
1621                This corresponds to the ``name`` field
1622                on the ``request`` instance; if ``request`` is provided, this
1623                should not be set.
1624            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1625                should be retried.
1626            timeout (float): The timeout for this request.
1627            metadata (Sequence[Tuple[str, str]]): Strings which should be
1628                sent along with the request as metadata.
1629        """
1630        # Create or coerce a protobuf request object.
1631        # Sanity check: If we got a request object, we should *not* have
1632        # gotten any keyword arguments that map to the request.
1633        has_flattened_params = any([name])
1634        if request is not None and has_flattened_params:
1635            raise ValueError(
1636                "If the `request` argument is set, then none of "
1637                "the individual field arguments should be set."
1638            )
1639
1640        # Minor optimization to avoid making a copy if the user passes
1641        # in a dlp.DeleteDeidentifyTemplateRequest.
1642        # There's no risk of modifying the input as we've already verified
1643        # there are no flattened fields.
1644        if not isinstance(request, dlp.DeleteDeidentifyTemplateRequest):
1645            request = dlp.DeleteDeidentifyTemplateRequest(request)
1646            # If we have keyword arguments corresponding to fields on the
1647            # request, apply these.
1648            if name is not None:
1649                request.name = name
1650
1651        # Wrap the RPC method; this adds retry and timeout information,
1652        # and friendly error handling.
1653        rpc = self._transport._wrapped_methods[
1654            self._transport.delete_deidentify_template
1655        ]
1656
1657        # Certain fields should be provided within the metadata header;
1658        # add these here.
1659        metadata = tuple(metadata) + (
1660            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1661        )
1662
1663        # Send the request.
1664        rpc(
1665            request, retry=retry, timeout=timeout, metadata=metadata,
1666        )
1667
1668    def create_job_trigger(
1669        self,
1670        request: Union[dlp.CreateJobTriggerRequest, dict] = None,
1671        *,
1672        parent: str = None,
1673        job_trigger: dlp.JobTrigger = None,
1674        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1675        timeout: float = None,
1676        metadata: Sequence[Tuple[str, str]] = (),
1677    ) -> dlp.JobTrigger:
1678        r"""Creates a job trigger to run DLP actions such as
1679        scanning storage for sensitive information on a set
1680        schedule. See
1681        https://cloud.google.com/dlp/docs/creating-job-triggers
1682        to learn more.
1683
1684        Args:
1685            request (Union[google.cloud.dlp_v2.types.CreateJobTriggerRequest, dict]):
1686                The request object. Request message for
1687                CreateJobTrigger.
1688            parent (str):
1689                Required. Parent resource name.
1690
1691                The format of this value varies depending on whether you
1692                have `specified a processing
1693                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
1694
1695                -  Projects scope, location specified:
1696                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
1697                -  Projects scope, no location specified (defaults to
1698                   global): ``projects/``\ PROJECT_ID
1699
1700                The following example ``parent`` string specifies a
1701                parent project with the identifier ``example-project``,
1702                and specifies the ``europe-west3`` location for
1703                processing data:
1704
1705                ::
1706
1707                    parent=projects/example-project/locations/europe-west3
1708
1709                This corresponds to the ``parent`` field
1710                on the ``request`` instance; if ``request`` is provided, this
1711                should not be set.
1712            job_trigger (google.cloud.dlp_v2.types.JobTrigger):
1713                Required. The JobTrigger to create.
1714                This corresponds to the ``job_trigger`` field
1715                on the ``request`` instance; if ``request`` is provided, this
1716                should not be set.
1717            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1718                should be retried.
1719            timeout (float): The timeout for this request.
1720            metadata (Sequence[Tuple[str, str]]): Strings which should be
1721                sent along with the request as metadata.
1722
1723        Returns:
1724            google.cloud.dlp_v2.types.JobTrigger:
1725                Contains a configuration to make dlp
1726                api calls on a repeating basis. See
1727                https://cloud.google.com/dlp/docs/concepts-
1728                job-triggers to learn more.
1729
1730        """
1731        # Create or coerce a protobuf request object.
1732        # Sanity check: If we got a request object, we should *not* have
1733        # gotten any keyword arguments that map to the request.
1734        has_flattened_params = any([parent, job_trigger])
1735        if request is not None and has_flattened_params:
1736            raise ValueError(
1737                "If the `request` argument is set, then none of "
1738                "the individual field arguments should be set."
1739            )
1740
1741        # Minor optimization to avoid making a copy if the user passes
1742        # in a dlp.CreateJobTriggerRequest.
1743        # There's no risk of modifying the input as we've already verified
1744        # there are no flattened fields.
1745        if not isinstance(request, dlp.CreateJobTriggerRequest):
1746            request = dlp.CreateJobTriggerRequest(request)
1747            # If we have keyword arguments corresponding to fields on the
1748            # request, apply these.
1749            if parent is not None:
1750                request.parent = parent
1751            if job_trigger is not None:
1752                request.job_trigger = job_trigger
1753
1754        # Wrap the RPC method; this adds retry and timeout information,
1755        # and friendly error handling.
1756        rpc = self._transport._wrapped_methods[self._transport.create_job_trigger]
1757
1758        # Certain fields should be provided within the metadata header;
1759        # add these here.
1760        metadata = tuple(metadata) + (
1761            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1762        )
1763
1764        # Send the request.
1765        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1766
1767        # Done; return the response.
1768        return response
1769
1770    def update_job_trigger(
1771        self,
1772        request: Union[dlp.UpdateJobTriggerRequest, dict] = None,
1773        *,
1774        name: str = None,
1775        job_trigger: dlp.JobTrigger = None,
1776        update_mask: field_mask_pb2.FieldMask = None,
1777        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1778        timeout: float = None,
1779        metadata: Sequence[Tuple[str, str]] = (),
1780    ) -> dlp.JobTrigger:
1781        r"""Updates a job trigger.
1782        See https://cloud.google.com/dlp/docs/creating-job-
1783        triggers to learn more.
1784
1785        Args:
1786            request (Union[google.cloud.dlp_v2.types.UpdateJobTriggerRequest, dict]):
1787                The request object. Request message for
1788                UpdateJobTrigger.
1789            name (str):
1790                Required. Resource name of the project and the
1791                triggeredJob, for example
1792                ``projects/dlp-test-project/jobTriggers/53234423``.
1793
1794                This corresponds to the ``name`` field
1795                on the ``request`` instance; if ``request`` is provided, this
1796                should not be set.
1797            job_trigger (google.cloud.dlp_v2.types.JobTrigger):
1798                New JobTrigger value.
1799                This corresponds to the ``job_trigger`` field
1800                on the ``request`` instance; if ``request`` is provided, this
1801                should not be set.
1802            update_mask (google.protobuf.field_mask_pb2.FieldMask):
1803                Mask to control which fields get
1804                updated.
1805
1806                This corresponds to the ``update_mask`` field
1807                on the ``request`` instance; if ``request`` is provided, this
1808                should not be set.
1809            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1810                should be retried.
1811            timeout (float): The timeout for this request.
1812            metadata (Sequence[Tuple[str, str]]): Strings which should be
1813                sent along with the request as metadata.
1814
1815        Returns:
1816            google.cloud.dlp_v2.types.JobTrigger:
1817                Contains a configuration to make dlp
1818                api calls on a repeating basis. See
1819                https://cloud.google.com/dlp/docs/concepts-
1820                job-triggers to learn more.
1821
1822        """
1823        # Create or coerce a protobuf request object.
1824        # Sanity check: If we got a request object, we should *not* have
1825        # gotten any keyword arguments that map to the request.
1826        has_flattened_params = any([name, job_trigger, update_mask])
1827        if request is not None and has_flattened_params:
1828            raise ValueError(
1829                "If the `request` argument is set, then none of "
1830                "the individual field arguments should be set."
1831            )
1832
1833        # Minor optimization to avoid making a copy if the user passes
1834        # in a dlp.UpdateJobTriggerRequest.
1835        # There's no risk of modifying the input as we've already verified
1836        # there are no flattened fields.
1837        if not isinstance(request, dlp.UpdateJobTriggerRequest):
1838            request = dlp.UpdateJobTriggerRequest(request)
1839            # If we have keyword arguments corresponding to fields on the
1840            # request, apply these.
1841            if name is not None:
1842                request.name = name
1843            if job_trigger is not None:
1844                request.job_trigger = job_trigger
1845            if update_mask is not None:
1846                request.update_mask = update_mask
1847
1848        # Wrap the RPC method; this adds retry and timeout information,
1849        # and friendly error handling.
1850        rpc = self._transport._wrapped_methods[self._transport.update_job_trigger]
1851
1852        # Certain fields should be provided within the metadata header;
1853        # add these here.
1854        metadata = tuple(metadata) + (
1855            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1856        )
1857
1858        # Send the request.
1859        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1860
1861        # Done; return the response.
1862        return response
1863
1864    def hybrid_inspect_job_trigger(
1865        self,
1866        request: Union[dlp.HybridInspectJobTriggerRequest, dict] = None,
1867        *,
1868        name: str = None,
1869        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1870        timeout: float = None,
1871        metadata: Sequence[Tuple[str, str]] = (),
1872    ) -> dlp.HybridInspectResponse:
1873        r"""Inspect hybrid content and store findings to a
1874        trigger. The inspection will be processed
1875        asynchronously. To review the findings monitor the jobs
1876        within the trigger.
1877        Early access feature is in a pre-release state and might
1878        change or have limited support. For more information,
1879        see
1880        https://cloud.google.com/products#product-launch-stages.
1881
1882        Args:
1883            request (Union[google.cloud.dlp_v2.types.HybridInspectJobTriggerRequest, dict]):
1884                The request object. Request to search for potentially
1885                sensitive info in a custom location.
1886            name (str):
1887                Required. Resource name of the trigger to execute a
1888                hybrid inspect on, for example
1889                ``projects/dlp-test-project/jobTriggers/53234423``.
1890
1891                This corresponds to the ``name`` field
1892                on the ``request`` instance; if ``request`` is provided, this
1893                should not be set.
1894            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1895                should be retried.
1896            timeout (float): The timeout for this request.
1897            metadata (Sequence[Tuple[str, str]]): Strings which should be
1898                sent along with the request as metadata.
1899
1900        Returns:
1901            google.cloud.dlp_v2.types.HybridInspectResponse:
1902                Quota exceeded errors will be thrown
1903                once quota has been met.
1904
1905        """
1906        # Create or coerce a protobuf request object.
1907        # Sanity check: If we got a request object, we should *not* have
1908        # gotten any keyword arguments that map to the request.
1909        has_flattened_params = any([name])
1910        if request is not None and has_flattened_params:
1911            raise ValueError(
1912                "If the `request` argument is set, then none of "
1913                "the individual field arguments should be set."
1914            )
1915
1916        # Minor optimization to avoid making a copy if the user passes
1917        # in a dlp.HybridInspectJobTriggerRequest.
1918        # There's no risk of modifying the input as we've already verified
1919        # there are no flattened fields.
1920        if not isinstance(request, dlp.HybridInspectJobTriggerRequest):
1921            request = dlp.HybridInspectJobTriggerRequest(request)
1922            # If we have keyword arguments corresponding to fields on the
1923            # request, apply these.
1924            if name is not None:
1925                request.name = name
1926
1927        # Wrap the RPC method; this adds retry and timeout information,
1928        # and friendly error handling.
1929        rpc = self._transport._wrapped_methods[
1930            self._transport.hybrid_inspect_job_trigger
1931        ]
1932
1933        # Certain fields should be provided within the metadata header;
1934        # add these here.
1935        metadata = tuple(metadata) + (
1936            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1937        )
1938
1939        # Send the request.
1940        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
1941
1942        # Done; return the response.
1943        return response
1944
1945    def get_job_trigger(
1946        self,
1947        request: Union[dlp.GetJobTriggerRequest, dict] = None,
1948        *,
1949        name: str = None,
1950        retry: OptionalRetry = gapic_v1.method.DEFAULT,
1951        timeout: float = None,
1952        metadata: Sequence[Tuple[str, str]] = (),
1953    ) -> dlp.JobTrigger:
1954        r"""Gets a job trigger.
1955        See https://cloud.google.com/dlp/docs/creating-job-
1956        triggers to learn more.
1957
1958        Args:
1959            request (Union[google.cloud.dlp_v2.types.GetJobTriggerRequest, dict]):
1960                The request object. Request message for GetJobTrigger.
1961            name (str):
1962                Required. Resource name of the project and the
1963                triggeredJob, for example
1964                ``projects/dlp-test-project/jobTriggers/53234423``.
1965
1966                This corresponds to the ``name`` field
1967                on the ``request`` instance; if ``request`` is provided, this
1968                should not be set.
1969            retry (google.api_core.retry.Retry): Designation of what errors, if any,
1970                should be retried.
1971            timeout (float): The timeout for this request.
1972            metadata (Sequence[Tuple[str, str]]): Strings which should be
1973                sent along with the request as metadata.
1974
1975        Returns:
1976            google.cloud.dlp_v2.types.JobTrigger:
1977                Contains a configuration to make dlp
1978                api calls on a repeating basis. See
1979                https://cloud.google.com/dlp/docs/concepts-
1980                job-triggers to learn more.
1981
1982        """
1983        # Create or coerce a protobuf request object.
1984        # Sanity check: If we got a request object, we should *not* have
1985        # gotten any keyword arguments that map to the request.
1986        has_flattened_params = any([name])
1987        if request is not None and has_flattened_params:
1988            raise ValueError(
1989                "If the `request` argument is set, then none of "
1990                "the individual field arguments should be set."
1991            )
1992
1993        # Minor optimization to avoid making a copy if the user passes
1994        # in a dlp.GetJobTriggerRequest.
1995        # There's no risk of modifying the input as we've already verified
1996        # there are no flattened fields.
1997        if not isinstance(request, dlp.GetJobTriggerRequest):
1998            request = dlp.GetJobTriggerRequest(request)
1999            # If we have keyword arguments corresponding to fields on the
2000            # request, apply these.
2001            if name is not None:
2002                request.name = name
2003
2004        # Wrap the RPC method; this adds retry and timeout information,
2005        # and friendly error handling.
2006        rpc = self._transport._wrapped_methods[self._transport.get_job_trigger]
2007
2008        # Certain fields should be provided within the metadata header;
2009        # add these here.
2010        metadata = tuple(metadata) + (
2011            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2012        )
2013
2014        # Send the request.
2015        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2016
2017        # Done; return the response.
2018        return response
2019
2020    def list_job_triggers(
2021        self,
2022        request: Union[dlp.ListJobTriggersRequest, dict] = None,
2023        *,
2024        parent: str = None,
2025        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2026        timeout: float = None,
2027        metadata: Sequence[Tuple[str, str]] = (),
2028    ) -> pagers.ListJobTriggersPager:
2029        r"""Lists job triggers.
2030        See https://cloud.google.com/dlp/docs/creating-job-
2031        triggers to learn more.
2032
2033        Args:
2034            request (Union[google.cloud.dlp_v2.types.ListJobTriggersRequest, dict]):
2035                The request object. Request message for ListJobTriggers.
2036            parent (str):
2037                Required. Parent resource name.
2038
2039                The format of this value varies depending on whether you
2040                have `specified a processing
2041                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
2042
2043                -  Projects scope, location specified:
2044                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
2045                -  Projects scope, no location specified (defaults to
2046                   global): ``projects/``\ PROJECT_ID
2047
2048                The following example ``parent`` string specifies a
2049                parent project with the identifier ``example-project``,
2050                and specifies the ``europe-west3`` location for
2051                processing data:
2052
2053                ::
2054
2055                    parent=projects/example-project/locations/europe-west3
2056
2057                This corresponds to the ``parent`` field
2058                on the ``request`` instance; if ``request`` is provided, this
2059                should not be set.
2060            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2061                should be retried.
2062            timeout (float): The timeout for this request.
2063            metadata (Sequence[Tuple[str, str]]): Strings which should be
2064                sent along with the request as metadata.
2065
2066        Returns:
2067            google.cloud.dlp_v2.services.dlp_service.pagers.ListJobTriggersPager:
2068                Response message for ListJobTriggers.
2069                Iterating over this object will yield
2070                results and resolve additional pages
2071                automatically.
2072
2073        """
2074        # Create or coerce a protobuf request object.
2075        # Sanity check: If we got a request object, we should *not* have
2076        # gotten any keyword arguments that map to the request.
2077        has_flattened_params = any([parent])
2078        if request is not None and has_flattened_params:
2079            raise ValueError(
2080                "If the `request` argument is set, then none of "
2081                "the individual field arguments should be set."
2082            )
2083
2084        # Minor optimization to avoid making a copy if the user passes
2085        # in a dlp.ListJobTriggersRequest.
2086        # There's no risk of modifying the input as we've already verified
2087        # there are no flattened fields.
2088        if not isinstance(request, dlp.ListJobTriggersRequest):
2089            request = dlp.ListJobTriggersRequest(request)
2090            # If we have keyword arguments corresponding to fields on the
2091            # request, apply these.
2092            if parent is not None:
2093                request.parent = parent
2094
2095        # Wrap the RPC method; this adds retry and timeout information,
2096        # and friendly error handling.
2097        rpc = self._transport._wrapped_methods[self._transport.list_job_triggers]
2098
2099        # Certain fields should be provided within the metadata header;
2100        # add these here.
2101        metadata = tuple(metadata) + (
2102            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2103        )
2104
2105        # Send the request.
2106        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2107
2108        # This method is paged; wrap the response in a pager, which provides
2109        # an `__iter__` convenience method.
2110        response = pagers.ListJobTriggersPager(
2111            method=rpc, request=request, response=response, metadata=metadata,
2112        )
2113
2114        # Done; return the response.
2115        return response
2116
2117    def delete_job_trigger(
2118        self,
2119        request: Union[dlp.DeleteJobTriggerRequest, dict] = None,
2120        *,
2121        name: str = None,
2122        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2123        timeout: float = None,
2124        metadata: Sequence[Tuple[str, str]] = (),
2125    ) -> None:
2126        r"""Deletes a job trigger.
2127        See https://cloud.google.com/dlp/docs/creating-job-
2128        triggers to learn more.
2129
2130        Args:
2131            request (Union[google.cloud.dlp_v2.types.DeleteJobTriggerRequest, dict]):
2132                The request object. Request message for
2133                DeleteJobTrigger.
2134            name (str):
2135                Required. Resource name of the project and the
2136                triggeredJob, for example
2137                ``projects/dlp-test-project/jobTriggers/53234423``.
2138
2139                This corresponds to the ``name`` field
2140                on the ``request`` instance; if ``request`` is provided, this
2141                should not be set.
2142            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2143                should be retried.
2144            timeout (float): The timeout for this request.
2145            metadata (Sequence[Tuple[str, str]]): Strings which should be
2146                sent along with the request as metadata.
2147        """
2148        # Create or coerce a protobuf request object.
2149        # Sanity check: If we got a request object, we should *not* have
2150        # gotten any keyword arguments that map to the request.
2151        has_flattened_params = any([name])
2152        if request is not None and has_flattened_params:
2153            raise ValueError(
2154                "If the `request` argument is set, then none of "
2155                "the individual field arguments should be set."
2156            )
2157
2158        # Minor optimization to avoid making a copy if the user passes
2159        # in a dlp.DeleteJobTriggerRequest.
2160        # There's no risk of modifying the input as we've already verified
2161        # there are no flattened fields.
2162        if not isinstance(request, dlp.DeleteJobTriggerRequest):
2163            request = dlp.DeleteJobTriggerRequest(request)
2164            # If we have keyword arguments corresponding to fields on the
2165            # request, apply these.
2166            if name is not None:
2167                request.name = name
2168
2169        # Wrap the RPC method; this adds retry and timeout information,
2170        # and friendly error handling.
2171        rpc = self._transport._wrapped_methods[self._transport.delete_job_trigger]
2172
2173        # Certain fields should be provided within the metadata header;
2174        # add these here.
2175        metadata = tuple(metadata) + (
2176            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2177        )
2178
2179        # Send the request.
2180        rpc(
2181            request, retry=retry, timeout=timeout, metadata=metadata,
2182        )
2183
2184    def activate_job_trigger(
2185        self,
2186        request: Union[dlp.ActivateJobTriggerRequest, dict] = None,
2187        *,
2188        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2189        timeout: float = None,
2190        metadata: Sequence[Tuple[str, str]] = (),
2191    ) -> dlp.DlpJob:
2192        r"""Activate a job trigger. Causes the immediate execute
2193        of a trigger instead of waiting on the trigger event to
2194        occur.
2195
2196        Args:
2197            request (Union[google.cloud.dlp_v2.types.ActivateJobTriggerRequest, dict]):
2198                The request object. Request message for
2199                ActivateJobTrigger.
2200            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2201                should be retried.
2202            timeout (float): The timeout for this request.
2203            metadata (Sequence[Tuple[str, str]]): Strings which should be
2204                sent along with the request as metadata.
2205
2206        Returns:
2207            google.cloud.dlp_v2.types.DlpJob:
2208                Combines all of the information about
2209                a DLP job.
2210
2211        """
2212        # Create or coerce a protobuf request object.
2213        # Minor optimization to avoid making a copy if the user passes
2214        # in a dlp.ActivateJobTriggerRequest.
2215        # There's no risk of modifying the input as we've already verified
2216        # there are no flattened fields.
2217        if not isinstance(request, dlp.ActivateJobTriggerRequest):
2218            request = dlp.ActivateJobTriggerRequest(request)
2219
2220        # Wrap the RPC method; this adds retry and timeout information,
2221        # and friendly error handling.
2222        rpc = self._transport._wrapped_methods[self._transport.activate_job_trigger]
2223
2224        # Certain fields should be provided within the metadata header;
2225        # add these here.
2226        metadata = tuple(metadata) + (
2227            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2228        )
2229
2230        # Send the request.
2231        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2232
2233        # Done; return the response.
2234        return response
2235
2236    def create_dlp_job(
2237        self,
2238        request: Union[dlp.CreateDlpJobRequest, dict] = None,
2239        *,
2240        parent: str = None,
2241        inspect_job: dlp.InspectJobConfig = None,
2242        risk_job: dlp.RiskAnalysisJobConfig = None,
2243        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2244        timeout: float = None,
2245        metadata: Sequence[Tuple[str, str]] = (),
2246    ) -> dlp.DlpJob:
2247        r"""Creates a new job to inspect storage or calculate
2248        risk metrics. See
2249        https://cloud.google.com/dlp/docs/inspecting-storage and
2250        https://cloud.google.com/dlp/docs/compute-risk-analysis
2251        to learn more.
2252        When no InfoTypes or CustomInfoTypes are specified in
2253        inspect jobs, the system will automatically choose what
2254        detectors to run. By default this may be all types, but
2255        may change over time as detectors are updated.
2256
2257        Args:
2258            request (Union[google.cloud.dlp_v2.types.CreateDlpJobRequest, dict]):
2259                The request object. Request message for
2260                CreateDlpJobRequest. Used to initiate long running jobs
2261                such as calculating risk metrics or inspecting Google
2262                Cloud Storage.
2263            parent (str):
2264                Required. Parent resource name.
2265
2266                The format of this value varies depending on whether you
2267                have `specified a processing
2268                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
2269
2270                -  Projects scope, location specified:
2271                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
2272                -  Projects scope, no location specified (defaults to
2273                   global): ``projects/``\ PROJECT_ID
2274
2275                The following example ``parent`` string specifies a
2276                parent project with the identifier ``example-project``,
2277                and specifies the ``europe-west3`` location for
2278                processing data:
2279
2280                ::
2281
2282                    parent=projects/example-project/locations/europe-west3
2283
2284                This corresponds to the ``parent`` field
2285                on the ``request`` instance; if ``request`` is provided, this
2286                should not be set.
2287            inspect_job (google.cloud.dlp_v2.types.InspectJobConfig):
2288                Set to control what and how to
2289                inspect.
2290
2291                This corresponds to the ``inspect_job`` field
2292                on the ``request`` instance; if ``request`` is provided, this
2293                should not be set.
2294            risk_job (google.cloud.dlp_v2.types.RiskAnalysisJobConfig):
2295                Set to choose what metric to
2296                calculate.
2297
2298                This corresponds to the ``risk_job`` field
2299                on the ``request`` instance; if ``request`` is provided, this
2300                should not be set.
2301            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2302                should be retried.
2303            timeout (float): The timeout for this request.
2304            metadata (Sequence[Tuple[str, str]]): Strings which should be
2305                sent along with the request as metadata.
2306
2307        Returns:
2308            google.cloud.dlp_v2.types.DlpJob:
2309                Combines all of the information about
2310                a DLP job.
2311
2312        """
2313        # Create or coerce a protobuf request object.
2314        # Sanity check: If we got a request object, we should *not* have
2315        # gotten any keyword arguments that map to the request.
2316        has_flattened_params = any([parent, inspect_job, risk_job])
2317        if request is not None and has_flattened_params:
2318            raise ValueError(
2319                "If the `request` argument is set, then none of "
2320                "the individual field arguments should be set."
2321            )
2322
2323        # Minor optimization to avoid making a copy if the user passes
2324        # in a dlp.CreateDlpJobRequest.
2325        # There's no risk of modifying the input as we've already verified
2326        # there are no flattened fields.
2327        if not isinstance(request, dlp.CreateDlpJobRequest):
2328            request = dlp.CreateDlpJobRequest(request)
2329            # If we have keyword arguments corresponding to fields on the
2330            # request, apply these.
2331            if parent is not None:
2332                request.parent = parent
2333            if inspect_job is not None:
2334                request.inspect_job = inspect_job
2335            if risk_job is not None:
2336                request.risk_job = risk_job
2337
2338        # Wrap the RPC method; this adds retry and timeout information,
2339        # and friendly error handling.
2340        rpc = self._transport._wrapped_methods[self._transport.create_dlp_job]
2341
2342        # Certain fields should be provided within the metadata header;
2343        # add these here.
2344        metadata = tuple(metadata) + (
2345            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2346        )
2347
2348        # Send the request.
2349        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2350
2351        # Done; return the response.
2352        return response
2353
2354    def list_dlp_jobs(
2355        self,
2356        request: Union[dlp.ListDlpJobsRequest, dict] = None,
2357        *,
2358        parent: str = None,
2359        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2360        timeout: float = None,
2361        metadata: Sequence[Tuple[str, str]] = (),
2362    ) -> pagers.ListDlpJobsPager:
2363        r"""Lists DlpJobs that match the specified filter in the
2364        request. See
2365        https://cloud.google.com/dlp/docs/inspecting-storage and
2366        https://cloud.google.com/dlp/docs/compute-risk-analysis
2367        to learn more.
2368
2369        Args:
2370            request (Union[google.cloud.dlp_v2.types.ListDlpJobsRequest, dict]):
2371                The request object. The request message for listing DLP
2372                jobs.
2373            parent (str):
2374                Required. Parent resource name.
2375
2376                The format of this value varies depending on whether you
2377                have `specified a processing
2378                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
2379
2380                -  Projects scope, location specified:
2381                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
2382                -  Projects scope, no location specified (defaults to
2383                   global): ``projects/``\ PROJECT_ID
2384
2385                The following example ``parent`` string specifies a
2386                parent project with the identifier ``example-project``,
2387                and specifies the ``europe-west3`` location for
2388                processing data:
2389
2390                ::
2391
2392                    parent=projects/example-project/locations/europe-west3
2393
2394                This corresponds to the ``parent`` field
2395                on the ``request`` instance; if ``request`` is provided, this
2396                should not be set.
2397            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2398                should be retried.
2399            timeout (float): The timeout for this request.
2400            metadata (Sequence[Tuple[str, str]]): Strings which should be
2401                sent along with the request as metadata.
2402
2403        Returns:
2404            google.cloud.dlp_v2.services.dlp_service.pagers.ListDlpJobsPager:
2405                The response message for listing DLP
2406                jobs.
2407                Iterating over this object will yield
2408                results and resolve additional pages
2409                automatically.
2410
2411        """
2412        # Create or coerce a protobuf request object.
2413        # Sanity check: If we got a request object, we should *not* have
2414        # gotten any keyword arguments that map to the request.
2415        has_flattened_params = any([parent])
2416        if request is not None and has_flattened_params:
2417            raise ValueError(
2418                "If the `request` argument is set, then none of "
2419                "the individual field arguments should be set."
2420            )
2421
2422        # Minor optimization to avoid making a copy if the user passes
2423        # in a dlp.ListDlpJobsRequest.
2424        # There's no risk of modifying the input as we've already verified
2425        # there are no flattened fields.
2426        if not isinstance(request, dlp.ListDlpJobsRequest):
2427            request = dlp.ListDlpJobsRequest(request)
2428            # If we have keyword arguments corresponding to fields on the
2429            # request, apply these.
2430            if parent is not None:
2431                request.parent = parent
2432
2433        # Wrap the RPC method; this adds retry and timeout information,
2434        # and friendly error handling.
2435        rpc = self._transport._wrapped_methods[self._transport.list_dlp_jobs]
2436
2437        # Certain fields should be provided within the metadata header;
2438        # add these here.
2439        metadata = tuple(metadata) + (
2440            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2441        )
2442
2443        # Send the request.
2444        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2445
2446        # This method is paged; wrap the response in a pager, which provides
2447        # an `__iter__` convenience method.
2448        response = pagers.ListDlpJobsPager(
2449            method=rpc, request=request, response=response, metadata=metadata,
2450        )
2451
2452        # Done; return the response.
2453        return response
2454
2455    def get_dlp_job(
2456        self,
2457        request: Union[dlp.GetDlpJobRequest, dict] = None,
2458        *,
2459        name: str = None,
2460        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2461        timeout: float = None,
2462        metadata: Sequence[Tuple[str, str]] = (),
2463    ) -> dlp.DlpJob:
2464        r"""Gets the latest state of a long-running DlpJob.
2465        See https://cloud.google.com/dlp/docs/inspecting-storage
2466        and https://cloud.google.com/dlp/docs/compute-risk-
2467        analysis to learn more.
2468
2469        Args:
2470            request (Union[google.cloud.dlp_v2.types.GetDlpJobRequest, dict]):
2471                The request object. The request message for
2472                [DlpJobs.GetDlpJob][].
2473            name (str):
2474                Required. The name of the DlpJob
2475                resource.
2476
2477                This corresponds to the ``name`` field
2478                on the ``request`` instance; if ``request`` is provided, this
2479                should not be set.
2480            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2481                should be retried.
2482            timeout (float): The timeout for this request.
2483            metadata (Sequence[Tuple[str, str]]): Strings which should be
2484                sent along with the request as metadata.
2485
2486        Returns:
2487            google.cloud.dlp_v2.types.DlpJob:
2488                Combines all of the information about
2489                a DLP job.
2490
2491        """
2492        # Create or coerce a protobuf request object.
2493        # Sanity check: If we got a request object, we should *not* have
2494        # gotten any keyword arguments that map to the request.
2495        has_flattened_params = any([name])
2496        if request is not None and has_flattened_params:
2497            raise ValueError(
2498                "If the `request` argument is set, then none of "
2499                "the individual field arguments should be set."
2500            )
2501
2502        # Minor optimization to avoid making a copy if the user passes
2503        # in a dlp.GetDlpJobRequest.
2504        # There's no risk of modifying the input as we've already verified
2505        # there are no flattened fields.
2506        if not isinstance(request, dlp.GetDlpJobRequest):
2507            request = dlp.GetDlpJobRequest(request)
2508            # If we have keyword arguments corresponding to fields on the
2509            # request, apply these.
2510            if name is not None:
2511                request.name = name
2512
2513        # Wrap the RPC method; this adds retry and timeout information,
2514        # and friendly error handling.
2515        rpc = self._transport._wrapped_methods[self._transport.get_dlp_job]
2516
2517        # Certain fields should be provided within the metadata header;
2518        # add these here.
2519        metadata = tuple(metadata) + (
2520            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2521        )
2522
2523        # Send the request.
2524        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2525
2526        # Done; return the response.
2527        return response
2528
2529    def delete_dlp_job(
2530        self,
2531        request: Union[dlp.DeleteDlpJobRequest, dict] = None,
2532        *,
2533        name: str = None,
2534        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2535        timeout: float = None,
2536        metadata: Sequence[Tuple[str, str]] = (),
2537    ) -> None:
2538        r"""Deletes a long-running DlpJob. This method indicates
2539        that the client is no longer interested in the DlpJob
2540        result. The job will be cancelled if possible.
2541        See https://cloud.google.com/dlp/docs/inspecting-storage
2542        and https://cloud.google.com/dlp/docs/compute-risk-
2543        analysis to learn more.
2544
2545        Args:
2546            request (Union[google.cloud.dlp_v2.types.DeleteDlpJobRequest, dict]):
2547                The request object. The request message for deleting a
2548                DLP job.
2549            name (str):
2550                Required. The name of the DlpJob
2551                resource to be deleted.
2552
2553                This corresponds to the ``name`` field
2554                on the ``request`` instance; if ``request`` is provided, this
2555                should not be set.
2556            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2557                should be retried.
2558            timeout (float): The timeout for this request.
2559            metadata (Sequence[Tuple[str, str]]): Strings which should be
2560                sent along with the request as metadata.
2561        """
2562        # Create or coerce a protobuf request object.
2563        # Sanity check: If we got a request object, we should *not* have
2564        # gotten any keyword arguments that map to the request.
2565        has_flattened_params = any([name])
2566        if request is not None and has_flattened_params:
2567            raise ValueError(
2568                "If the `request` argument is set, then none of "
2569                "the individual field arguments should be set."
2570            )
2571
2572        # Minor optimization to avoid making a copy if the user passes
2573        # in a dlp.DeleteDlpJobRequest.
2574        # There's no risk of modifying the input as we've already verified
2575        # there are no flattened fields.
2576        if not isinstance(request, dlp.DeleteDlpJobRequest):
2577            request = dlp.DeleteDlpJobRequest(request)
2578            # If we have keyword arguments corresponding to fields on the
2579            # request, apply these.
2580            if name is not None:
2581                request.name = name
2582
2583        # Wrap the RPC method; this adds retry and timeout information,
2584        # and friendly error handling.
2585        rpc = self._transport._wrapped_methods[self._transport.delete_dlp_job]
2586
2587        # Certain fields should be provided within the metadata header;
2588        # add these here.
2589        metadata = tuple(metadata) + (
2590            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2591        )
2592
2593        # Send the request.
2594        rpc(
2595            request, retry=retry, timeout=timeout, metadata=metadata,
2596        )
2597
2598    def cancel_dlp_job(
2599        self,
2600        request: Union[dlp.CancelDlpJobRequest, dict] = None,
2601        *,
2602        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2603        timeout: float = None,
2604        metadata: Sequence[Tuple[str, str]] = (),
2605    ) -> None:
2606        r"""Starts asynchronous cancellation on a long-running
2607        DlpJob. The server makes a best effort to cancel the
2608        DlpJob, but success is not guaranteed.
2609        See https://cloud.google.com/dlp/docs/inspecting-storage
2610        and https://cloud.google.com/dlp/docs/compute-risk-
2611        analysis to learn more.
2612
2613        Args:
2614            request (Union[google.cloud.dlp_v2.types.CancelDlpJobRequest, dict]):
2615                The request object. The request message for canceling a
2616                DLP job.
2617            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2618                should be retried.
2619            timeout (float): The timeout for this request.
2620            metadata (Sequence[Tuple[str, str]]): Strings which should be
2621                sent along with the request as metadata.
2622        """
2623        # Create or coerce a protobuf request object.
2624        # Minor optimization to avoid making a copy if the user passes
2625        # in a dlp.CancelDlpJobRequest.
2626        # There's no risk of modifying the input as we've already verified
2627        # there are no flattened fields.
2628        if not isinstance(request, dlp.CancelDlpJobRequest):
2629            request = dlp.CancelDlpJobRequest(request)
2630
2631        # Wrap the RPC method; this adds retry and timeout information,
2632        # and friendly error handling.
2633        rpc = self._transport._wrapped_methods[self._transport.cancel_dlp_job]
2634
2635        # Certain fields should be provided within the metadata header;
2636        # add these here.
2637        metadata = tuple(metadata) + (
2638            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2639        )
2640
2641        # Send the request.
2642        rpc(
2643            request, retry=retry, timeout=timeout, metadata=metadata,
2644        )
2645
2646    def create_stored_info_type(
2647        self,
2648        request: Union[dlp.CreateStoredInfoTypeRequest, dict] = None,
2649        *,
2650        parent: str = None,
2651        config: dlp.StoredInfoTypeConfig = None,
2652        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2653        timeout: float = None,
2654        metadata: Sequence[Tuple[str, str]] = (),
2655    ) -> dlp.StoredInfoType:
2656        r"""Creates a pre-built stored infoType to be used for
2657        inspection. See
2658        https://cloud.google.com/dlp/docs/creating-stored-
2659        infotypes to learn more.
2660
2661        Args:
2662            request (Union[google.cloud.dlp_v2.types.CreateStoredInfoTypeRequest, dict]):
2663                The request object. Request message for
2664                CreateStoredInfoType.
2665            parent (str):
2666                Required. Parent resource name.
2667
2668                The format of this value varies depending on the scope
2669                of the request (project or organization) and whether you
2670                have `specified a processing
2671                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
2672
2673                -  Projects scope, location specified:
2674                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
2675                -  Projects scope, no location specified (defaults to
2676                   global): ``projects/``\ PROJECT_ID
2677                -  Organizations scope, location specified:
2678                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
2679                -  Organizations scope, no location specified (defaults
2680                   to global): ``organizations/``\ ORG_ID
2681
2682                The following example ``parent`` string specifies a
2683                parent project with the identifier ``example-project``,
2684                and specifies the ``europe-west3`` location for
2685                processing data:
2686
2687                ::
2688
2689                    parent=projects/example-project/locations/europe-west3
2690
2691                This corresponds to the ``parent`` field
2692                on the ``request`` instance; if ``request`` is provided, this
2693                should not be set.
2694            config (google.cloud.dlp_v2.types.StoredInfoTypeConfig):
2695                Required. Configuration of the
2696                storedInfoType to create.
2697
2698                This corresponds to the ``config`` field
2699                on the ``request`` instance; if ``request`` is provided, this
2700                should not be set.
2701            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2702                should be retried.
2703            timeout (float): The timeout for this request.
2704            metadata (Sequence[Tuple[str, str]]): Strings which should be
2705                sent along with the request as metadata.
2706
2707        Returns:
2708            google.cloud.dlp_v2.types.StoredInfoType:
2709                StoredInfoType resource message that
2710                contains information about the current
2711                version and any pending updates.
2712
2713        """
2714        # Create or coerce a protobuf request object.
2715        # Sanity check: If we got a request object, we should *not* have
2716        # gotten any keyword arguments that map to the request.
2717        has_flattened_params = any([parent, config])
2718        if request is not None and has_flattened_params:
2719            raise ValueError(
2720                "If the `request` argument is set, then none of "
2721                "the individual field arguments should be set."
2722            )
2723
2724        # Minor optimization to avoid making a copy if the user passes
2725        # in a dlp.CreateStoredInfoTypeRequest.
2726        # There's no risk of modifying the input as we've already verified
2727        # there are no flattened fields.
2728        if not isinstance(request, dlp.CreateStoredInfoTypeRequest):
2729            request = dlp.CreateStoredInfoTypeRequest(request)
2730            # If we have keyword arguments corresponding to fields on the
2731            # request, apply these.
2732            if parent is not None:
2733                request.parent = parent
2734            if config is not None:
2735                request.config = config
2736
2737        # Wrap the RPC method; this adds retry and timeout information,
2738        # and friendly error handling.
2739        rpc = self._transport._wrapped_methods[self._transport.create_stored_info_type]
2740
2741        # Certain fields should be provided within the metadata header;
2742        # add these here.
2743        metadata = tuple(metadata) + (
2744            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
2745        )
2746
2747        # Send the request.
2748        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2749
2750        # Done; return the response.
2751        return response
2752
2753    def update_stored_info_type(
2754        self,
2755        request: Union[dlp.UpdateStoredInfoTypeRequest, dict] = None,
2756        *,
2757        name: str = None,
2758        config: dlp.StoredInfoTypeConfig = None,
2759        update_mask: field_mask_pb2.FieldMask = None,
2760        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2761        timeout: float = None,
2762        metadata: Sequence[Tuple[str, str]] = (),
2763    ) -> dlp.StoredInfoType:
2764        r"""Updates the stored infoType by creating a new
2765        version. The existing version will continue to be used
2766        until the new version is ready. See
2767        https://cloud.google.com/dlp/docs/creating-stored-
2768        infotypes to learn more.
2769
2770        Args:
2771            request (Union[google.cloud.dlp_v2.types.UpdateStoredInfoTypeRequest, dict]):
2772                The request object. Request message for
2773                UpdateStoredInfoType.
2774            name (str):
2775                Required. Resource name of organization and
2776                storedInfoType to be updated, for example
2777                ``organizations/433245324/storedInfoTypes/432452342`` or
2778                projects/project-id/storedInfoTypes/432452342.
2779
2780                This corresponds to the ``name`` field
2781                on the ``request`` instance; if ``request`` is provided, this
2782                should not be set.
2783            config (google.cloud.dlp_v2.types.StoredInfoTypeConfig):
2784                Updated configuration for the
2785                storedInfoType. If not provided, a new
2786                version of the storedInfoType will be
2787                created with the existing configuration.
2788
2789                This corresponds to the ``config`` field
2790                on the ``request`` instance; if ``request`` is provided, this
2791                should not be set.
2792            update_mask (google.protobuf.field_mask_pb2.FieldMask):
2793                Mask to control which fields get
2794                updated.
2795
2796                This corresponds to the ``update_mask`` field
2797                on the ``request`` instance; if ``request`` is provided, this
2798                should not be set.
2799            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2800                should be retried.
2801            timeout (float): The timeout for this request.
2802            metadata (Sequence[Tuple[str, str]]): Strings which should be
2803                sent along with the request as metadata.
2804
2805        Returns:
2806            google.cloud.dlp_v2.types.StoredInfoType:
2807                StoredInfoType resource message that
2808                contains information about the current
2809                version and any pending updates.
2810
2811        """
2812        # Create or coerce a protobuf request object.
2813        # Sanity check: If we got a request object, we should *not* have
2814        # gotten any keyword arguments that map to the request.
2815        has_flattened_params = any([name, config, update_mask])
2816        if request is not None and has_flattened_params:
2817            raise ValueError(
2818                "If the `request` argument is set, then none of "
2819                "the individual field arguments should be set."
2820            )
2821
2822        # Minor optimization to avoid making a copy if the user passes
2823        # in a dlp.UpdateStoredInfoTypeRequest.
2824        # There's no risk of modifying the input as we've already verified
2825        # there are no flattened fields.
2826        if not isinstance(request, dlp.UpdateStoredInfoTypeRequest):
2827            request = dlp.UpdateStoredInfoTypeRequest(request)
2828            # If we have keyword arguments corresponding to fields on the
2829            # request, apply these.
2830            if name is not None:
2831                request.name = name
2832            if config is not None:
2833                request.config = config
2834            if update_mask is not None:
2835                request.update_mask = update_mask
2836
2837        # Wrap the RPC method; this adds retry and timeout information,
2838        # and friendly error handling.
2839        rpc = self._transport._wrapped_methods[self._transport.update_stored_info_type]
2840
2841        # Certain fields should be provided within the metadata header;
2842        # add these here.
2843        metadata = tuple(metadata) + (
2844            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2845        )
2846
2847        # Send the request.
2848        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2849
2850        # Done; return the response.
2851        return response
2852
2853    def get_stored_info_type(
2854        self,
2855        request: Union[dlp.GetStoredInfoTypeRequest, dict] = None,
2856        *,
2857        name: str = None,
2858        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2859        timeout: float = None,
2860        metadata: Sequence[Tuple[str, str]] = (),
2861    ) -> dlp.StoredInfoType:
2862        r"""Gets a stored infoType.
2863        See https://cloud.google.com/dlp/docs/creating-stored-
2864        infotypes to learn more.
2865
2866        Args:
2867            request (Union[google.cloud.dlp_v2.types.GetStoredInfoTypeRequest, dict]):
2868                The request object. Request message for
2869                GetStoredInfoType.
2870            name (str):
2871                Required. Resource name of the organization and
2872                storedInfoType to be read, for example
2873                ``organizations/433245324/storedInfoTypes/432452342`` or
2874                projects/project-id/storedInfoTypes/432452342.
2875
2876                This corresponds to the ``name`` field
2877                on the ``request`` instance; if ``request`` is provided, this
2878                should not be set.
2879            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2880                should be retried.
2881            timeout (float): The timeout for this request.
2882            metadata (Sequence[Tuple[str, str]]): Strings which should be
2883                sent along with the request as metadata.
2884
2885        Returns:
2886            google.cloud.dlp_v2.types.StoredInfoType:
2887                StoredInfoType resource message that
2888                contains information about the current
2889                version and any pending updates.
2890
2891        """
2892        # Create or coerce a protobuf request object.
2893        # Sanity check: If we got a request object, we should *not* have
2894        # gotten any keyword arguments that map to the request.
2895        has_flattened_params = any([name])
2896        if request is not None and has_flattened_params:
2897            raise ValueError(
2898                "If the `request` argument is set, then none of "
2899                "the individual field arguments should be set."
2900            )
2901
2902        # Minor optimization to avoid making a copy if the user passes
2903        # in a dlp.GetStoredInfoTypeRequest.
2904        # There's no risk of modifying the input as we've already verified
2905        # there are no flattened fields.
2906        if not isinstance(request, dlp.GetStoredInfoTypeRequest):
2907            request = dlp.GetStoredInfoTypeRequest(request)
2908            # If we have keyword arguments corresponding to fields on the
2909            # request, apply these.
2910            if name is not None:
2911                request.name = name
2912
2913        # Wrap the RPC method; this adds retry and timeout information,
2914        # and friendly error handling.
2915        rpc = self._transport._wrapped_methods[self._transport.get_stored_info_type]
2916
2917        # Certain fields should be provided within the metadata header;
2918        # add these here.
2919        metadata = tuple(metadata) + (
2920            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
2921        )
2922
2923        # Send the request.
2924        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2925
2926        # Done; return the response.
2927        return response
2928
2929    def list_stored_info_types(
2930        self,
2931        request: Union[dlp.ListStoredInfoTypesRequest, dict] = None,
2932        *,
2933        parent: str = None,
2934        retry: OptionalRetry = gapic_v1.method.DEFAULT,
2935        timeout: float = None,
2936        metadata: Sequence[Tuple[str, str]] = (),
2937    ) -> pagers.ListStoredInfoTypesPager:
2938        r"""Lists stored infoTypes.
2939        See https://cloud.google.com/dlp/docs/creating-stored-
2940        infotypes to learn more.
2941
2942        Args:
2943            request (Union[google.cloud.dlp_v2.types.ListStoredInfoTypesRequest, dict]):
2944                The request object. Request message for
2945                ListStoredInfoTypes.
2946            parent (str):
2947                Required. Parent resource name.
2948
2949                The format of this value varies depending on the scope
2950                of the request (project or organization) and whether you
2951                have `specified a processing
2952                location <https://cloud.google.com/dlp/docs/specifying-location>`__:
2953
2954                -  Projects scope, location specified:
2955                   ``projects/``\ PROJECT_ID\ ``/locations/``\ LOCATION_ID
2956                -  Projects scope, no location specified (defaults to
2957                   global): ``projects/``\ PROJECT_ID
2958                -  Organizations scope, location specified:
2959                   ``organizations/``\ ORG_ID\ ``/locations/``\ LOCATION_ID
2960                -  Organizations scope, no location specified (defaults
2961                   to global): ``organizations/``\ ORG_ID
2962
2963                The following example ``parent`` string specifies a
2964                parent project with the identifier ``example-project``,
2965                and specifies the ``europe-west3`` location for
2966                processing data:
2967
2968                ::
2969
2970                    parent=projects/example-project/locations/europe-west3
2971
2972                This corresponds to the ``parent`` field
2973                on the ``request`` instance; if ``request`` is provided, this
2974                should not be set.
2975            retry (google.api_core.retry.Retry): Designation of what errors, if any,
2976                should be retried.
2977            timeout (float): The timeout for this request.
2978            metadata (Sequence[Tuple[str, str]]): Strings which should be
2979                sent along with the request as metadata.
2980
2981        Returns:
2982            google.cloud.dlp_v2.services.dlp_service.pagers.ListStoredInfoTypesPager:
2983                Response message for
2984                ListStoredInfoTypes.
2985                Iterating over this object will yield
2986                results and resolve additional pages
2987                automatically.
2988
2989        """
2990        # Create or coerce a protobuf request object.
2991        # Sanity check: If we got a request object, we should *not* have
2992        # gotten any keyword arguments that map to the request.
2993        has_flattened_params = any([parent])
2994        if request is not None and has_flattened_params:
2995            raise ValueError(
2996                "If the `request` argument is set, then none of "
2997                "the individual field arguments should be set."
2998            )
2999
3000        # Minor optimization to avoid making a copy if the user passes
3001        # in a dlp.ListStoredInfoTypesRequest.
3002        # There's no risk of modifying the input as we've already verified
3003        # there are no flattened fields.
3004        if not isinstance(request, dlp.ListStoredInfoTypesRequest):
3005            request = dlp.ListStoredInfoTypesRequest(request)
3006            # If we have keyword arguments corresponding to fields on the
3007            # request, apply these.
3008            if parent is not None:
3009                request.parent = parent
3010
3011        # Wrap the RPC method; this adds retry and timeout information,
3012        # and friendly error handling.
3013        rpc = self._transport._wrapped_methods[self._transport.list_stored_info_types]
3014
3015        # Certain fields should be provided within the metadata header;
3016        # add these here.
3017        metadata = tuple(metadata) + (
3018            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
3019        )
3020
3021        # Send the request.
3022        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
3023
3024        # This method is paged; wrap the response in a pager, which provides
3025        # an `__iter__` convenience method.
3026        response = pagers.ListStoredInfoTypesPager(
3027            method=rpc, request=request, response=response, metadata=metadata,
3028        )
3029
3030        # Done; return the response.
3031        return response
3032
3033    def delete_stored_info_type(
3034        self,
3035        request: Union[dlp.DeleteStoredInfoTypeRequest, dict] = None,
3036        *,
3037        name: str = None,
3038        retry: OptionalRetry = gapic_v1.method.DEFAULT,
3039        timeout: float = None,
3040        metadata: Sequence[Tuple[str, str]] = (),
3041    ) -> None:
3042        r"""Deletes a stored infoType.
3043        See https://cloud.google.com/dlp/docs/creating-stored-
3044        infotypes to learn more.
3045
3046        Args:
3047            request (Union[google.cloud.dlp_v2.types.DeleteStoredInfoTypeRequest, dict]):
3048                The request object. Request message for
3049                DeleteStoredInfoType.
3050            name (str):
3051                Required. Resource name of the organization and
3052                storedInfoType to be deleted, for example
3053                ``organizations/433245324/storedInfoTypes/432452342`` or
3054                projects/project-id/storedInfoTypes/432452342.
3055
3056                This corresponds to the ``name`` field
3057                on the ``request`` instance; if ``request`` is provided, this
3058                should not be set.
3059            retry (google.api_core.retry.Retry): Designation of what errors, if any,
3060                should be retried.
3061            timeout (float): The timeout for this request.
3062            metadata (Sequence[Tuple[str, str]]): Strings which should be
3063                sent along with the request as metadata.
3064        """
3065        # Create or coerce a protobuf request object.
3066        # Sanity check: If we got a request object, we should *not* have
3067        # gotten any keyword arguments that map to the request.
3068        has_flattened_params = any([name])
3069        if request is not None and has_flattened_params:
3070            raise ValueError(
3071                "If the `request` argument is set, then none of "
3072                "the individual field arguments should be set."
3073            )
3074
3075        # Minor optimization to avoid making a copy if the user passes
3076        # in a dlp.DeleteStoredInfoTypeRequest.
3077        # There's no risk of modifying the input as we've already verified
3078        # there are no flattened fields.
3079        if not isinstance(request, dlp.DeleteStoredInfoTypeRequest):
3080            request = dlp.DeleteStoredInfoTypeRequest(request)
3081            # If we have keyword arguments corresponding to fields on the
3082            # request, apply these.
3083            if name is not None:
3084                request.name = name
3085
3086        # Wrap the RPC method; this adds retry and timeout information,
3087        # and friendly error handling.
3088        rpc = self._transport._wrapped_methods[self._transport.delete_stored_info_type]
3089
3090        # Certain fields should be provided within the metadata header;
3091        # add these here.
3092        metadata = tuple(metadata) + (
3093            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3094        )
3095
3096        # Send the request.
3097        rpc(
3098            request, retry=retry, timeout=timeout, metadata=metadata,
3099        )
3100
3101    def hybrid_inspect_dlp_job(
3102        self,
3103        request: Union[dlp.HybridInspectDlpJobRequest, dict] = None,
3104        *,
3105        name: str = None,
3106        retry: OptionalRetry = gapic_v1.method.DEFAULT,
3107        timeout: float = None,
3108        metadata: Sequence[Tuple[str, str]] = (),
3109    ) -> dlp.HybridInspectResponse:
3110        r"""Inspect hybrid content and store findings to a job.
3111        To review the findings inspect the job. Inspection will
3112        occur asynchronously.
3113        Early access feature is in a pre-release state and might
3114        change or have limited support. For more information,
3115        see
3116        https://cloud.google.com/products#product-launch-stages.
3117
3118        Args:
3119            request (Union[google.cloud.dlp_v2.types.HybridInspectDlpJobRequest, dict]):
3120                The request object. Request to search for potentially
3121                sensitive info in a custom location.
3122            name (str):
3123                Required. Resource name of the job to execute a hybrid
3124                inspect on, for example
3125                ``projects/dlp-test-project/dlpJob/53234423``.
3126
3127                This corresponds to the ``name`` field
3128                on the ``request`` instance; if ``request`` is provided, this
3129                should not be set.
3130            retry (google.api_core.retry.Retry): Designation of what errors, if any,
3131                should be retried.
3132            timeout (float): The timeout for this request.
3133            metadata (Sequence[Tuple[str, str]]): Strings which should be
3134                sent along with the request as metadata.
3135
3136        Returns:
3137            google.cloud.dlp_v2.types.HybridInspectResponse:
3138                Quota exceeded errors will be thrown
3139                once quota has been met.
3140
3141        """
3142        # Create or coerce a protobuf request object.
3143        # Sanity check: If we got a request object, we should *not* have
3144        # gotten any keyword arguments that map to the request.
3145        has_flattened_params = any([name])
3146        if request is not None and has_flattened_params:
3147            raise ValueError(
3148                "If the `request` argument is set, then none of "
3149                "the individual field arguments should be set."
3150            )
3151
3152        # Minor optimization to avoid making a copy if the user passes
3153        # in a dlp.HybridInspectDlpJobRequest.
3154        # There's no risk of modifying the input as we've already verified
3155        # there are no flattened fields.
3156        if not isinstance(request, dlp.HybridInspectDlpJobRequest):
3157            request = dlp.HybridInspectDlpJobRequest(request)
3158            # If we have keyword arguments corresponding to fields on the
3159            # request, apply these.
3160            if name is not None:
3161                request.name = name
3162
3163        # Wrap the RPC method; this adds retry and timeout information,
3164        # and friendly error handling.
3165        rpc = self._transport._wrapped_methods[self._transport.hybrid_inspect_dlp_job]
3166
3167        # Certain fields should be provided within the metadata header;
3168        # add these here.
3169        metadata = tuple(metadata) + (
3170            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3171        )
3172
3173        # Send the request.
3174        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
3175
3176        # Done; return the response.
3177        return response
3178
3179    def finish_dlp_job(
3180        self,
3181        request: Union[dlp.FinishDlpJobRequest, dict] = None,
3182        *,
3183        retry: OptionalRetry = gapic_v1.method.DEFAULT,
3184        timeout: float = None,
3185        metadata: Sequence[Tuple[str, str]] = (),
3186    ) -> None:
3187        r"""Finish a running hybrid DlpJob. Triggers the
3188        finalization steps and running of any enabled actions
3189        that have not yet run. Early access feature is in a pre-
3190        release state and might change or have limited support.
3191        For more information, see
3192        https://cloud.google.com/products#product-launch-stages.
3193
3194        Args:
3195            request (Union[google.cloud.dlp_v2.types.FinishDlpJobRequest, dict]):
3196                The request object. The request message for finishing a
3197                DLP hybrid job.
3198            retry (google.api_core.retry.Retry): Designation of what errors, if any,
3199                should be retried.
3200            timeout (float): The timeout for this request.
3201            metadata (Sequence[Tuple[str, str]]): Strings which should be
3202                sent along with the request as metadata.
3203        """
3204        # Create or coerce a protobuf request object.
3205        # Minor optimization to avoid making a copy if the user passes
3206        # in a dlp.FinishDlpJobRequest.
3207        # There's no risk of modifying the input as we've already verified
3208        # there are no flattened fields.
3209        if not isinstance(request, dlp.FinishDlpJobRequest):
3210            request = dlp.FinishDlpJobRequest(request)
3211
3212        # Wrap the RPC method; this adds retry and timeout information,
3213        # and friendly error handling.
3214        rpc = self._transport._wrapped_methods[self._transport.finish_dlp_job]
3215
3216        # Certain fields should be provided within the metadata header;
3217        # add these here.
3218        metadata = tuple(metadata) + (
3219            gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
3220        )
3221
3222        # Send the request.
3223        rpc(
3224            request, retry=retry, timeout=timeout, metadata=metadata,
3225        )
3226
3227    def __enter__(self):
3228        return self
3229
3230    def __exit__(self, type, value, traceback):
3231        """Releases underlying transport's resources.
3232
3233        .. warning::
3234            ONLY use as a context manager if the transport is NOT shared
3235            with other clients! Exiting the with block will CLOSE the transport
3236            and may cause errors in other clients!
3237        """
3238        self.transport.close()
3239
3240
3241try:
3242    DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
3243        gapic_version=pkg_resources.get_distribution("google-cloud-dlp",).version,
3244    )
3245except pkg_resources.DistributionNotFound:
3246    DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
3247
3248
3249__all__ = ("DlpServiceClient",)
3250