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

feat: add Pub/Sub endpoints for Cloud Channnel API #9

Merged
merged 5 commits into from Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .kokoro/test-samples.sh
Expand Up @@ -87,11 +87,11 @@ for file in samples/**/requirements.txt; do
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

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

if [[ $EXIT -ne 0 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/trampoline_v2.sh
Expand Up @@ -159,7 +159,7 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then
"KOKORO_GITHUB_COMMIT"
"KOKORO_GITHUB_PULL_REQUEST_NUMBER"
"KOKORO_GITHUB_PULL_REQUEST_COMMIT"
# For FlakyBot
# For Build Cop Bot
"KOKORO_GITHUB_COMMIT_URL"
"KOKORO_GITHUB_PULL_REQUEST_URL"
)
Expand Down
18 changes: 18 additions & 0 deletions google/cloud/channel/__init__.py
Expand Up @@ -93,21 +93,30 @@
from google.cloud.channel_v1.types.service import ListPurchasableSkusResponse
from google.cloud.channel_v1.types.service import ListSkusRequest
from google.cloud.channel_v1.types.service import ListSkusResponse
from google.cloud.channel_v1.types.service import ListSubscribersRequest
from google.cloud.channel_v1.types.service import ListSubscribersResponse
from google.cloud.channel_v1.types.service import ListTransferableOffersRequest
from google.cloud.channel_v1.types.service import ListTransferableOffersResponse
from google.cloud.channel_v1.types.service import ListTransferableSkusRequest
from google.cloud.channel_v1.types.service import ListTransferableSkusResponse
from google.cloud.channel_v1.types.service import ProvisionCloudIdentityRequest
from google.cloud.channel_v1.types.service import PurchasableOffer
from google.cloud.channel_v1.types.service import PurchasableSku
from google.cloud.channel_v1.types.service import RegisterSubscriberRequest
from google.cloud.channel_v1.types.service import RegisterSubscriberResponse
from google.cloud.channel_v1.types.service import StartPaidServiceRequest
from google.cloud.channel_v1.types.service import SuspendEntitlementRequest
from google.cloud.channel_v1.types.service import TransferEntitlementsRequest
from google.cloud.channel_v1.types.service import TransferEntitlementsResponse
from google.cloud.channel_v1.types.service import TransferEntitlementsToGoogleRequest
from google.cloud.channel_v1.types.service import TransferableOffer
from google.cloud.channel_v1.types.service import UnregisterSubscriberRequest
from google.cloud.channel_v1.types.service import UnregisterSubscriberResponse
from google.cloud.channel_v1.types.service import UpdateChannelPartnerLinkRequest
from google.cloud.channel_v1.types.service import UpdateCustomerRequest
from google.cloud.channel_v1.types.subscriber_event import CustomerEvent
from google.cloud.channel_v1.types.subscriber_event import EntitlementEvent
from google.cloud.channel_v1.types.subscriber_event import SubscriberEvent

__all__ = (
"ActivateEntitlementRequest",
Expand All @@ -134,9 +143,11 @@
"CreateEntitlementRequest",
"Customer",
"CustomerConstraints",
"CustomerEvent",
"DeleteCustomerRequest",
"EduData",
"Entitlement",
"EntitlementEvent",
"GetChannelPartnerLinkRequest",
"GetCustomerRequest",
"GetEntitlementRequest",
Expand All @@ -156,6 +167,8 @@
"ListPurchasableSkusResponse",
"ListSkusRequest",
"ListSkusResponse",
"ListSubscribersRequest",
"ListSubscribersResponse",
"ListTransferableOffersRequest",
"ListTransferableOffersResponse",
"ListTransferableSkusRequest",
Expand All @@ -182,10 +195,13 @@
"ProvisionedService",
"PurchasableOffer",
"PurchasableSku",
"RegisterSubscriberRequest",
"RegisterSubscriberResponse",
"RenewalSettings",
"ResourceType",
"Sku",
"StartPaidServiceRequest",
"SubscriberEvent",
"SuspendEntitlementRequest",
"TransferEligibility",
"TransferEntitlementsRequest",
Expand All @@ -194,6 +210,8 @@
"TransferableOffer",
"TransferableSku",
"TrialSettings",
"UnregisterSubscriberRequest",
"UnregisterSubscriberResponse",
"UpdateChannelPartnerLinkRequest",
"UpdateCustomerRequest",
"Value",
Expand Down
18 changes: 18 additions & 0 deletions google/cloud/channel_v1/__init__.py
Expand Up @@ -86,21 +86,30 @@
from .types.service import ListPurchasableSkusResponse
from .types.service import ListSkusRequest
from .types.service import ListSkusResponse
from .types.service import ListSubscribersRequest
from .types.service import ListSubscribersResponse
from .types.service import ListTransferableOffersRequest
from .types.service import ListTransferableOffersResponse
from .types.service import ListTransferableSkusRequest
from .types.service import ListTransferableSkusResponse
from .types.service import ProvisionCloudIdentityRequest
from .types.service import PurchasableOffer
from .types.service import PurchasableSku
from .types.service import RegisterSubscriberRequest
from .types.service import RegisterSubscriberResponse
from .types.service import StartPaidServiceRequest
from .types.service import SuspendEntitlementRequest
from .types.service import TransferEntitlementsRequest
from .types.service import TransferEntitlementsResponse
from .types.service import TransferEntitlementsToGoogleRequest
from .types.service import TransferableOffer
from .types.service import UnregisterSubscriberRequest
from .types.service import UnregisterSubscriberResponse
from .types.service import UpdateChannelPartnerLinkRequest
from .types.service import UpdateCustomerRequest
from .types.subscriber_event import CustomerEvent
from .types.subscriber_event import EntitlementEvent
from .types.subscriber_event import SubscriberEvent


__all__ = (
Expand All @@ -126,9 +135,11 @@
"CreateEntitlementRequest",
"Customer",
"CustomerConstraints",
"CustomerEvent",
"DeleteCustomerRequest",
"EduData",
"Entitlement",
"EntitlementEvent",
"GetChannelPartnerLinkRequest",
"GetCustomerRequest",
"GetEntitlementRequest",
Expand All @@ -148,6 +159,8 @@
"ListPurchasableSkusResponse",
"ListSkusRequest",
"ListSkusResponse",
"ListSubscribersRequest",
"ListSubscribersResponse",
"ListTransferableOffersRequest",
"ListTransferableOffersResponse",
"ListTransferableSkusRequest",
Expand All @@ -174,10 +187,13 @@
"ProvisionedService",
"PurchasableOffer",
"PurchasableSku",
"RegisterSubscriberRequest",
"RegisterSubscriberResponse",
"RenewalSettings",
"ResourceType",
"Sku",
"StartPaidServiceRequest",
"SubscriberEvent",
"SuspendEntitlementRequest",
"TransferEligibility",
"TransferEntitlementsRequest",
Expand All @@ -186,6 +202,8 @@
"TransferableOffer",
"TransferableSku",
"TrialSettings",
"UnregisterSubscriberRequest",
"UnregisterSubscriberResponse",
"UpdateChannelPartnerLinkRequest",
"UpdateCustomerRequest",
"Value",
Expand Down
217 changes: 217 additions & 0 deletions google/cloud/channel_v1/services/cloud_channel_service/async_client.py
Expand Up @@ -2608,6 +2608,223 @@ async def list_purchasable_offers(
# Done; return the response.
return response

async def register_subscriber(
self,
request: service.RegisterSubscriberRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service.RegisterSubscriberResponse:
r"""Registers a service account with subscriber privileges on the
Cloud Pub/Sub topic created for this Channel Services account.
Once you create a subscriber, you will get the events as per
[SubscriberEvent][google.cloud.channel.v1.SubscriberEvent]

Possible Error Codes:

- PERMISSION_DENIED: If the reseller account making the request
and the reseller account being provided are different, or if
the impersonated user is not a super admin.
- INVALID_ARGUMENT: Missing or invalid required parameters in
the request.
- INTERNAL: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.
- UNKNOWN: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.

Return Value: Topic name with service email address registered
if successful, otherwise error is returned.

Args:
request (:class:`google.cloud.channel_v1.types.RegisterSubscriberRequest`):
The request object. Request Message for
RegisterSubscriber.

retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.channel_v1.types.RegisterSubscriberResponse:
Response Message for
RegisterSubscriber.

"""
# Create or coerce a protobuf request object.

request = service.RegisterSubscriberRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.register_subscriber,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Done; return the response.
return response

async def unregister_subscriber(
self,
request: service.UnregisterSubscriberRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> service.UnregisterSubscriberResponse:
r"""Unregisters a service account with subscriber privileges on the
Cloud Pub/Sub topic created for this Channel Services account.
If there are no more service account left with sunbscriber
privileges, the topic will be deleted. You can check this by
calling ListSubscribers api.

Possible Error Codes:

- PERMISSION_DENIED: If the reseller account making the request
and the reseller account being provided are different, or if
the impersonated user is not a super admin.
- INVALID_ARGUMENT: Missing or invalid required parameters in
the request.
- NOT_FOUND: If the topic resource doesn't exist.
- INTERNAL: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.
- UNKNOWN: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.

Return Value: Topic name from which service email address has
been unregistered if successful, otherwise error is returned. If
the service email was already not associated with the topic, the
success response will be returned.

Args:
request (:class:`google.cloud.channel_v1.types.UnregisterSubscriberRequest`):
The request object. Request Message for
UnregisterSubscriber.

retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.channel_v1.types.UnregisterSubscriberResponse:
Response Message for
UnregisterSubscriber.

"""
# Create or coerce a protobuf request object.

request = service.UnregisterSubscriberRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.unregister_subscriber,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# Done; return the response.
return response

async def list_subscribers(
self,
request: service.ListSubscribersRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListSubscribersAsyncPager:
r"""Lists service accounts with subscriber privileges on the Cloud
Pub/Sub topic created for this Channel Services account.

Possible Error Codes:

- PERMISSION_DENIED: If the reseller account making the request
and the reseller account being provided are different, or if
the account is not a super admin.
- INVALID_ARGUMENT: Missing or invalid required parameters in
the request.
- NOT_FOUND: If the topic resource doesn't exist.
- INTERNAL: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.
- UNKNOWN: Any non-user error related to a technical issue in
the backend. In this case, contact Cloud Channel support.

Return Value: List of service email addresses if successful,
otherwise error is returned.

Args:
request (:class:`google.cloud.channel_v1.types.ListSubscribersRequest`):
The request object. Request Message for ListSubscribers.

retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.channel_v1.services.cloud_channel_service.pagers.ListSubscribersAsyncPager:
Response Message for ListSubscribers.
Iterating over this object will yield
results and resolve additional pages
automatically.

"""
# Create or coerce a protobuf request object.

request = service.ListSubscribersRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_subscribers,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("account", request.account),)),
)

# Send the request.
response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

# This method is paged; wrap the response in a pager, which provides
# an `__aiter__` convenience method.
response = pagers.ListSubscribersAsyncPager(
method=rpc, request=request, response=response, metadata=metadata,
)

# Done; return the response.
return response


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down