Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
chore: fix README instructions for java (#592)
Browse files Browse the repository at this point in the history
Source-Author: Jeff Ching <chingor@google.com>
Source-Date: Fri May 29 14:22:08 2020 -0700
Source-Repo: googleapis/synthtool
Source-Sha: cb3c683e958a4b5c016bb3734436fc1cb887eb7b
Source-Link: googleapis/synthtool@cb3c683
  • Loading branch information
yoshi-automation committed May 30, 2020
1 parent ef3116f commit 2f4bf0a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
Expand Up @@ -151,23 +151,17 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
from_service_account_json = from_service_account_file

@staticmethod
def endpoint_path(
project: str, location: str, namespace: str, service: str, endpoint: str
) -> str:
"""Return a fully-qualified endpoint string."""
return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}".format(
project=project,
location=location,
namespace=namespace,
service=service,
endpoint=endpoint,
def service_path(project: str, location: str, namespace: str, service: str) -> str:
"""Return a fully-qualified service string."""
return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(
project=project, location=location, namespace=namespace, service=service
)

@staticmethod
def parse_endpoint_path(path: str) -> Dict[str, str]:
"""Parse a endpoint path into its component segments."""
def parse_service_path(path: str) -> Dict[str, str]:
"""Parse a service path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/namespaces/(?P<namespace>.+?)/services/(?P<service>.+?)/endpoints/(?P<endpoint>.+?)$",
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/namespaces/(?P<namespace>.+?)/services/(?P<service>.+?)$",
path,
)
return m.groupdict() if m else {}
Expand All @@ -189,17 +183,23 @@ def parse_namespace_path(path: str) -> Dict[str, str]:
return m.groupdict() if m else {}

@staticmethod
def service_path(project: str, location: str, namespace: str, service: str) -> str:
"""Return a fully-qualified service string."""
return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(
project=project, location=location, namespace=namespace, service=service
def endpoint_path(
project: str, location: str, namespace: str, service: str, endpoint: str
) -> str:
"""Return a fully-qualified endpoint string."""
return "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}".format(
project=project,
location=location,
namespace=namespace,
service=service,
endpoint=endpoint,
)

@staticmethod
def parse_service_path(path: str) -> Dict[str, str]:
"""Parse a service path into its component segments."""
def parse_endpoint_path(path: str) -> Dict[str, str]:
"""Parse a endpoint path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/namespaces/(?P<namespace>.+?)/services/(?P<service>.+?)$",
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/namespaces/(?P<namespace>.+?)/services/(?P<service>.+?)/endpoints/(?P<endpoint>.+?)$",
path,
)
return m.groupdict() if m else {}
Expand Down
4 changes: 2 additions & 2 deletions synth.metadata
Expand Up @@ -19,14 +19,14 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "385d537832113984af2d033aaf353f0432256527"
"sha": "cb3c683e958a4b5c016bb3734436fc1cb887eb7b"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "385d537832113984af2d033aaf353f0432256527"
"sha": "cb3c683e958a4b5c016bb3734436fc1cb887eb7b"
}
}
],
Expand Down
60 changes: 30 additions & 30 deletions tests/unit/servicedirectory_v1beta1/test_registration_service.py
Expand Up @@ -1728,38 +1728,32 @@ def test_registration_service_grpc_transport_channel_mtls_with_adc(
assert transport.grpc_channel == mock_grpc_channel


def test_endpoint_path():
def test_service_path():
project = "squid"
location = "clam"
namespace = "whelk"
service = "octopus"
endpoint = "oyster"

expected = "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}".format(
project=project,
location=location,
namespace=namespace,
service=service,
endpoint=endpoint,
expected = "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(
project=project, location=location, namespace=namespace, service=service
)
actual = RegistrationServiceClient.endpoint_path(
project, location, namespace, service, endpoint
actual = RegistrationServiceClient.service_path(
project, location, namespace, service
)
assert expected == actual


def test_parse_endpoint_path():
def test_parse_service_path():
expected = {
"project": "nudibranch",
"location": "cuttlefish",
"namespace": "mussel",
"service": "winkle",
"endpoint": "nautilus",
"project": "oyster",
"location": "nudibranch",
"namespace": "cuttlefish",
"service": "mussel",
}
path = RegistrationServiceClient.endpoint_path(**expected)
path = RegistrationServiceClient.service_path(**expected)

# Check that the path construction is reversible.
actual = RegistrationServiceClient.parse_endpoint_path(path)
actual = RegistrationServiceClient.parse_service_path(path)
assert expected == actual


Expand All @@ -1784,30 +1778,36 @@ def test_parse_namespace_path():
assert expected == actual


def test_service_path():
def test_endpoint_path():
project = "squid"
location = "clam"
namespace = "whelk"
service = "octopus"
endpoint = "oyster"

expected = "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}".format(
project=project, location=location, namespace=namespace, service=service
expected = "projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}".format(
project=project,
location=location,
namespace=namespace,
service=service,
endpoint=endpoint,
)
actual = RegistrationServiceClient.service_path(
project, location, namespace, service
actual = RegistrationServiceClient.endpoint_path(
project, location, namespace, service, endpoint
)
assert expected == actual


def test_parse_service_path():
def test_parse_endpoint_path():
expected = {
"project": "oyster",
"location": "nudibranch",
"namespace": "cuttlefish",
"service": "mussel",
"project": "nudibranch",
"location": "cuttlefish",
"namespace": "mussel",
"service": "winkle",
"endpoint": "nautilus",
}
path = RegistrationServiceClient.service_path(**expected)
path = RegistrationServiceClient.endpoint_path(**expected)

# Check that the path construction is reversible.
actual = RegistrationServiceClient.parse_service_path(path)
actual = RegistrationServiceClient.parse_endpoint_path(path)
assert expected == actual

0 comments on commit 2f4bf0a

Please sign in to comment.