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

Commit

Permalink
feat: add resource type to ChannelPartnerLink (#112)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 405947781

Source-Link: googleapis/googleapis@daf9c98

Source-Link: googleapis/googleapis-gen@d84824c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDg0ODI0Yzc4NTYzZDU5YjBlNThkNTY2NGJmYWE0MzBlOWFkN2U3YSJ9
  • Loading branch information
gcf-owl-bot[bot] committed Oct 27, 2021
1 parent 53cd8ff commit 76433c4
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 32 deletions.
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions google/cloud/channel_v1/services/cloud_channel_service/client.py
Expand Up @@ -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<account>.+?)/channelPartnerLinks/(?P<channel_partner_link>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def customer_path(account: str, customer: str,) -> str:
"""Returns a fully-qualified customer string."""
Expand Down
88 changes: 56 additions & 32 deletions tests/unit/gapic/channel_v1/test_cloud_channel_service.py
Expand Up @@ -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,
)
Expand All @@ -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)

Expand All @@ -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,
)
Expand All @@ -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)

Expand All @@ -7990,17 +8014,17 @@ 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


def test_parse_offer_path():
expected = {
"account": "squid",
"offer": "clam",
"account": "oyster",
"offer": "nudibranch",
}
path = CloudChannelServiceClient.offer_path(**expected)

Expand All @@ -8010,15 +8034,15 @@ 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


def test_parse_product_path():
expected = {
"product": "octopus",
"product": "mussel",
}
path = CloudChannelServiceClient.product_path(**expected)

Expand All @@ -8028,17 +8052,17 @@ 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


def test_parse_sku_path():
expected = {
"product": "cuttlefish",
"sku": "mussel",
"product": "scallop",
"sku": "abalone",
}
path = CloudChannelServiceClient.sku_path(**expected)

Expand All @@ -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,
)
Expand All @@ -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)

Expand All @@ -8068,15 +8092,15 @@ 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


def test_parse_common_folder_path():
expected = {
"folder": "abalone",
"folder": "octopus",
}
path = CloudChannelServiceClient.common_folder_path(**expected)

Expand All @@ -8086,15 +8110,15 @@ 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


def test_parse_common_organization_path():
expected = {
"organization": "clam",
"organization": "nudibranch",
}
path = CloudChannelServiceClient.common_organization_path(**expected)

Expand All @@ -8104,15 +8128,15 @@ 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


def test_parse_common_project_path():
expected = {
"project": "octopus",
"project": "mussel",
}
path = CloudChannelServiceClient.common_project_path(**expected)

Expand All @@ -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,
)
Expand All @@ -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)

Expand Down

0 comments on commit 76433c4

Please sign in to comment.