Skip to content

Commit

Permalink
feat(kms): undeprecate resource name helper methods, add 2.7 deprecat…
Browse files Browse the repository at this point in the history
…ion warning (via synth) (#10045)
  • Loading branch information
yoshi-automation authored and busunkim96 committed Jan 8, 2020
1 parent d7f7887 commit f04cf32
Show file tree
Hide file tree
Showing 3 changed files with 3,438 additions and 41 deletions.
11 changes: 11 additions & 0 deletions packages/google-cloud-kms/google/cloud/kms_v1/__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.kms_v1 import types
from google.cloud.kms_v1.gapic import enums
from google.cloud.kms_v1.gapic import key_management_service_client


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 KeyManagementServiceClient(
key_management_service_client.KeyManagementServiceClient
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def crypto_key_path(cls, project, location, key_ring, crypto_key):
"""DEPRECATED. Return a fully-qualified crypto_key string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified crypto_key string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}",
project=project,
Expand All @@ -108,12 +103,7 @@ def crypto_key_path(cls, project, location, key_ring, crypto_key):

@classmethod
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path):
"""DEPRECATED. Return a fully-qualified crypto_key_path string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified crypto_key_path string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}",
project=project,
Expand All @@ -126,12 +116,7 @@ def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path):
def crypto_key_version_path(
cls, project, location, key_ring, crypto_key, crypto_key_version
):
"""DEPRECATED. Return a fully-qualified crypto_key_version string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified crypto_key_version string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}",
project=project,
Expand All @@ -143,12 +128,7 @@ def crypto_key_version_path(

@classmethod
def import_job_path(cls, project, location, key_ring, import_job):
"""DEPRECATED. Return a fully-qualified import_job string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified import_job string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}",
project=project,
Expand All @@ -159,12 +139,7 @@ def import_job_path(cls, project, location, key_ring, import_job):

@classmethod
def key_ring_path(cls, project, location, key_ring):
"""DEPRECATED. Return a fully-qualified key_ring string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified key_ring string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/keyRings/{key_ring}",
project=project,
Expand All @@ -174,12 +149,7 @@ def key_ring_path(cls, project, location, key_ring):

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

0 comments on commit f04cf32

Please sign in to comment.