Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ParameterManagerAsyncClient:
_DEFAULT_ENDPOINT_TEMPLATE = ParameterManagerClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = ParameterManagerClient._DEFAULT_UNIVERSE

crypto_key_path = staticmethod(ParameterManagerClient.crypto_key_path)
parse_crypto_key_path = staticmethod(ParameterManagerClient.parse_crypto_key_path)
parameter_path = staticmethod(ParameterManagerClient.parameter_path)
parse_parameter_path = staticmethod(ParameterManagerClient.parse_parameter_path)
parameter_version_path = staticmethod(ParameterManagerClient.parameter_version_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ def transport(self) -> ParameterManagerTransport:
"""
return self._transport

@staticmethod
def crypto_key_path(
project: str,
location: str,
key_ring: str,
crypto_key: str,
) -> str:
"""Returns a fully-qualified crypto_key string."""
return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
)

@staticmethod
def parse_crypto_key_path(path: str) -> Dict[str, str]:
"""Parses a crypto_key path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/keyRings/(?P<key_ring>.+?)/cryptoKeys/(?P<crypto_key>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def parameter_path(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-parametermanager",
"version": "0.1.4"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10813,10 +10813,41 @@ def test_parameter_manager_transport_channel_mtls_with_adc(transport_class):
assert transport.grpc_channel == mock_grpc_channel


def test_parameter_path():
def test_crypto_key_path():
project = "squid"
location = "clam"
parameter = "whelk"
key_ring = "whelk"
crypto_key = "octopus"
expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format(
project=project,
location=location,
key_ring=key_ring,
crypto_key=crypto_key,
)
actual = ParameterManagerClient.crypto_key_path(
project, location, key_ring, crypto_key
)
assert expected == actual


def test_parse_crypto_key_path():
expected = {
"project": "oyster",
"location": "nudibranch",
"key_ring": "cuttlefish",
"crypto_key": "mussel",
}
path = ParameterManagerClient.crypto_key_path(**expected)

# Check that the path construction is reversible.
actual = ParameterManagerClient.parse_crypto_key_path(path)
assert expected == actual


def test_parameter_path():
project = "winkle"
location = "nautilus"
parameter = "scallop"
expected = "projects/{project}/locations/{location}/parameters/{parameter}".format(
project=project,
location=location,
Expand All @@ -10828,9 +10859,9 @@ def test_parameter_path():

def test_parse_parameter_path():
expected = {
"project": "octopus",
"location": "oyster",
"parameter": "nudibranch",
"project": "abalone",
"location": "squid",
"parameter": "clam",
}
path = ParameterManagerClient.parameter_path(**expected)

Expand All @@ -10840,10 +10871,10 @@ def test_parse_parameter_path():


def test_parameter_version_path():
project = "cuttlefish"
location = "mussel"
parameter = "winkle"
parameter_version = "nautilus"
project = "whelk"
location = "octopus"
parameter = "oyster"
parameter_version = "nudibranch"
expected = "projects/{project}/locations/{location}/parameters/{parameter}/versions/{parameter_version}".format(
project=project,
location=location,
Expand All @@ -10858,10 +10889,10 @@ def test_parameter_version_path():

def test_parse_parameter_version_path():
expected = {
"project": "scallop",
"location": "abalone",
"parameter": "squid",
"parameter_version": "clam",
"project": "cuttlefish",
"location": "mussel",
"parameter": "winkle",
"parameter_version": "nautilus",
}
path = ParameterManagerClient.parameter_version_path(**expected)

Expand All @@ -10871,7 +10902,7 @@ def test_parse_parameter_version_path():


def test_common_billing_account_path():
billing_account = "whelk"
billing_account = "scallop"
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
Expand All @@ -10881,7 +10912,7 @@ def test_common_billing_account_path():

def test_parse_common_billing_account_path():
expected = {
"billing_account": "octopus",
"billing_account": "abalone",
}
path = ParameterManagerClient.common_billing_account_path(**expected)

Expand All @@ -10891,7 +10922,7 @@ def test_parse_common_billing_account_path():


def test_common_folder_path():
folder = "oyster"
folder = "squid"
expected = "folders/{folder}".format(
folder=folder,
)
Expand All @@ -10901,7 +10932,7 @@ def test_common_folder_path():

def test_parse_common_folder_path():
expected = {
"folder": "nudibranch",
"folder": "clam",
}
path = ParameterManagerClient.common_folder_path(**expected)

Expand All @@ -10911,7 +10942,7 @@ def test_parse_common_folder_path():


def test_common_organization_path():
organization = "cuttlefish"
organization = "whelk"
expected = "organizations/{organization}".format(
organization=organization,
)
Expand All @@ -10921,7 +10952,7 @@ def test_common_organization_path():

def test_parse_common_organization_path():
expected = {
"organization": "mussel",
"organization": "octopus",
}
path = ParameterManagerClient.common_organization_path(**expected)

Expand All @@ -10931,7 +10962,7 @@ def test_parse_common_organization_path():


def test_common_project_path():
project = "winkle"
project = "oyster"
expected = "projects/{project}".format(
project=project,
)
Expand All @@ -10941,7 +10972,7 @@ def test_common_project_path():

def test_parse_common_project_path():
expected = {
"project": "nautilus",
"project": "nudibranch",
}
path = ParameterManagerClient.common_project_path(**expected)

Expand All @@ -10951,8 +10982,8 @@ def test_parse_common_project_path():


def test_common_location_path():
project = "scallop"
location = "abalone"
project = "cuttlefish"
location = "mussel"
expected = "projects/{project}/locations/{location}".format(
project=project,
location=location,
Expand All @@ -10963,8 +10994,8 @@ def test_common_location_path():

def test_parse_common_location_path():
expected = {
"project": "squid",
"location": "clam",
"project": "winkle",
"location": "nautilus",
}
path = ParameterManagerClient.common_location_path(**expected)

Expand Down
Loading