Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dlp): undeprecate resource name helper methods, add 2.7 deprecation warning (via synth) #10040

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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