diff --git a/google/cloud/channel_v1/services/cloud_channel_service/async_client.py b/google/cloud/channel_v1/services/cloud_channel_service/async_client.py index 55bac3a..faa6f62 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/async_client.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/async_client.py @@ -76,6 +76,12 @@ class CloudChannelServiceAsyncClient: DEFAULT_ENDPOINT = CloudChannelServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = CloudChannelServiceClient.DEFAULT_MTLS_ENDPOINT + channel_partner_link_path = staticmethod( + CloudChannelServiceClient.channel_partner_link_path + ) + parse_channel_partner_link_path = staticmethod( + CloudChannelServiceClient.parse_channel_partner_link_path + ) customer_path = staticmethod(CloudChannelServiceClient.customer_path) parse_customer_path = staticmethod(CloudChannelServiceClient.parse_customer_path) entitlement_path = staticmethod(CloudChannelServiceClient.entitlement_path) diff --git a/google/cloud/channel_v1/services/cloud_channel_service/client.py b/google/cloud/channel_v1/services/cloud_channel_service/client.py index d384694..1d24eac 100644 --- a/google/cloud/channel_v1/services/cloud_channel_service/client.py +++ b/google/cloud/channel_v1/services/cloud_channel_service/client.py @@ -192,6 +192,22 @@ def transport(self) -> CloudChannelServiceTransport: """ return self._transport + @staticmethod + def channel_partner_link_path(account: str, channel_partner_link: str,) -> str: + """Returns a fully-qualified channel_partner_link string.""" + return "accounts/{account}/channelPartnerLinks/{channel_partner_link}".format( + account=account, channel_partner_link=channel_partner_link, + ) + + @staticmethod + def parse_channel_partner_link_path(path: str) -> Dict[str, str]: + """Parses a channel_partner_link path into its component segments.""" + m = re.match( + r"^accounts/(?P.+?)/channelPartnerLinks/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def customer_path(account: str, customer: str,) -> str: """Returns a fully-qualified customer string.""" diff --git a/tests/unit/gapic/channel_v1/test_cloud_channel_service.py b/tests/unit/gapic/channel_v1/test_cloud_channel_service.py index 1cc90eb..dbc719d 100644 --- a/tests/unit/gapic/channel_v1/test_cloud_channel_service.py +++ b/tests/unit/gapic/channel_v1/test_cloud_channel_service.py @@ -7943,9 +7943,33 @@ def test_cloud_channel_service_grpc_lro_async_client(): assert transport.operations_client is transport.operations_client -def test_customer_path(): +def test_channel_partner_link_path(): account = "squid" - customer = "clam" + channel_partner_link = "clam" + expected = "accounts/{account}/channelPartnerLinks/{channel_partner_link}".format( + account=account, channel_partner_link=channel_partner_link, + ) + actual = CloudChannelServiceClient.channel_partner_link_path( + account, channel_partner_link + ) + assert expected == actual + + +def test_parse_channel_partner_link_path(): + expected = { + "account": "whelk", + "channel_partner_link": "octopus", + } + path = CloudChannelServiceClient.channel_partner_link_path(**expected) + + # Check that the path construction is reversible. + actual = CloudChannelServiceClient.parse_channel_partner_link_path(path) + assert expected == actual + + +def test_customer_path(): + account = "oyster" + customer = "nudibranch" expected = "accounts/{account}/customers/{customer}".format( account=account, customer=customer, ) @@ -7955,8 +7979,8 @@ def test_customer_path(): def test_parse_customer_path(): expected = { - "account": "whelk", - "customer": "octopus", + "account": "cuttlefish", + "customer": "mussel", } path = CloudChannelServiceClient.customer_path(**expected) @@ -7966,9 +7990,9 @@ def test_parse_customer_path(): def test_entitlement_path(): - account = "oyster" - customer = "nudibranch" - entitlement = "cuttlefish" + account = "winkle" + customer = "nautilus" + entitlement = "scallop" expected = "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format( account=account, customer=customer, entitlement=entitlement, ) @@ -7978,9 +8002,9 @@ def test_entitlement_path(): def test_parse_entitlement_path(): expected = { - "account": "mussel", - "customer": "winkle", - "entitlement": "nautilus", + "account": "abalone", + "customer": "squid", + "entitlement": "clam", } path = CloudChannelServiceClient.entitlement_path(**expected) @@ -7990,8 +8014,8 @@ def test_parse_entitlement_path(): def test_offer_path(): - account = "scallop" - offer = "abalone" + account = "whelk" + offer = "octopus" expected = "accounts/{account}/offers/{offer}".format(account=account, offer=offer,) actual = CloudChannelServiceClient.offer_path(account, offer) assert expected == actual @@ -7999,8 +8023,8 @@ def test_offer_path(): def test_parse_offer_path(): expected = { - "account": "squid", - "offer": "clam", + "account": "oyster", + "offer": "nudibranch", } path = CloudChannelServiceClient.offer_path(**expected) @@ -8010,7 +8034,7 @@ def test_parse_offer_path(): def test_product_path(): - product = "whelk" + product = "cuttlefish" expected = "products/{product}".format(product=product,) actual = CloudChannelServiceClient.product_path(product) assert expected == actual @@ -8018,7 +8042,7 @@ def test_product_path(): def test_parse_product_path(): expected = { - "product": "octopus", + "product": "mussel", } path = CloudChannelServiceClient.product_path(**expected) @@ -8028,8 +8052,8 @@ def test_parse_product_path(): def test_sku_path(): - product = "oyster" - sku = "nudibranch" + product = "winkle" + sku = "nautilus" expected = "products/{product}/skus/{sku}".format(product=product, sku=sku,) actual = CloudChannelServiceClient.sku_path(product, sku) assert expected == actual @@ -8037,8 +8061,8 @@ def test_sku_path(): def test_parse_sku_path(): expected = { - "product": "cuttlefish", - "sku": "mussel", + "product": "scallop", + "sku": "abalone", } path = CloudChannelServiceClient.sku_path(**expected) @@ -8048,7 +8072,7 @@ def test_parse_sku_path(): def test_common_billing_account_path(): - billing_account = "winkle" + billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8058,7 +8082,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nautilus", + "billing_account": "clam", } path = CloudChannelServiceClient.common_billing_account_path(**expected) @@ -8068,7 +8092,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "scallop" + folder = "whelk" expected = "folders/{folder}".format(folder=folder,) actual = CloudChannelServiceClient.common_folder_path(folder) assert expected == actual @@ -8076,7 +8100,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "abalone", + "folder": "octopus", } path = CloudChannelServiceClient.common_folder_path(**expected) @@ -8086,7 +8110,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "squid" + organization = "oyster" expected = "organizations/{organization}".format(organization=organization,) actual = CloudChannelServiceClient.common_organization_path(organization) assert expected == actual @@ -8094,7 +8118,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "clam", + "organization": "nudibranch", } path = CloudChannelServiceClient.common_organization_path(**expected) @@ -8104,7 +8128,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "whelk" + project = "cuttlefish" expected = "projects/{project}".format(project=project,) actual = CloudChannelServiceClient.common_project_path(project) assert expected == actual @@ -8112,7 +8136,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "octopus", + "project": "mussel", } path = CloudChannelServiceClient.common_project_path(**expected) @@ -8122,8 +8146,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "oyster" - location = "nudibranch" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -8133,8 +8157,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "cuttlefish", - "location": "mussel", + "project": "scallop", + "location": "abalone", } path = CloudChannelServiceClient.common_location_path(**expected)