diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py index 5546a37bcea0..c05e2b8fded6 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py @@ -45,10 +45,18 @@ class AssetServiceAsyncClient: DEFAULT_ENDPOINT = AssetServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = AssetServiceClient.DEFAULT_MTLS_ENDPOINT + access_level_path = staticmethod(AssetServiceClient.access_level_path) + parse_access_level_path = staticmethod(AssetServiceClient.parse_access_level_path) + access_policy_path = staticmethod(AssetServiceClient.access_policy_path) + parse_access_policy_path = staticmethod(AssetServiceClient.parse_access_policy_path) asset_path = staticmethod(AssetServiceClient.asset_path) feed_path = staticmethod(AssetServiceClient.feed_path) parse_feed_path = staticmethod(AssetServiceClient.parse_feed_path) + service_perimeter_path = staticmethod(AssetServiceClient.service_perimeter_path) + parse_service_perimeter_path = staticmethod( + AssetServiceClient.parse_service_perimeter_path + ) common_billing_account_path = staticmethod( AssetServiceClient.common_billing_account_path ) diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py index 6459c846aece..4963879816ec 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py @@ -157,6 +157,33 @@ def transport(self) -> AssetServiceTransport: """ return self._transport + @staticmethod + def access_level_path(access_policy: str, access_level: str,) -> str: + """Returns a fully-qualified access_level string.""" + return "accessPolicies/{access_policy}/accessLevels/{access_level}".format( + access_policy=access_policy, access_level=access_level, + ) + + @staticmethod + def parse_access_level_path(path: str) -> Dict[str, str]: + """Parses a access_level path into its component segments.""" + m = re.match( + r"^accessPolicies/(?P.+?)/accessLevels/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def access_policy_path(access_policy: str,) -> str: + """Returns a fully-qualified access_policy string.""" + return "accessPolicies/{access_policy}".format(access_policy=access_policy,) + + @staticmethod + def parse_access_policy_path(path: str) -> Dict[str, str]: + """Parses a access_policy path into its component segments.""" + m = re.match(r"^accessPolicies/(?P.+?)$", path) + return m.groupdict() if m else {} + @staticmethod def asset_path() -> str: """Returns a fully-qualified asset string.""" @@ -173,6 +200,22 @@ def parse_feed_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/feeds/(?P.+?)$", path) return m.groupdict() if m else {} + @staticmethod + def service_perimeter_path(access_policy: str, service_perimeter: str,) -> str: + """Returns a fully-qualified service_perimeter string.""" + return "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, service_perimeter=service_perimeter, + ) + + @staticmethod + def parse_service_perimeter_path(path: str) -> Dict[str, str]: + """Parses a service_perimeter path into its component segments.""" + m = re.match( + r"^accessPolicies/(?P.+?)/servicePerimeters/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index 2c791571da25..ef95fe818617 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py @@ -42,8 +42,16 @@ class AssetServiceAsyncClient: DEFAULT_ENDPOINT = AssetServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = AssetServiceClient.DEFAULT_MTLS_ENDPOINT + access_level_path = staticmethod(AssetServiceClient.access_level_path) + parse_access_level_path = staticmethod(AssetServiceClient.parse_access_level_path) + access_policy_path = staticmethod(AssetServiceClient.access_policy_path) + parse_access_policy_path = staticmethod(AssetServiceClient.parse_access_policy_path) asset_path = staticmethod(AssetServiceClient.asset_path) + service_perimeter_path = staticmethod(AssetServiceClient.service_perimeter_path) + parse_service_perimeter_path = staticmethod( + AssetServiceClient.parse_service_perimeter_path + ) common_billing_account_path = staticmethod( AssetServiceClient.common_billing_account_path ) diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py index b00281a3121f..107524752eb6 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py @@ -154,11 +154,54 @@ def transport(self) -> AssetServiceTransport: """ return self._transport + @staticmethod + def access_level_path(access_policy: str, access_level: str,) -> str: + """Returns a fully-qualified access_level string.""" + return "accessPolicies/{access_policy}/accessLevels/{access_level}".format( + access_policy=access_policy, access_level=access_level, + ) + + @staticmethod + def parse_access_level_path(path: str) -> Dict[str, str]: + """Parses a access_level path into its component segments.""" + m = re.match( + r"^accessPolicies/(?P.+?)/accessLevels/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def access_policy_path(access_policy: str,) -> str: + """Returns a fully-qualified access_policy string.""" + return "accessPolicies/{access_policy}".format(access_policy=access_policy,) + + @staticmethod + def parse_access_policy_path(path: str) -> Dict[str, str]: + """Parses a access_policy path into its component segments.""" + m = re.match(r"^accessPolicies/(?P.+?)$", path) + return m.groupdict() if m else {} + @staticmethod def asset_path() -> str: """Returns a fully-qualified asset string.""" return "*".format() + @staticmethod + def service_perimeter_path(access_policy: str, service_perimeter: str,) -> str: + """Returns a fully-qualified service_perimeter string.""" + return "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, service_perimeter=service_perimeter, + ) + + @staticmethod + def parse_service_perimeter_path(path: str) -> Dict[str, str]: + """Parses a service_perimeter path into its component segments.""" + m = re.match( + r"^accessPolicies/(?P.+?)/servicePerimeters/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path(billing_account: str,) -> str: """Returns a fully-qualified billing_account string.""" diff --git a/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py index 17926e1e21f2..20e2ee2310f4 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py @@ -3757,6 +3757,46 @@ def test_asset_service_grpc_lro_async_client(): assert transport.operations_client is transport.operations_client +def test_access_level_path(): + access_policy = "squid" + access_level = "clam" + expected = "accessPolicies/{access_policy}/accessLevels/{access_level}".format( + access_policy=access_policy, access_level=access_level, + ) + actual = AssetServiceClient.access_level_path(access_policy, access_level) + assert expected == actual + + +def test_parse_access_level_path(): + expected = { + "access_policy": "whelk", + "access_level": "octopus", + } + path = AssetServiceClient.access_level_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_access_level_path(path) + assert expected == actual + + +def test_access_policy_path(): + access_policy = "oyster" + expected = "accessPolicies/{access_policy}".format(access_policy=access_policy,) + actual = AssetServiceClient.access_policy_path(access_policy) + assert expected == actual + + +def test_parse_access_policy_path(): + expected = { + "access_policy": "nudibranch", + } + path = AssetServiceClient.access_policy_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_access_policy_path(path) + assert expected == actual + + def test_asset_path(): expected = "*".format() actual = AssetServiceClient.asset_path() @@ -3764,8 +3804,8 @@ def test_asset_path(): def test_feed_path(): - project = "squid" - feed = "clam" + project = "cuttlefish" + feed = "mussel" expected = "projects/{project}/feeds/{feed}".format(project=project, feed=feed,) actual = AssetServiceClient.feed_path(project, feed) assert expected == actual @@ -3773,8 +3813,8 @@ def test_feed_path(): def test_parse_feed_path(): expected = { - "project": "whelk", - "feed": "octopus", + "project": "winkle", + "feed": "nautilus", } path = AssetServiceClient.feed_path(**expected) @@ -3783,8 +3823,30 @@ def test_parse_feed_path(): assert expected == actual +def test_service_perimeter_path(): + access_policy = "scallop" + service_perimeter = "abalone" + expected = "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, service_perimeter=service_perimeter, + ) + actual = AssetServiceClient.service_perimeter_path(access_policy, service_perimeter) + assert expected == actual + + +def test_parse_service_perimeter_path(): + expected = { + "access_policy": "squid", + "service_perimeter": "clam", + } + path = AssetServiceClient.service_perimeter_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_service_perimeter_path(path) + assert expected == actual + + def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3794,7 +3856,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "octopus", } path = AssetServiceClient.common_billing_account_path(**expected) @@ -3804,7 +3866,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "oyster" expected = "folders/{folder}".format(folder=folder,) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -3812,7 +3874,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "nudibranch", } path = AssetServiceClient.common_folder_path(**expected) @@ -3822,7 +3884,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "cuttlefish" expected = "organizations/{organization}".format(organization=organization,) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -3830,7 +3892,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "mussel", } path = AssetServiceClient.common_organization_path(**expected) @@ -3840,7 +3902,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "winkle" expected = "projects/{project}".format(project=project,) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -3848,7 +3910,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "nautilus", } path = AssetServiceClient.common_project_path(**expected) @@ -3858,8 +3920,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3869,8 +3931,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "squid", + "location": "clam", } path = AssetServiceClient.common_location_path(**expected) diff --git a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index 804094606e46..3070a9704e58 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -1164,14 +1164,76 @@ def test_asset_service_transport_channel_mtls_with_adc(transport_class): assert transport.grpc_channel == mock_grpc_channel +def test_access_level_path(): + access_policy = "squid" + access_level = "clam" + expected = "accessPolicies/{access_policy}/accessLevels/{access_level}".format( + access_policy=access_policy, access_level=access_level, + ) + actual = AssetServiceClient.access_level_path(access_policy, access_level) + assert expected == actual + + +def test_parse_access_level_path(): + expected = { + "access_policy": "whelk", + "access_level": "octopus", + } + path = AssetServiceClient.access_level_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_access_level_path(path) + assert expected == actual + + +def test_access_policy_path(): + access_policy = "oyster" + expected = "accessPolicies/{access_policy}".format(access_policy=access_policy,) + actual = AssetServiceClient.access_policy_path(access_policy) + assert expected == actual + + +def test_parse_access_policy_path(): + expected = { + "access_policy": "nudibranch", + } + path = AssetServiceClient.access_policy_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_access_policy_path(path) + assert expected == actual + + def test_asset_path(): expected = "*".format() actual = AssetServiceClient.asset_path() assert expected == actual +def test_service_perimeter_path(): + access_policy = "cuttlefish" + service_perimeter = "mussel" + expected = "accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}".format( + access_policy=access_policy, service_perimeter=service_perimeter, + ) + actual = AssetServiceClient.service_perimeter_path(access_policy, service_perimeter) + assert expected == actual + + +def test_parse_service_perimeter_path(): + expected = { + "access_policy": "winkle", + "service_perimeter": "nautilus", + } + path = AssetServiceClient.service_perimeter_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_service_perimeter_path(path) + assert expected == actual + + def test_common_billing_account_path(): - billing_account = "squid" + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1181,7 +1243,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "clam", + "billing_account": "abalone", } path = AssetServiceClient.common_billing_account_path(**expected) @@ -1191,7 +1253,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "whelk" + folder = "squid" expected = "folders/{folder}".format(folder=folder,) actual = AssetServiceClient.common_folder_path(folder) assert expected == actual @@ -1199,7 +1261,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "octopus", + "folder": "clam", } path = AssetServiceClient.common_folder_path(**expected) @@ -1209,7 +1271,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "oyster" + organization = "whelk" expected = "organizations/{organization}".format(organization=organization,) actual = AssetServiceClient.common_organization_path(organization) assert expected == actual @@ -1217,7 +1279,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nudibranch", + "organization": "octopus", } path = AssetServiceClient.common_organization_path(**expected) @@ -1227,7 +1289,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "cuttlefish" + project = "oyster" expected = "projects/{project}".format(project=project,) actual = AssetServiceClient.common_project_path(project) assert expected == actual @@ -1235,7 +1297,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "mussel", + "project": "nudibranch", } path = AssetServiceClient.common_project_path(**expected) @@ -1245,8 +1307,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "winkle" - location = "nautilus" + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1256,8 +1318,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "scallop", - "location": "abalone", + "project": "winkle", + "location": "nautilus", } path = AssetServiceClient.common_location_path(**expected)