Skip to content
Permalink
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
  • Loading branch information
yoshi-automation committed Feb 11, 2021
1 parent a42d173 commit 2c483c8ec24bba25fdea7a1f46d3d5396fe2076a
@@ -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
@@ -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"
)
@@ -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",
@@ -134,9 +143,11 @@
"CreateEntitlementRequest",
"Customer",
"CustomerConstraints",
"CustomerEvent",
"DeleteCustomerRequest",
"EduData",
"Entitlement",
"EntitlementEvent",
"GetChannelPartnerLinkRequest",
"GetCustomerRequest",
"GetEntitlementRequest",
@@ -156,6 +167,8 @@
"ListPurchasableSkusResponse",
"ListSkusRequest",
"ListSkusResponse",
"ListSubscribersRequest",
"ListSubscribersResponse",
"ListTransferableOffersRequest",
"ListTransferableOffersResponse",
"ListTransferableSkusRequest",
@@ -182,10 +195,13 @@
"ProvisionedService",
"PurchasableOffer",
"PurchasableSku",
"RegisterSubscriberRequest",
"RegisterSubscriberResponse",
"RenewalSettings",
"ResourceType",
"Sku",
"StartPaidServiceRequest",
"SubscriberEvent",
"SuspendEntitlementRequest",
"TransferEligibility",
"TransferEntitlementsRequest",
@@ -194,6 +210,8 @@
"TransferableOffer",
"TransferableSku",
"TrialSettings",
"UnregisterSubscriberRequest",
"UnregisterSubscriberResponse",
"UpdateChannelPartnerLinkRequest",
"UpdateCustomerRequest",
"Value",
@@ -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__ = (
@@ -126,9 +135,11 @@
"CreateEntitlementRequest",
"Customer",
"CustomerConstraints",
"CustomerEvent",
"DeleteCustomerRequest",
"EduData",
"Entitlement",
"EntitlementEvent",
"GetChannelPartnerLinkRequest",
"GetCustomerRequest",
"GetEntitlementRequest",
@@ -148,6 +159,8 @@
"ListPurchasableSkusResponse",
"ListSkusRequest",
"ListSkusResponse",
"ListSubscribersRequest",
"ListSubscribersResponse",
"ListTransferableOffersRequest",
"ListTransferableOffersResponse",
"ListTransferableSkusRequest",
@@ -174,10 +187,13 @@
"ProvisionedService",
"PurchasableOffer",
"PurchasableSku",
"RegisterSubscriberRequest",
"RegisterSubscriberResponse",
"RenewalSettings",
"ResourceType",
"Sku",
"StartPaidServiceRequest",
"SubscriberEvent",
"SuspendEntitlementRequest",
"TransferEligibility",
"TransferEntitlementsRequest",
@@ -186,6 +202,8 @@
"TransferableOffer",
"TransferableSku",
"TrialSettings",
"UnregisterSubscriberRequest",
"UnregisterSubscriberResponse",
"UpdateChannelPartnerLinkRequest",
"UpdateCustomerRequest",
"Value",
@@ -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(
Loading

0 comments on commit 2c483c8

Please sign in to comment.