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

Commit 2c483c8

Browse files
feat: add Pub/Sub endpoints for Cloud Channnel API (#9)
* feat: Add Pub/Sub endpoints for Cloud Channel API. PiperOrigin-RevId: 355059873 Source-Author: Google APIs <noreply@google.com> Source-Date: Mon Feb 1 17:13:22 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 6ef9eaea379fc1cc0355e06a5a20b594543ee693 Source-Link: googleapis/googleapis@6ef9eae
1 parent a42d173 commit 2c483c8

16 files changed

Lines changed: 1870 additions & 106 deletions

File tree

.kokoro/test-samples.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ for file in samples/**/requirements.txt; do
8787
python3.6 -m nox -s "$RUN_TESTS_SESSION"
8888
EXIT=$?
8989

90-
# If this is a periodic build, send the test log to the FlakyBot.
91-
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
90+
# If this is a periodic build, send the test log to the Build Cop Bot.
91+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
9292
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
93-
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
94-
$KOKORO_GFILE_DIR/linux_amd64/flakybot
93+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
94+
$KOKORO_GFILE_DIR/linux_amd64/buildcop
9595
fi
9696

9797
if [[ $EXIT -ne 0 ]]; then

.kokoro/trampoline_v2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then
159159
"KOKORO_GITHUB_COMMIT"
160160
"KOKORO_GITHUB_PULL_REQUEST_NUMBER"
161161
"KOKORO_GITHUB_PULL_REQUEST_COMMIT"
162-
# For FlakyBot
162+
# For Build Cop Bot
163163
"KOKORO_GITHUB_COMMIT_URL"
164164
"KOKORO_GITHUB_PULL_REQUEST_URL"
165165
)

google/cloud/channel/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,30 @@
9393
from google.cloud.channel_v1.types.service import ListPurchasableSkusResponse
9494
from google.cloud.channel_v1.types.service import ListSkusRequest
9595
from google.cloud.channel_v1.types.service import ListSkusResponse
96+
from google.cloud.channel_v1.types.service import ListSubscribersRequest
97+
from google.cloud.channel_v1.types.service import ListSubscribersResponse
9698
from google.cloud.channel_v1.types.service import ListTransferableOffersRequest
9799
from google.cloud.channel_v1.types.service import ListTransferableOffersResponse
98100
from google.cloud.channel_v1.types.service import ListTransferableSkusRequest
99101
from google.cloud.channel_v1.types.service import ListTransferableSkusResponse
100102
from google.cloud.channel_v1.types.service import ProvisionCloudIdentityRequest
101103
from google.cloud.channel_v1.types.service import PurchasableOffer
102104
from google.cloud.channel_v1.types.service import PurchasableSku
105+
from google.cloud.channel_v1.types.service import RegisterSubscriberRequest
106+
from google.cloud.channel_v1.types.service import RegisterSubscriberResponse
103107
from google.cloud.channel_v1.types.service import StartPaidServiceRequest
104108
from google.cloud.channel_v1.types.service import SuspendEntitlementRequest
105109
from google.cloud.channel_v1.types.service import TransferEntitlementsRequest
106110
from google.cloud.channel_v1.types.service import TransferEntitlementsResponse
107111
from google.cloud.channel_v1.types.service import TransferEntitlementsToGoogleRequest
108112
from google.cloud.channel_v1.types.service import TransferableOffer
113+
from google.cloud.channel_v1.types.service import UnregisterSubscriberRequest
114+
from google.cloud.channel_v1.types.service import UnregisterSubscriberResponse
109115
from google.cloud.channel_v1.types.service import UpdateChannelPartnerLinkRequest
110116
from google.cloud.channel_v1.types.service import UpdateCustomerRequest
117+
from google.cloud.channel_v1.types.subscriber_event import CustomerEvent
118+
from google.cloud.channel_v1.types.subscriber_event import EntitlementEvent
119+
from google.cloud.channel_v1.types.subscriber_event import SubscriberEvent
111120

112121
__all__ = (
113122
"ActivateEntitlementRequest",
@@ -134,9 +143,11 @@
134143
"CreateEntitlementRequest",
135144
"Customer",
136145
"CustomerConstraints",
146+
"CustomerEvent",
137147
"DeleteCustomerRequest",
138148
"EduData",
139149
"Entitlement",
150+
"EntitlementEvent",
140151
"GetChannelPartnerLinkRequest",
141152
"GetCustomerRequest",
142153
"GetEntitlementRequest",
@@ -156,6 +167,8 @@
156167
"ListPurchasableSkusResponse",
157168
"ListSkusRequest",
158169
"ListSkusResponse",
170+
"ListSubscribersRequest",
171+
"ListSubscribersResponse",
159172
"ListTransferableOffersRequest",
160173
"ListTransferableOffersResponse",
161174
"ListTransferableSkusRequest",
@@ -182,10 +195,13 @@
182195
"ProvisionedService",
183196
"PurchasableOffer",
184197
"PurchasableSku",
198+
"RegisterSubscriberRequest",
199+
"RegisterSubscriberResponse",
185200
"RenewalSettings",
186201
"ResourceType",
187202
"Sku",
188203
"StartPaidServiceRequest",
204+
"SubscriberEvent",
189205
"SuspendEntitlementRequest",
190206
"TransferEligibility",
191207
"TransferEntitlementsRequest",
@@ -194,6 +210,8 @@
194210
"TransferableOffer",
195211
"TransferableSku",
196212
"TrialSettings",
213+
"UnregisterSubscriberRequest",
214+
"UnregisterSubscriberResponse",
197215
"UpdateChannelPartnerLinkRequest",
198216
"UpdateCustomerRequest",
199217
"Value",

google/cloud/channel_v1/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,30 @@
8686
from .types.service import ListPurchasableSkusResponse
8787
from .types.service import ListSkusRequest
8888
from .types.service import ListSkusResponse
89+
from .types.service import ListSubscribersRequest
90+
from .types.service import ListSubscribersResponse
8991
from .types.service import ListTransferableOffersRequest
9092
from .types.service import ListTransferableOffersResponse
9193
from .types.service import ListTransferableSkusRequest
9294
from .types.service import ListTransferableSkusResponse
9395
from .types.service import ProvisionCloudIdentityRequest
9496
from .types.service import PurchasableOffer
9597
from .types.service import PurchasableSku
98+
from .types.service import RegisterSubscriberRequest
99+
from .types.service import RegisterSubscriberResponse
96100
from .types.service import StartPaidServiceRequest
97101
from .types.service import SuspendEntitlementRequest
98102
from .types.service import TransferEntitlementsRequest
99103
from .types.service import TransferEntitlementsResponse
100104
from .types.service import TransferEntitlementsToGoogleRequest
101105
from .types.service import TransferableOffer
106+
from .types.service import UnregisterSubscriberRequest
107+
from .types.service import UnregisterSubscriberResponse
102108
from .types.service import UpdateChannelPartnerLinkRequest
103109
from .types.service import UpdateCustomerRequest
110+
from .types.subscriber_event import CustomerEvent
111+
from .types.subscriber_event import EntitlementEvent
112+
from .types.subscriber_event import SubscriberEvent
104113

105114

106115
__all__ = (
@@ -126,9 +135,11 @@
126135
"CreateEntitlementRequest",
127136
"Customer",
128137
"CustomerConstraints",
138+
"CustomerEvent",
129139
"DeleteCustomerRequest",
130140
"EduData",
131141
"Entitlement",
142+
"EntitlementEvent",
132143
"GetChannelPartnerLinkRequest",
133144
"GetCustomerRequest",
134145
"GetEntitlementRequest",
@@ -148,6 +159,8 @@
148159
"ListPurchasableSkusResponse",
149160
"ListSkusRequest",
150161
"ListSkusResponse",
162+
"ListSubscribersRequest",
163+
"ListSubscribersResponse",
151164
"ListTransferableOffersRequest",
152165
"ListTransferableOffersResponse",
153166
"ListTransferableSkusRequest",
@@ -174,10 +187,13 @@
174187
"ProvisionedService",
175188
"PurchasableOffer",
176189
"PurchasableSku",
190+
"RegisterSubscriberRequest",
191+
"RegisterSubscriberResponse",
177192
"RenewalSettings",
178193
"ResourceType",
179194
"Sku",
180195
"StartPaidServiceRequest",
196+
"SubscriberEvent",
181197
"SuspendEntitlementRequest",
182198
"TransferEligibility",
183199
"TransferEntitlementsRequest",
@@ -186,6 +202,8 @@
186202
"TransferableOffer",
187203
"TransferableSku",
188204
"TrialSettings",
205+
"UnregisterSubscriberRequest",
206+
"UnregisterSubscriberResponse",
189207
"UpdateChannelPartnerLinkRequest",
190208
"UpdateCustomerRequest",
191209
"Value",

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

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,6 +2608,223 @@ async def list_purchasable_offers(
26082608
# Done; return the response.
26092609
return response
26102610

2611+
async def register_subscriber(
2612+
self,
2613+
request: service.RegisterSubscriberRequest = None,
2614+
*,
2615+
retry: retries.Retry = gapic_v1.method.DEFAULT,
2616+
timeout: float = None,
2617+
metadata: Sequence[Tuple[str, str]] = (),
2618+
) -> service.RegisterSubscriberResponse:
2619+
r"""Registers a service account with subscriber privileges on the
2620+
Cloud Pub/Sub topic created for this Channel Services account.
2621+
Once you create a subscriber, you will get the events as per
2622+
[SubscriberEvent][google.cloud.channel.v1.SubscriberEvent]
2623+
2624+
Possible Error Codes:
2625+
2626+
- PERMISSION_DENIED: If the reseller account making the request
2627+
and the reseller account being provided are different, or if
2628+
the impersonated user is not a super admin.
2629+
- INVALID_ARGUMENT: Missing or invalid required parameters in
2630+
the request.
2631+
- INTERNAL: Any non-user error related to a technical issue in
2632+
the backend. In this case, contact Cloud Channel support.
2633+
- UNKNOWN: Any non-user error related to a technical issue in
2634+
the backend. In this case, contact Cloud Channel support.
2635+
2636+
Return Value: Topic name with service email address registered
2637+
if successful, otherwise error is returned.
2638+
2639+
Args:
2640+
request (:class:`google.cloud.channel_v1.types.RegisterSubscriberRequest`):
2641+
The request object. Request Message for
2642+
RegisterSubscriber.
2643+
2644+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2645+
should be retried.
2646+
timeout (float): The timeout for this request.
2647+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2648+
sent along with the request as metadata.
2649+
2650+
Returns:
2651+
google.cloud.channel_v1.types.RegisterSubscriberResponse:
2652+
Response Message for
2653+
RegisterSubscriber.
2654+
2655+
"""
2656+
# Create or coerce a protobuf request object.
2657+
2658+
request = service.RegisterSubscriberRequest(request)
2659+
2660+
# Wrap the RPC method; this adds retry and timeout information,
2661+
# and friendly error handling.
2662+
rpc = gapic_v1.method_async.wrap_method(
2663+
self._client._transport.register_subscriber,
2664+
default_timeout=None,
2665+
client_info=DEFAULT_CLIENT_INFO,
2666+
)
2667+
2668+
# Certain fields should be provided within the metadata header;
2669+
# add these here.
2670+
metadata = tuple(metadata) + (
2671+
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
2672+
)
2673+
2674+
# Send the request.
2675+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2676+
2677+
# Done; return the response.
2678+
return response
2679+
2680+
async def unregister_subscriber(
2681+
self,
2682+
request: service.UnregisterSubscriberRequest = None,
2683+
*,
2684+
retry: retries.Retry = gapic_v1.method.DEFAULT,
2685+
timeout: float = None,
2686+
metadata: Sequence[Tuple[str, str]] = (),
2687+
) -> service.UnregisterSubscriberResponse:
2688+
r"""Unregisters a service account with subscriber privileges on the
2689+
Cloud Pub/Sub topic created for this Channel Services account.
2690+
If there are no more service account left with sunbscriber
2691+
privileges, the topic will be deleted. You can check this by
2692+
calling ListSubscribers api.
2693+
2694+
Possible Error Codes:
2695+
2696+
- PERMISSION_DENIED: If the reseller account making the request
2697+
and the reseller account being provided are different, or if
2698+
the impersonated user is not a super admin.
2699+
- INVALID_ARGUMENT: Missing or invalid required parameters in
2700+
the request.
2701+
- NOT_FOUND: If the topic resource doesn't exist.
2702+
- INTERNAL: Any non-user error related to a technical issue in
2703+
the backend. In this case, contact Cloud Channel support.
2704+
- UNKNOWN: Any non-user error related to a technical issue in
2705+
the backend. In this case, contact Cloud Channel support.
2706+
2707+
Return Value: Topic name from which service email address has
2708+
been unregistered if successful, otherwise error is returned. If
2709+
the service email was already not associated with the topic, the
2710+
success response will be returned.
2711+
2712+
Args:
2713+
request (:class:`google.cloud.channel_v1.types.UnregisterSubscriberRequest`):
2714+
The request object. Request Message for
2715+
UnregisterSubscriber.
2716+
2717+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2718+
should be retried.
2719+
timeout (float): The timeout for this request.
2720+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2721+
sent along with the request as metadata.
2722+
2723+
Returns:
2724+
google.cloud.channel_v1.types.UnregisterSubscriberResponse:
2725+
Response Message for
2726+
UnregisterSubscriber.
2727+
2728+
"""
2729+
# Create or coerce a protobuf request object.
2730+
2731+
request = service.UnregisterSubscriberRequest(request)
2732+
2733+
# Wrap the RPC method; this adds retry and timeout information,
2734+
# and friendly error handling.
2735+
rpc = gapic_v1.method_async.wrap_method(
2736+
self._client._transport.unregister_subscriber,
2737+
default_timeout=None,
2738+
client_info=DEFAULT_CLIENT_INFO,
2739+
)
2740+
2741+
# Certain fields should be provided within the metadata header;
2742+
# add these here.
2743+
metadata = tuple(metadata) + (
2744+
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
2745+
)
2746+
2747+
# Send the request.
2748+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2749+
2750+
# Done; return the response.
2751+
return response
2752+
2753+
async def list_subscribers(
2754+
self,
2755+
request: service.ListSubscribersRequest = None,
2756+
*,
2757+
retry: retries.Retry = gapic_v1.method.DEFAULT,
2758+
timeout: float = None,
2759+
metadata: Sequence[Tuple[str, str]] = (),
2760+
) -> pagers.ListSubscribersAsyncPager:
2761+
r"""Lists service accounts with subscriber privileges on the Cloud
2762+
Pub/Sub topic created for this Channel Services account.
2763+
2764+
Possible Error Codes:
2765+
2766+
- PERMISSION_DENIED: If the reseller account making the request
2767+
and the reseller account being provided are different, or if
2768+
the account is not a super admin.
2769+
- INVALID_ARGUMENT: Missing or invalid required parameters in
2770+
the request.
2771+
- NOT_FOUND: If the topic resource doesn't exist.
2772+
- INTERNAL: Any non-user error related to a technical issue in
2773+
the backend. In this case, contact Cloud Channel support.
2774+
- UNKNOWN: Any non-user error related to a technical issue in
2775+
the backend. In this case, contact Cloud Channel support.
2776+
2777+
Return Value: List of service email addresses if successful,
2778+
otherwise error is returned.
2779+
2780+
Args:
2781+
request (:class:`google.cloud.channel_v1.types.ListSubscribersRequest`):
2782+
The request object. Request Message for ListSubscribers.
2783+
2784+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
2785+
should be retried.
2786+
timeout (float): The timeout for this request.
2787+
metadata (Sequence[Tuple[str, str]]): Strings which should be
2788+
sent along with the request as metadata.
2789+
2790+
Returns:
2791+
google.cloud.channel_v1.services.cloud_channel_service.pagers.ListSubscribersAsyncPager:
2792+
Response Message for ListSubscribers.
2793+
Iterating over this object will yield
2794+
results and resolve additional pages
2795+
automatically.
2796+
2797+
"""
2798+
# Create or coerce a protobuf request object.
2799+
2800+
request = service.ListSubscribersRequest(request)
2801+
2802+
# Wrap the RPC method; this adds retry and timeout information,
2803+
# and friendly error handling.
2804+
rpc = gapic_v1.method_async.wrap_method(
2805+
self._client._transport.list_subscribers,
2806+
default_timeout=None,
2807+
client_info=DEFAULT_CLIENT_INFO,
2808+
)
2809+
2810+
# Certain fields should be provided within the metadata header;
2811+
# add these here.
2812+
metadata = tuple(metadata) + (
2813+
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
2814+
)
2815+
2816+
# Send the request.
2817+
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
2818+
2819+
# This method is paged; wrap the response in a pager, which provides
2820+
# an `__aiter__` convenience method.
2821+
response = pagers.ListSubscribersAsyncPager(
2822+
method=rpc, request=request, response=response, metadata=metadata,
2823+
)
2824+
2825+
# Done; return the response.
2826+
return response
2827+
26112828

26122829
try:
26132830
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(

0 commit comments

Comments
 (0)