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

Commit 76433c4

Browse files
feat: add resource type to ChannelPartnerLink (#112)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 405947781 Source-Link: googleapis/googleapis@daf9c98 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d84824c78563d59b0e58d5664bfaa430e9ad7e7a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDg0ODI0Yzc4NTYzZDU5YjBlNThkNTY2NGJmYWE0MzBlOWFkN2U3YSJ9
1 parent 53cd8ff commit 76433c4

File tree

3 files changed

+78
-32
lines changed

3 files changed

+78
-32
lines changed

google/cloud/channel_v1/services/cloud_channel_service/async_client.py

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ class CloudChannelServiceAsyncClient:
7676
DEFAULT_ENDPOINT = CloudChannelServiceClient.DEFAULT_ENDPOINT
7777
DEFAULT_MTLS_ENDPOINT = CloudChannelServiceClient.DEFAULT_MTLS_ENDPOINT
7878

79+
channel_partner_link_path = staticmethod(
80+
CloudChannelServiceClient.channel_partner_link_path
81+
)
82+
parse_channel_partner_link_path = staticmethod(
83+
CloudChannelServiceClient.parse_channel_partner_link_path
84+
)
7985
customer_path = staticmethod(CloudChannelServiceClient.customer_path)
8086
parse_customer_path = staticmethod(CloudChannelServiceClient.parse_customer_path)
8187
entitlement_path = staticmethod(CloudChannelServiceClient.entitlement_path)

google/cloud/channel_v1/services/cloud_channel_service/client.py

+16
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@ def transport(self) -> CloudChannelServiceTransport:
192192
"""
193193
return self._transport
194194

195+
@staticmethod
196+
def channel_partner_link_path(account: str, channel_partner_link: str,) -> str:
197+
"""Returns a fully-qualified channel_partner_link string."""
198+
return "accounts/{account}/channelPartnerLinks/{channel_partner_link}".format(
199+
account=account, channel_partner_link=channel_partner_link,
200+
)
201+
202+
@staticmethod
203+
def parse_channel_partner_link_path(path: str) -> Dict[str, str]:
204+
"""Parses a channel_partner_link path into its component segments."""
205+
m = re.match(
206+
r"^accounts/(?P<account>.+?)/channelPartnerLinks/(?P<channel_partner_link>.+?)$",
207+
path,
208+
)
209+
return m.groupdict() if m else {}
210+
195211
@staticmethod
196212
def customer_path(account: str, customer: str,) -> str:
197213
"""Returns a fully-qualified customer string."""

tests/unit/gapic/channel_v1/test_cloud_channel_service.py

+56-32
Original file line numberDiff line numberDiff line change
@@ -7943,9 +7943,33 @@ def test_cloud_channel_service_grpc_lro_async_client():
79437943
assert transport.operations_client is transport.operations_client
79447944

79457945

7946-
def test_customer_path():
7946+
def test_channel_partner_link_path():
79477947
account = "squid"
7948-
customer = "clam"
7948+
channel_partner_link = "clam"
7949+
expected = "accounts/{account}/channelPartnerLinks/{channel_partner_link}".format(
7950+
account=account, channel_partner_link=channel_partner_link,
7951+
)
7952+
actual = CloudChannelServiceClient.channel_partner_link_path(
7953+
account, channel_partner_link
7954+
)
7955+
assert expected == actual
7956+
7957+
7958+
def test_parse_channel_partner_link_path():
7959+
expected = {
7960+
"account": "whelk",
7961+
"channel_partner_link": "octopus",
7962+
}
7963+
path = CloudChannelServiceClient.channel_partner_link_path(**expected)
7964+
7965+
# Check that the path construction is reversible.
7966+
actual = CloudChannelServiceClient.parse_channel_partner_link_path(path)
7967+
assert expected == actual
7968+
7969+
7970+
def test_customer_path():
7971+
account = "oyster"
7972+
customer = "nudibranch"
79497973
expected = "accounts/{account}/customers/{customer}".format(
79507974
account=account, customer=customer,
79517975
)
@@ -7955,8 +7979,8 @@ def test_customer_path():
79557979

79567980
def test_parse_customer_path():
79577981
expected = {
7958-
"account": "whelk",
7959-
"customer": "octopus",
7982+
"account": "cuttlefish",
7983+
"customer": "mussel",
79607984
}
79617985
path = CloudChannelServiceClient.customer_path(**expected)
79627986

@@ -7966,9 +7990,9 @@ def test_parse_customer_path():
79667990

79677991

79687992
def test_entitlement_path():
7969-
account = "oyster"
7970-
customer = "nudibranch"
7971-
entitlement = "cuttlefish"
7993+
account = "winkle"
7994+
customer = "nautilus"
7995+
entitlement = "scallop"
79727996
expected = "accounts/{account}/customers/{customer}/entitlements/{entitlement}".format(
79737997
account=account, customer=customer, entitlement=entitlement,
79747998
)
@@ -7978,9 +8002,9 @@ def test_entitlement_path():
79788002

79798003
def test_parse_entitlement_path():
79808004
expected = {
7981-
"account": "mussel",
7982-
"customer": "winkle",
7983-
"entitlement": "nautilus",
8005+
"account": "abalone",
8006+
"customer": "squid",
8007+
"entitlement": "clam",
79848008
}
79858009
path = CloudChannelServiceClient.entitlement_path(**expected)
79868010

@@ -7990,17 +8014,17 @@ def test_parse_entitlement_path():
79908014

79918015

79928016
def test_offer_path():
7993-
account = "scallop"
7994-
offer = "abalone"
8017+
account = "whelk"
8018+
offer = "octopus"
79958019
expected = "accounts/{account}/offers/{offer}".format(account=account, offer=offer,)
79968020
actual = CloudChannelServiceClient.offer_path(account, offer)
79978021
assert expected == actual
79988022

79998023

80008024
def test_parse_offer_path():
80018025
expected = {
8002-
"account": "squid",
8003-
"offer": "clam",
8026+
"account": "oyster",
8027+
"offer": "nudibranch",
80048028
}
80058029
path = CloudChannelServiceClient.offer_path(**expected)
80068030

@@ -8010,15 +8034,15 @@ def test_parse_offer_path():
80108034

80118035

80128036
def test_product_path():
8013-
product = "whelk"
8037+
product = "cuttlefish"
80148038
expected = "products/{product}".format(product=product,)
80158039
actual = CloudChannelServiceClient.product_path(product)
80168040
assert expected == actual
80178041

80188042

80198043
def test_parse_product_path():
80208044
expected = {
8021-
"product": "octopus",
8045+
"product": "mussel",
80228046
}
80238047
path = CloudChannelServiceClient.product_path(**expected)
80248048

@@ -8028,17 +8052,17 @@ def test_parse_product_path():
80288052

80298053

80308054
def test_sku_path():
8031-
product = "oyster"
8032-
sku = "nudibranch"
8055+
product = "winkle"
8056+
sku = "nautilus"
80338057
expected = "products/{product}/skus/{sku}".format(product=product, sku=sku,)
80348058
actual = CloudChannelServiceClient.sku_path(product, sku)
80358059
assert expected == actual
80368060

80378061

80388062
def test_parse_sku_path():
80398063
expected = {
8040-
"product": "cuttlefish",
8041-
"sku": "mussel",
8064+
"product": "scallop",
8065+
"sku": "abalone",
80428066
}
80438067
path = CloudChannelServiceClient.sku_path(**expected)
80448068

@@ -8048,7 +8072,7 @@ def test_parse_sku_path():
80488072

80498073

80508074
def test_common_billing_account_path():
8051-
billing_account = "winkle"
8075+
billing_account = "squid"
80528076
expected = "billingAccounts/{billing_account}".format(
80538077
billing_account=billing_account,
80548078
)
@@ -8058,7 +8082,7 @@ def test_common_billing_account_path():
80588082

80598083
def test_parse_common_billing_account_path():
80608084
expected = {
8061-
"billing_account": "nautilus",
8085+
"billing_account": "clam",
80628086
}
80638087
path = CloudChannelServiceClient.common_billing_account_path(**expected)
80648088

@@ -8068,15 +8092,15 @@ def test_parse_common_billing_account_path():
80688092

80698093

80708094
def test_common_folder_path():
8071-
folder = "scallop"
8095+
folder = "whelk"
80728096
expected = "folders/{folder}".format(folder=folder,)
80738097
actual = CloudChannelServiceClient.common_folder_path(folder)
80748098
assert expected == actual
80758099

80768100

80778101
def test_parse_common_folder_path():
80788102
expected = {
8079-
"folder": "abalone",
8103+
"folder": "octopus",
80808104
}
80818105
path = CloudChannelServiceClient.common_folder_path(**expected)
80828106

@@ -8086,15 +8110,15 @@ def test_parse_common_folder_path():
80868110

80878111

80888112
def test_common_organization_path():
8089-
organization = "squid"
8113+
organization = "oyster"
80908114
expected = "organizations/{organization}".format(organization=organization,)
80918115
actual = CloudChannelServiceClient.common_organization_path(organization)
80928116
assert expected == actual
80938117

80948118

80958119
def test_parse_common_organization_path():
80968120
expected = {
8097-
"organization": "clam",
8121+
"organization": "nudibranch",
80988122
}
80998123
path = CloudChannelServiceClient.common_organization_path(**expected)
81008124

@@ -8104,15 +8128,15 @@ def test_parse_common_organization_path():
81048128

81058129

81068130
def test_common_project_path():
8107-
project = "whelk"
8131+
project = "cuttlefish"
81088132
expected = "projects/{project}".format(project=project,)
81098133
actual = CloudChannelServiceClient.common_project_path(project)
81108134
assert expected == actual
81118135

81128136

81138137
def test_parse_common_project_path():
81148138
expected = {
8115-
"project": "octopus",
8139+
"project": "mussel",
81168140
}
81178141
path = CloudChannelServiceClient.common_project_path(**expected)
81188142

@@ -8122,8 +8146,8 @@ def test_parse_common_project_path():
81228146

81238147

81248148
def test_common_location_path():
8125-
project = "oyster"
8126-
location = "nudibranch"
8149+
project = "winkle"
8150+
location = "nautilus"
81278151
expected = "projects/{project}/locations/{location}".format(
81288152
project=project, location=location,
81298153
)
@@ -8133,8 +8157,8 @@ def test_common_location_path():
81338157

81348158
def test_parse_common_location_path():
81358159
expected = {
8136-
"project": "cuttlefish",
8137-
"location": "mussel",
8160+
"project": "scallop",
8161+
"location": "abalone",
81388162
}
81398163
path = CloudChannelServiceClient.common_location_path(**expected)
81408164

0 commit comments

Comments
 (0)