1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.apps.events.subscriptions.v1; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/duration.proto"; 22import "google/protobuf/field_mask.proto"; 23import "google/protobuf/timestamp.proto"; 24 25option csharp_namespace = "Google.Apps.Events.Subscriptions.V1"; 26option go_package = "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb;subscriptionspb"; 27option java_multiple_files = true; 28option java_outer_classname = "SubscriptionResourceProto"; 29option java_package = "com.google.apps.events.subscriptions.v1"; 30option php_namespace = "Google\\Apps\\Events\\Subscriptions\\V1"; 31option ruby_package = "Google::Apps::Events::Subscriptions::V1"; 32option (google.api.resource_definition) = { 33 type: "cloudidentity.googleapis.com/User" 34 pattern: "users/{user}" 35}; 36option (google.api.resource_definition) = { 37 type: "pubsub.googleapis.com/Topic" 38 pattern: "projects/{project}/topics/{topic}" 39}; 40 41// A subscription to receive events about a Google Workspace resource. To learn 42// more about subscriptions, see the [Google Workspace Events API 43// overview](https://developers.google.com/workspace/events). 44message Subscription { 45 option (google.api.resource) = { 46 type: "workspaceevents.googleapis.com/Subscription" 47 pattern: "subscriptions/{subscription}" 48 plural: "subscriptions" 49 singular: "subscription" 50 style: DECLARATIVE_FRIENDLY 51 }; 52 53 // Possible states for the subscription. 54 enum State { 55 // Default value. This value is unused. 56 STATE_UNSPECIFIED = 0; 57 58 // The subscription is active and can receive and deliver events to its 59 // notification endpoint. 60 ACTIVE = 1; 61 62 // The subscription is unable to receive events due to an error. 63 // To identify the error, see the 64 // [`suspension_reason`][google.apps.events.subscriptions.v1.Subscription.suspension_reason] 65 // field. 66 SUSPENDED = 2; 67 68 // The subscription is deleted. 69 DELETED = 3; 70 } 71 72 // Possible errors for a subscription. 73 enum ErrorType { 74 // Default value. This value is unused. 75 ERROR_TYPE_UNSPECIFIED = 0; 76 77 // The authorizing user has revoked the grant of one or more OAuth scopes. 78 // To learn more about authorization for Google Workspace, see [Configure 79 // the OAuth consent 80 // screen](https://developers.google.com/workspace/guides/configure-oauth-consent#choose-scopes). 81 USER_SCOPE_REVOKED = 1; 82 83 // The target resource for the subscription no longer exists. 84 RESOURCE_DELETED = 2; 85 86 // The user that authorized the creation of the subscription no longer has 87 // access to the subscription's target resource. 88 USER_AUTHORIZATION_FAILURE = 3; 89 90 // The Google Workspace application doesn't have access to deliver 91 // events to your subscription's notification endpoint. 92 ENDPOINT_PERMISSION_DENIED = 4; 93 94 // The subscription's notification endpoint doesn't exist, or the endpoint 95 // can't be found in the Google Cloud project where you created the 96 // subscription. 97 ENDPOINT_NOT_FOUND = 6; 98 99 // The subscription's notification endpoint failed to receive events due to 100 // insufficient quota or reaching rate limiting. 101 ENDPOINT_RESOURCE_EXHAUSTED = 7; 102 103 // An unidentified error has occurred. 104 OTHER = 5; 105 } 106 107 // The time when the subscription expires. 108 // 109 // The maximum expiration time depends on whether your subscription includes 110 // resource data in event payloads (specified in the 111 // [PayloadOptions][google.apps.events.subscriptions.v1.PayloadOptions] 112 // field): 113 // 114 // * If payloads omit resource data, up to 7 days. 115 // * If payloads include resource data, up to 4 hours. If your Google 116 // Workspace organization grants access to the resource through [domain-wide 117 // delegation](https://support.google.com/a/answer/162106), you can extend the 118 // subscription's expiration time to up to 24 hours. 119 // 120 // After a subscription expires, it's deleted automatically. You receive 121 // lifecycle events to the 122 // [notification_endpoint][google.apps.events.subscriptions.v1.Subscription.notification_endpoint] 123 // 12 hours and one hour before the subscription expires. For details, see 124 // [Receive and respond to lifecycle 125 // events](https://developers.google.com/workspace/events/guides/events-lifecycle). 126 // 127 // To prevent a subscription from expiring, you can use the 128 // [`UpdateSubscription`][google.apps.events.subscriptions.v1.SubscriptionsService.UpdateSubscription] 129 // method to extend its expiration date. For details, see [Update or renew a 130 // subscription](https://developers.google.com/workspace/events/guides/update-subscription). 131 oneof expiration { 132 // Non-empty default. The timestamp in UTC when the subscription expires. 133 // Always displayed on output, regardless of what was used on input. 134 google.protobuf.Timestamp expire_time = 13 135 [(google.api.field_behavior) = NON_EMPTY_DEFAULT]; 136 137 // Input only. The time-to-live (TTL) or duration for the subscription. If 138 // unspecified or set to `0`, uses the maximum possible duration. 139 google.protobuf.Duration ttl = 14 140 [(google.api.field_behavior) = INPUT_ONLY]; 141 } 142 143 // Optional. Immutable. Identifier. Resource name of the subscription. 144 // 145 // Format: `subscriptions/{subscription}` 146 string name = 1 [ 147 (google.api.field_behavior) = IDENTIFIER, 148 (google.api.field_behavior) = IMMUTABLE, 149 (google.api.field_behavior) = OPTIONAL 150 ]; 151 152 // Output only. System-assigned unique identifier for the subscription. 153 string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 154 155 // Required. Immutable. The Google Workspace resource that's monitored for 156 // events, formatted as the [full resource 157 // name](https://google.aip.dev/122#full-resource-names). To learn about 158 // target resources and the events that they support, see [Supported Google 159 // Workspace 160 // events](https://developers.google.com/workspace/events#supported-events). 161 // 162 // A user can only authorize your app to create one subscription for a given 163 // target resource. If your app tries to create another subscription with the 164 // same user credentials, the request returns an `ALREADY_EXISTS` error. 165 string target_resource = 4 [ 166 (google.api.field_behavior) = IMMUTABLE, 167 (google.api.field_behavior) = REQUIRED, 168 (google.api.resource_reference) = { type: "*" } 169 ]; 170 171 // Required. Immutable. Unordered list. Input for creating a subscription. 172 // Otherwise, output only. One or more types of events to receive about the 173 // target resource. Formatted according to the CloudEvents specification. 174 // 175 // The supported event types depend on the target resource of your 176 // subscription. For details, see [Supported Google Workspace 177 // events](https://developers.google.com/workspace/events/guides#supported-events). 178 // 179 // By default, you also receive events about the [lifecycle of your 180 // subscription](https://developers.google.com/workspace/events/guides/events-lifecycle). 181 // You don't need to specify lifecycle events for this field. 182 // 183 // If you specify an event type that doesn't exist for the target resource, 184 // the request returns an HTTP `400 Bad Request` status code. 185 repeated string event_types = 5 [ 186 (google.api.field_behavior) = REQUIRED, 187 (google.api.field_behavior) = UNORDERED_LIST, 188 (google.api.field_behavior) = IMMUTABLE 189 ]; 190 191 // Optional. Options about what data to include in the event payload. Only 192 // supported for Google Chat events. 193 PayloadOptions payload_options = 6 [(google.api.field_behavior) = OPTIONAL]; 194 195 // Required. Immutable. The endpoint where the subscription delivers events, 196 // such as a Pub/Sub topic. 197 NotificationEndpoint notification_endpoint = 7 [ 198 (google.api.field_behavior) = REQUIRED, 199 (google.api.field_behavior) = IMMUTABLE 200 ]; 201 202 // Output only. The state of the subscription. Determines whether the 203 // subscription can receive events and deliver them to the notification 204 // endpoint. 205 State state = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; 206 207 // Output only. The error that suspended the subscription. 208 // 209 // To reactivate the subscription, resolve the error and call the 210 // [`ReactivateSubscription`][google.apps.events.subscriptions.v1.SubscriptionsService.ReactivateSubscription] 211 // method. 212 ErrorType suspension_reason = 18 [(google.api.field_behavior) = OUTPUT_ONLY]; 213 214 // Output only. The user who authorized the creation of the 215 // subscription. 216 // 217 // Format: `users/{user}` 218 // 219 // For Google Workspace users, the `{user}` value is the 220 // [`user.id`](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users#User.FIELDS.ids) 221 // field from the Directory API. 222 string authority = 10 [ 223 (google.api.field_behavior) = OUTPUT_ONLY, 224 (google.api.resource_reference) = { 225 type: "cloudidentity.googleapis.com/User" 226 } 227 ]; 228 229 // Output only. The time when the subscription is created. 230 google.protobuf.Timestamp create_time = 11 231 [(google.api.field_behavior) = OUTPUT_ONLY]; 232 233 // Output only. The last time that the subscription is updated. 234 google.protobuf.Timestamp update_time = 12 235 [(google.api.field_behavior) = OUTPUT_ONLY]; 236 237 // Output only. If `true`, the subscription is in the process of being 238 // updated. 239 bool reconciling = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; 240 241 // Optional. This checksum is computed by the server based on the value of 242 // other fields, and might be sent on update requests to ensure the client has 243 // an up-to-date value before proceeding. 244 string etag = 17 [(google.api.field_behavior) = OPTIONAL]; 245} 246 247// Options about what data to include in the event payload. Only supported for 248// Google Chat events. 249message PayloadOptions { 250 // Optional. Whether the event payload includes data about the resource that 251 // changed. For example, for an event where a Google Chat message was created, 252 // whether the payload contains data about the 253 // [`Message`](https://developers.google.com/chat/api/reference/rest/v1/spaces.messages) 254 // resource. If false, the event payload only includes the name of the changed 255 // resource. 256 bool include_resource = 1 [(google.api.field_behavior) = OPTIONAL]; 257 258 // Optional. If `include_resource` is set to `true`, the list of fields to 259 // include in the event payload. Separate fields with a comma. For example, to 260 // include a Google Chat message's sender and create time, enter 261 // `message.sender,message.createTime`. If omitted, the payload includes all 262 // fields for the resource. 263 // 264 // If you specify a field that doesn't exist for the resource, the system 265 // ignores the field. 266 google.protobuf.FieldMask field_mask = 2 267 [(google.api.field_behavior) = OPTIONAL]; 268} 269 270// The endpoint where the subscription delivers events. 271message NotificationEndpoint { 272 oneof endpoint { 273 // Immutable. The Cloud Pub/Sub topic that receives events for the 274 // subscription. 275 // 276 // Format: `projects/{project}/topics/{topic}` 277 // 278 // 279 // You must create the topic in the same Google Cloud project where 280 // you create this subscription. 281 // 282 // When the topic receives events, the events are encoded as Cloud Pub/Sub 283 // messages. For details, see the [Google Cloud Pub/Sub Protocol Binding for 284 // CloudEvents](https://github.com/googleapis/google-cloudevents/blob/main/docs/spec/pubsub.md). 285 string pubsub_topic = 1 [ 286 (google.api.field_behavior) = IMMUTABLE, 287 (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } 288 ]; 289 } 290} 291