Skip to content

Commit

Permalink
feat(dlp): undeprecate resource name helper methods, add 2.7 deprecat…
Browse files Browse the repository at this point in the history
…ion warning (via synth) (#10040)
  • Loading branch information
yoshi-automation authored and busunkim96 committed Jan 8, 2020
1 parent 3d00a9c commit b663b61
Show file tree
Hide file tree
Showing 3 changed files with 3,445 additions and 65 deletions.
11 changes: 11 additions & 0 deletions dlp/google/cloud/dlp_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.dlp_v2 import types
from google.cloud.dlp_v2.gapic import dlp_service_client
from google.cloud.dlp_v2.gapic import enums


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class DlpServiceClient(dlp_service_client.DlpServiceClient):
__doc__ = dlp_service_client.DlpServiceClient.__doc__
enums = enums
Expand Down
70 changes: 10 additions & 60 deletions dlp/google/cloud/dlp_v2/gapic/dlp_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,21 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def dlp_job_path(cls, project, dlp_job):
"""DEPRECATED. Return a fully-qualified dlp_job string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified dlp_job string."""
return google.api_core.path_template.expand(
"projects/{project}/dlpJobs/{dlp_job}", project=project, dlp_job=dlp_job
)

@classmethod
def organization_path(cls, organization):
"""DEPRECATED. Return a fully-qualified organization string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified organization string."""
return google.api_core.path_template.expand(
"organizations/{organization}", organization=organization
)

@classmethod
def organization_deidentify_template_path(cls, organization, deidentify_template):
"""DEPRECATED. Return a fully-qualified organization_deidentify_template string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified organization_deidentify_template string."""
return google.api_core.path_template.expand(
"organizations/{organization}/deidentifyTemplates/{deidentify_template}",
organization=organization,
Expand All @@ -124,12 +109,7 @@ def organization_deidentify_template_path(cls, organization, deidentify_template

@classmethod
def organization_inspect_template_path(cls, organization, inspect_template):
"""DEPRECATED. Return a fully-qualified organization_inspect_template string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified organization_inspect_template string."""
return google.api_core.path_template.expand(
"organizations/{organization}/inspectTemplates/{inspect_template}",
organization=organization,
Expand All @@ -138,12 +118,7 @@ def organization_inspect_template_path(cls, organization, inspect_template):

@classmethod
def organization_stored_info_type_path(cls, organization, stored_info_type):
"""DEPRECATED. Return a fully-qualified organization_stored_info_type string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified organization_stored_info_type string."""
return google.api_core.path_template.expand(
"organizations/{organization}/storedInfoTypes/{stored_info_type}",
organization=organization,
Expand All @@ -152,24 +127,14 @@ def organization_stored_info_type_path(cls, organization, stored_info_type):

@classmethod
def project_path(cls, project):
"""DEPRECATED. Return a fully-qualified project string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project
)

@classmethod
def project_deidentify_template_path(cls, project, deidentify_template):
"""DEPRECATED. Return a fully-qualified project_deidentify_template string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project_deidentify_template string."""
return google.api_core.path_template.expand(
"projects/{project}/deidentifyTemplates/{deidentify_template}",
project=project,
Expand All @@ -178,12 +143,7 @@ def project_deidentify_template_path(cls, project, deidentify_template):

@classmethod
def project_inspect_template_path(cls, project, inspect_template):
"""DEPRECATED. Return a fully-qualified project_inspect_template string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project_inspect_template string."""
return google.api_core.path_template.expand(
"projects/{project}/inspectTemplates/{inspect_template}",
project=project,
Expand All @@ -192,12 +152,7 @@ def project_inspect_template_path(cls, project, inspect_template):

@classmethod
def project_job_trigger_path(cls, project, job_trigger):
"""DEPRECATED. Return a fully-qualified project_job_trigger string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project_job_trigger string."""
return google.api_core.path_template.expand(
"projects/{project}/jobTriggers/{job_trigger}",
project=project,
Expand All @@ -206,12 +161,7 @@ def project_job_trigger_path(cls, project, job_trigger):

@classmethod
def project_stored_info_type_path(cls, project, stored_info_type):
"""DEPRECATED. Return a fully-qualified project_stored_info_type string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project_stored_info_type string."""
return google.api_core.path_template.expand(
"projects/{project}/storedInfoTypes/{stored_info_type}",
project=project,
Expand Down
Loading

0 comments on commit b663b61

Please sign in to comment.