Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit fbb47e6

Browse files
feat: add inventory_path (#283)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 394704298 Source-Link: googleapis/googleapis@31d2d34 Source-Link: https://github.com/googleapis/googleapis-gen/commit/aa3ce0901f686a71b68e427c6bb7a611b151b540
1 parent bf23fbc commit fbb47e6

File tree

3 files changed

+58
-16
lines changed

3 files changed

+58
-16
lines changed

google/cloud/asset_v1/services/asset_service/async_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class AssetServiceAsyncClient:
5353

5454
feed_path = staticmethod(AssetServiceClient.feed_path)
5555
parse_feed_path = staticmethod(AssetServiceClient.parse_feed_path)
56+
inventory_path = staticmethod(AssetServiceClient.inventory_path)
57+
parse_inventory_path = staticmethod(AssetServiceClient.parse_inventory_path)
5658
service_perimeter_path = staticmethod(AssetServiceClient.service_perimeter_path)
5759
parse_service_perimeter_path = staticmethod(
5860
AssetServiceClient.parse_service_perimeter_path

google/cloud/asset_v1/services/asset_service/client.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@ def parse_feed_path(path: str) -> Dict[str, str]:
200200
m = re.match(r"^projects/(?P<project>.+?)/feeds/(?P<feed>.+?)$", path)
201201
return m.groupdict() if m else {}
202202

203+
@staticmethod
204+
def inventory_path(project: str, location: str, instance: str,) -> str:
205+
"""Returns a fully-qualified inventory string."""
206+
return "projects/{project}/locations/{location}/instances/{instance}/inventory".format(
207+
project=project, location=location, instance=instance,
208+
)
209+
210+
@staticmethod
211+
def parse_inventory_path(path: str) -> Dict[str, str]:
212+
"""Parses a inventory path into its component segments."""
213+
m = re.match(
214+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/instances/(?P<instance>.+?)/inventory$",
215+
path,
216+
)
217+
return m.groupdict() if m else {}
218+
203219
@staticmethod
204220
def service_perimeter_path(access_policy: str, service_perimeter: str,) -> str:
205221
"""Returns a fully-qualified service_perimeter string."""

tests/unit/gapic/asset_v1/test_asset_service.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,9 +3835,33 @@ def test_parse_feed_path():
38353835
assert expected == actual
38363836

38373837

3838+
def test_inventory_path():
3839+
project = "scallop"
3840+
location = "abalone"
3841+
instance = "squid"
3842+
expected = "projects/{project}/locations/{location}/instances/{instance}/inventory".format(
3843+
project=project, location=location, instance=instance,
3844+
)
3845+
actual = AssetServiceClient.inventory_path(project, location, instance)
3846+
assert expected == actual
3847+
3848+
3849+
def test_parse_inventory_path():
3850+
expected = {
3851+
"project": "clam",
3852+
"location": "whelk",
3853+
"instance": "octopus",
3854+
}
3855+
path = AssetServiceClient.inventory_path(**expected)
3856+
3857+
# Check that the path construction is reversible.
3858+
actual = AssetServiceClient.parse_inventory_path(path)
3859+
assert expected == actual
3860+
3861+
38383862
def test_service_perimeter_path():
3839-
access_policy = "scallop"
3840-
service_perimeter = "abalone"
3863+
access_policy = "oyster"
3864+
service_perimeter = "nudibranch"
38413865
expected = "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format(
38423866
access_policy=access_policy, service_perimeter=service_perimeter,
38433867
)
@@ -3847,8 +3871,8 @@ def test_service_perimeter_path():
38473871

38483872
def test_parse_service_perimeter_path():
38493873
expected = {
3850-
"access_policy": "squid",
3851-
"service_perimeter": "clam",
3874+
"access_policy": "cuttlefish",
3875+
"service_perimeter": "mussel",
38523876
}
38533877
path = AssetServiceClient.service_perimeter_path(**expected)
38543878

@@ -3858,7 +3882,7 @@ def test_parse_service_perimeter_path():
38583882

38593883

38603884
def test_common_billing_account_path():
3861-
billing_account = "whelk"
3885+
billing_account = "winkle"
38623886
expected = "billingAccounts/{billing_account}".format(
38633887
billing_account=billing_account,
38643888
)
@@ -3868,7 +3892,7 @@ def test_common_billing_account_path():
38683892

38693893
def test_parse_common_billing_account_path():
38703894
expected = {
3871-
"billing_account": "octopus",
3895+
"billing_account": "nautilus",
38723896
}
38733897
path = AssetServiceClient.common_billing_account_path(**expected)
38743898

@@ -3878,15 +3902,15 @@ def test_parse_common_billing_account_path():
38783902

38793903

38803904
def test_common_folder_path():
3881-
folder = "oyster"
3905+
folder = "scallop"
38823906
expected = "folders/{folder}".format(folder=folder,)
38833907
actual = AssetServiceClient.common_folder_path(folder)
38843908
assert expected == actual
38853909

38863910

38873911
def test_parse_common_folder_path():
38883912
expected = {
3889-
"folder": "nudibranch",
3913+
"folder": "abalone",
38903914
}
38913915
path = AssetServiceClient.common_folder_path(**expected)
38923916

@@ -3896,15 +3920,15 @@ def test_parse_common_folder_path():
38963920

38973921

38983922
def test_common_organization_path():
3899-
organization = "cuttlefish"
3923+
organization = "squid"
39003924
expected = "organizations/{organization}".format(organization=organization,)
39013925
actual = AssetServiceClient.common_organization_path(organization)
39023926
assert expected == actual
39033927

39043928

39053929
def test_parse_common_organization_path():
39063930
expected = {
3907-
"organization": "mussel",
3931+
"organization": "clam",
39083932
}
39093933
path = AssetServiceClient.common_organization_path(**expected)
39103934

@@ -3914,15 +3938,15 @@ def test_parse_common_organization_path():
39143938

39153939

39163940
def test_common_project_path():
3917-
project = "winkle"
3941+
project = "whelk"
39183942
expected = "projects/{project}".format(project=project,)
39193943
actual = AssetServiceClient.common_project_path(project)
39203944
assert expected == actual
39213945

39223946

39233947
def test_parse_common_project_path():
39243948
expected = {
3925-
"project": "nautilus",
3949+
"project": "octopus",
39263950
}
39273951
path = AssetServiceClient.common_project_path(**expected)
39283952

@@ -3932,8 +3956,8 @@ def test_parse_common_project_path():
39323956

39333957

39343958
def test_common_location_path():
3935-
project = "scallop"
3936-
location = "abalone"
3959+
project = "oyster"
3960+
location = "nudibranch"
39373961
expected = "projects/{project}/locations/{location}".format(
39383962
project=project, location=location,
39393963
)
@@ -3943,8 +3967,8 @@ def test_common_location_path():
39433967

39443968
def test_parse_common_location_path():
39453969
expected = {
3946-
"project": "squid",
3947-
"location": "clam",
3970+
"project": "cuttlefish",
3971+
"location": "mussel",
39483972
}
39493973
path = AssetServiceClient.common_location_path(**expected)
39503974

0 commit comments

Comments
 (0)