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

fix: fix resource pattern ID segment name #107

Merged
merged 2 commits into from Dec 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -187,17 +187,17 @@ def transport(self) -> ArtifactRegistryTransport:
return self._transport

@staticmethod
def file_path(project: str, location: str, repo: str, file: str,) -> str:
def file_path(project: str, location: str, repository: str, file: str,) -> str:
"""Returns a fully-qualified file string."""
return "projects/{project}/locations/{location}/repositories/{repo}/files/{file}".format(
project=project, location=location, repo=repo, file=file,
return "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(
project=project, location=location, repository=repository, file=file,
)

@staticmethod
def parse_file_path(path: str) -> Dict[str, str]:
"""Parses a file path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/repositories/(?P<repo>.+?)/files/(?P<file>.+?)$",
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/repositories/(?P<repository>.+?)/files/(?P<file>.+?)$",
path,
)
return m.groupdict() if m else {}
Expand Down
Expand Up @@ -5913,20 +5913,20 @@ def test_artifact_registry_grpc_lro_async_client():
def test_file_path():
project = "squid"
location = "clam"
repo = "whelk"
repository = "whelk"
file = "octopus"
expected = "projects/{project}/locations/{location}/repositories/{repo}/files/{file}".format(
project=project, location=location, repo=repo, file=file,
expected = "projects/{project}/locations/{location}/repositories/{repository}/files/{file}".format(
project=project, location=location, repository=repository, file=file,
)
actual = ArtifactRegistryClient.file_path(project, location, repo, file)
actual = ArtifactRegistryClient.file_path(project, location, repository, file)
assert expected == actual


def test_parse_file_path():
expected = {
"project": "oyster",
"location": "nudibranch",
"repo": "cuttlefish",
"repository": "cuttlefish",
"file": "mussel",
}
path = ArtifactRegistryClient.file_path(**expected)
Expand Down