Skip to content

Commit

Permalink
feat: Add Pub/Sub endpoints for Cloud Channel API.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 355059873
  • Loading branch information
Google APIs authored and Copybara-Service committed Feb 2, 2021
1 parent 20712b8 commit 6ef9eae
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 1 deletion.
4 changes: 3 additions & 1 deletion google/cloud/channel/v1/BUILD.bazel
Expand Up @@ -29,6 +29,7 @@ proto_library(
"operations.proto",
"products.proto",
"service.proto",
"subscriber_event.proto",
],
deps = [
"//google/api:annotations_proto",
Expand Down Expand Up @@ -81,6 +82,7 @@ java_gapic_library(
name = "channel_java_gapic",
srcs = [":channel_proto_with_info"],
grpc_service_config = "cloudchannel_grpc_service_config.json",
package = "google.cloud.channel.v1",
test_deps = [
":channel_java_grpc",
],
Expand All @@ -92,7 +94,6 @@ java_gapic_library(
java_gapic_test(
name = "channel_java_gapic_test_suite",
test_classes = [
"com.google.cloud.channel.v1.CloudChannelServiceClientTest",
],
runtime_deps = [":channel_java_gapic_test"],
)
Expand Down Expand Up @@ -243,6 +244,7 @@ load(

nodejs_gapic_library(
name = "channel_nodejs_gapic",
package_name = "@google-cloud/channel",
src = ":channel_proto_with_info",
extra_protoc_parameters = ["metadata"],
grpc_service_config = "cloudchannel_grpc_service_config.json",
Expand Down
3 changes: 3 additions & 0 deletions google/cloud/channel/v1/cloudchannel_v1.yaml
Expand Up @@ -7,7 +7,10 @@ apis:
- name: google.cloud.channel.v1.CloudChannelService

types:
- name: google.cloud.channel.v1.CustomerEvent
- name: google.cloud.channel.v1.EntitlementEvent
- name: google.cloud.channel.v1.OperationMetadata
- name: google.cloud.channel.v1.SubscriberEvent
- name: google.cloud.channel.v1.TransferEntitlementsResponse

http:
Expand Down
145 changes: 145 additions & 0 deletions google/cloud/channel/v1/service.proto
Expand Up @@ -890,6 +890,86 @@ service CloudChannelService {
get: "/v1/{customer=accounts/*/customers/*}:listPurchasableOffers"
};
}

// 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.
rpc RegisterSubscriber(RegisterSubscriberRequest) returns (RegisterSubscriberResponse) {
option (google.api.http) = {
post: "/v1/{account=accounts/*}:register"
body: "*"
};
}

// 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.
rpc UnregisterSubscriber(UnregisterSubscriberRequest) returns (UnregisterSubscriberResponse) {
option (google.api.http) = {
post: "/v1/{account=accounts/*}:unregister"
body: "*"
};
}

// 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.
rpc ListSubscribers(ListSubscribersRequest) returns (ListSubscribersResponse) {
option (google.api.http) = {
get: "/v1/{account=accounts/*}:listSubscribers"
};
}
}

// Request message for [CloudChannelService.CheckCloudIdentityAccountsExist][google.cloud.channel.v1.CloudChannelService.CheckCloudIdentityAccountsExist].
Expand Down Expand Up @@ -1796,3 +1876,68 @@ message PurchasableOffer {
// Offer.
Offer offer = 1;
}

// Request Message for RegisterSubscriber.
message RegisterSubscriberRequest {
// Required. Resource name of the account.
string account = 1 [(google.api.field_behavior) = REQUIRED];

// Required. Service account which will provide subscriber access to the
// registered topic.
string service_account = 2 [(google.api.field_behavior) = REQUIRED];
}

// Response Message for RegisterSubscriber.
message RegisterSubscriberResponse {
// Name of the topic to which the subscriber will listen to.
string topic = 1;
}

// Request Message for UnregisterSubscriber.
message UnregisterSubscriberRequest {
// Required. Resource name of the account.
string account = 1 [(google.api.field_behavior) = REQUIRED];

// Required. Service account which will be unregistered from getting subscriber access
// to the topic.
string service_account = 2 [(google.api.field_behavior) = REQUIRED];
}

// Response Message for UnregisterSubscriber.
message UnregisterSubscriberResponse {
// Name of the topic from which the service account subscriber access has been
// removed.
string topic = 1;
}

// Request Message for ListSubscribers.
message ListSubscribersRequest {
// Required. Resource name of the account.
string account = 1 [(google.api.field_behavior) = REQUIRED];

// Optional. The maximum number of service accounts to return. The service may return
// fewer than this value.
// If unspecified, at most 100 service accounts will be returned.
// The maximum value is 1000; values above 1000 will be coerced to 1000.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. A page token, received from a previous `ListSubscribers` call.
// Provide this to retrieve the subsequent page.
//
// When paginating, all other parameters provided to `ListSubscribers` must
// match the call that provided the page token.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response Message for ListSubscribers.
message ListSubscribersResponse {
// Name of the topic registered with the reseller.
string topic = 1;

// List of service accounts which have subscriber access to the topic.
repeated string service_accounts = 2;

// A token that can be sent as `page_token` to retrieve the next page.
// If this field is omitted, there are no subsequent pages.
string next_page_token = 3;
}
111 changes: 111 additions & 0 deletions google/cloud/channel/v1/subscriber_event.proto
@@ -0,0 +1,111 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.channel.v1;

import "google/api/resource.proto";
import "google/api/annotations.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/channel/v1;channel";
option java_multiple_files = true;
option java_outer_classname = "SubscriberEventProto";
option java_package = "com.google.cloud.channel.v1";

// Represents Pub/Sub message content describing customer update.
message CustomerEvent {
// Type of customer event.
enum Type {
// Default value. This state doesn't show unless an error occurs.
TYPE_UNSPECIFIED = 0;
}

// Resource name of the customer.
// Format: accounts/{account_id}/customers/{customer_id}
string customer = 1 [(google.api.resource_reference) = {
type: "cloudchannel.googleapis.com/Customer"
}];

// Type of event which happened on the customer.
Type event_type = 2;
}

// Represents Pub/Sub message content describing entitlement update.
message EntitlementEvent {
// Type of entitlement event.
enum Type {
// Default value. This state doesn't show unless an error occurs.
TYPE_UNSPECIFIED = 0;

// A new entitlement was created.
CREATED = 1;

// The offer type associated with an entitlement was changed.
// This is not triggered if an entitlement converts from a commit offer to a
// flexible offer as part of a renewal.
PRICE_PLAN_SWITCHED = 3;

// Annual commitment for a commit plan was changed.
COMMITMENT_CHANGED = 4;

// An annual entitlement was renewed.
RENEWED = 5;

// Entitlement was suspended.
SUSPENDED = 6;

// Entitlement was unsuspended.
ACTIVATED = 7;

// Entitlement was cancelled.
CANCELLED = 8;

// Entitlement was upgraded or downgraded (e.g. from Google Workspace
// Business Standard to Google Workspace Business Plus).
SKU_CHANGED = 9;

// The renewal settings of an entitlement has changed.
RENEWAL_SETTING_CHANGED = 10;

// Paid service has started on trial entitlement.
PAID_SERVICE_STARTED = 11;

// License was assigned to or revoked from a user.
LICENSE_ASSIGNMENT_CHANGED = 12;
}

// Resource name of an entitlement of the form:
// accounts/{account_id}/customers/{customer_id}/entitlements/{entitlement_id}
string entitlement = 1 [(google.api.resource_reference) = {
type: "cloudchannel.googleapis.com/Entitlement"
}];

// Type of event which happened on the entitlement.
Type event_type = 2;
}

// Represents information which resellers will get as part of notification from
// Cloud Pub/Sub.
message SubscriberEvent {
// Specifies the Pub/Sub event provided to the partners.
// This is a required field.
oneof event {
// Customer event send as part of Pub/Sub event to partners.
CustomerEvent customer_event = 1;

// Entitlement event send as part of Pub/Sub event to partners.
EntitlementEvent entitlement_event = 2;
}
}

0 comments on commit 6ef9eae

Please sign in to comment.