|
| 1 | +// Copyright 2020 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 | + |
| 15 | +syntax = "proto3"; |
| 16 | + |
| 17 | +package google.pubsub.v1; |
| 18 | + |
| 19 | +import "google/api/annotations.proto"; |
| 20 | +import "google/api/client.proto"; |
| 21 | +import "google/api/field_behavior.proto"; |
| 22 | +import "google/api/resource.proto"; |
| 23 | +import "google/protobuf/empty.proto"; |
| 24 | + |
| 25 | +option cc_enable_arenas = true; |
| 26 | +option csharp_namespace = "Google.Cloud.PubSub.V1"; |
| 27 | +option go_package = "google.golang.org/genproto/googleapis/pubsub/v1;pubsub"; |
| 28 | +option java_multiple_files = true; |
| 29 | +option java_outer_classname = "SchemaProto"; |
| 30 | +option java_package = "com.google.pubsub.v1"; |
| 31 | +option php_namespace = "Google\\Cloud\\PubSub\\V1"; |
| 32 | +option ruby_package = "Google::Cloud::PubSub::V1"; |
| 33 | + |
| 34 | +// Service for doing schema-related operations. |
| 35 | +// |
| 36 | +// EXPERIMENTAL: The Schema service is in development and may not work yet. |
| 37 | + |
| 38 | +service SchemaService { |
| 39 | + option (google.api.default_host) = "pubsub.googleapis.com"; |
| 40 | + option (google.api.oauth_scopes) = |
| 41 | + "https://www.googleapis.com/auth/cloud-platform," |
| 42 | + "https://www.googleapis.com/auth/pubsub"; |
| 43 | + |
| 44 | + // Creates a schema. |
| 45 | + rpc CreateSchema(CreateSchemaRequest) returns (Schema) { |
| 46 | + option (google.api.http) = { |
| 47 | + post: "/v1/{parent=projects/*}/schemas" |
| 48 | + body: "schema" |
| 49 | + }; |
| 50 | + option (google.api.method_signature) = "parent,schema,schema_id"; |
| 51 | + } |
| 52 | + |
| 53 | + // Gets a schema. |
| 54 | + rpc GetSchema(GetSchemaRequest) returns (Schema) { |
| 55 | + option (google.api.http) = { |
| 56 | + get: "/v1/{name=projects/*/schemas/*}" |
| 57 | + }; |
| 58 | + option (google.api.method_signature) = "name"; |
| 59 | + } |
| 60 | + |
| 61 | + // Lists schemas in a project. |
| 62 | + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { |
| 63 | + option (google.api.http) = { |
| 64 | + get: "/v1/{parent=projects/*}/schemas" |
| 65 | + }; |
| 66 | + option (google.api.method_signature) = "parent"; |
| 67 | + } |
| 68 | + |
| 69 | + // Deletes a schema. |
| 70 | + rpc DeleteSchema(DeleteSchemaRequest) returns (google.protobuf.Empty) { |
| 71 | + option (google.api.http) = { |
| 72 | + delete: "/v1/{name=projects/*/schemas/*}" |
| 73 | + }; |
| 74 | + option (google.api.method_signature) = "name"; |
| 75 | + } |
| 76 | + |
| 77 | + // Validates a schema. |
| 78 | + rpc ValidateSchema(ValidateSchemaRequest) returns (ValidateSchemaResponse) { |
| 79 | + option (google.api.http) = { |
| 80 | + post: "/v1/{parent=projects/*}/schemas:validate" |
| 81 | + body: "*" |
| 82 | + }; |
| 83 | + option (google.api.method_signature) = "parent,schema"; |
| 84 | + } |
| 85 | + |
| 86 | + // Validates a message against a schema. |
| 87 | + rpc ValidateMessage(ValidateMessageRequest) |
| 88 | + returns (ValidateMessageResponse) { |
| 89 | + option (google.api.http) = { |
| 90 | + post: "/v1/{parent=projects/*}/schemas:validateMessage" |
| 91 | + body: "*" |
| 92 | + }; |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +// A schema resource. |
| 97 | +message Schema { |
| 98 | + option (google.api.resource) = { |
| 99 | + type: "pubsub.googleapis.com/Schema" |
| 100 | + pattern: "projects/{project}/schemas/{schema}" |
| 101 | + }; |
| 102 | + |
| 103 | + // Possible schema definition types. |
| 104 | + enum Type { |
| 105 | + // Default value. This value is unused. |
| 106 | + TYPE_UNSPECIFIED = 0; |
| 107 | + |
| 108 | + // A Protocol Buffer schema definition. |
| 109 | + PROTOCOL_BUFFER = 1; |
| 110 | + |
| 111 | + // An Avro schema definition. |
| 112 | + AVRO = 2; |
| 113 | + } |
| 114 | + |
| 115 | + // Required. Name of the schema. |
| 116 | + // Format is `projects/{project}/schemas/{schema}`. |
| 117 | + string name = 1 [(google.api.field_behavior) = REQUIRED]; |
| 118 | + |
| 119 | + // The type of the schema definition. |
| 120 | + Type type = 2; |
| 121 | + |
| 122 | + // The definition of the schema. This should contain a string representing |
| 123 | + // the full definition of the schema that is a valid schema definition of |
| 124 | + // the type specified in `type`. |
| 125 | + string definition = 3; |
| 126 | +} |
| 127 | + |
| 128 | +// Request for the CreateSchema method. |
| 129 | +message CreateSchemaRequest { |
| 130 | + // Required. The name of the project in which to create the schema. |
| 131 | + // Format is `projects/{project-id}`. |
| 132 | + string parent = 1 [ |
| 133 | + (google.api.field_behavior) = REQUIRED, |
| 134 | + (google.api.resource_reference) = { |
| 135 | + child_type: "pubsub.googleapis.com/Schema" |
| 136 | + } |
| 137 | + ]; |
| 138 | + |
| 139 | + // Required. The schema object to create. |
| 140 | + // |
| 141 | + // This schema's `name` parameter is ignored. The schema object returned |
| 142 | + // by CreateSchema will have a `name` made using the given `parent` and |
| 143 | + // `schema_id`. |
| 144 | + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; |
| 145 | + |
| 146 | + // The ID to use for the schema, which will become the final component of |
| 147 | + // the schema's resource name. |
| 148 | + // |
| 149 | + // See https://cloud.google.com/pubsub/docs/admin#resource_names for resource |
| 150 | + // name constraints. |
| 151 | + string schema_id = 3; |
| 152 | +} |
| 153 | + |
| 154 | +// View of Schema object fields to be returned by GetSchema and ListSchemas. |
| 155 | +enum SchemaView { |
| 156 | + // The default / unset value. |
| 157 | + // The API will default to the BASIC view. |
| 158 | + SCHEMA_VIEW_UNSPECIFIED = 0; |
| 159 | + |
| 160 | + // Include the name and type of the schema, but not the definition. |
| 161 | + BASIC = 1; |
| 162 | + |
| 163 | + // Include all Schema object fields. |
| 164 | + FULL = 2; |
| 165 | +} |
| 166 | + |
| 167 | +// Request for the GetSchema method. |
| 168 | +message GetSchemaRequest { |
| 169 | + // Required. The name of the schema to get. |
| 170 | + // Format is `projects/{project}/schemas/{schema}`. |
| 171 | + string name = 1 [ |
| 172 | + (google.api.field_behavior) = REQUIRED, |
| 173 | + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } |
| 174 | + ]; |
| 175 | + |
| 176 | + // The set of fields to return in the response. If not set, returns a Schema |
| 177 | + // with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all |
| 178 | + // fields. |
| 179 | + SchemaView view = 2; |
| 180 | +} |
| 181 | + |
| 182 | +// Request for the `ListSchemas` method. |
| 183 | +message ListSchemasRequest { |
| 184 | + // Required. The name of the project in which to list schemas. |
| 185 | + // Format is `projects/{project-id}`. |
| 186 | + string parent = 1 [ |
| 187 | + (google.api.field_behavior) = REQUIRED, |
| 188 | + (google.api.resource_reference) = { |
| 189 | + type: "cloudresourcemanager.googleapis.com/Project" |
| 190 | + } |
| 191 | + ]; |
| 192 | + |
| 193 | + // The set of Schema fields to return in the response. If not set, returns |
| 194 | + // Schemas with `name` and `type`, but not `definition`. Set to `FULL` to |
| 195 | + // retrieve all fields. |
| 196 | + SchemaView view = 2; |
| 197 | + |
| 198 | + // Maximum number of schemas to return. |
| 199 | + int32 page_size = 3; |
| 200 | + |
| 201 | + // The value returned by the last `ListSchemasResponse`; indicates that |
| 202 | + // this is a continuation of a prior `ListSchemas` call, and that the |
| 203 | + // system should return the next page of data. |
| 204 | + string page_token = 4; |
| 205 | +} |
| 206 | + |
| 207 | +// Response for the `ListSchemas` method. |
| 208 | +message ListSchemasResponse { |
| 209 | + // The resulting schemas. |
| 210 | + repeated Schema schemas = 1; |
| 211 | + |
| 212 | + // If not empty, indicates that there may be more schemas that match the |
| 213 | + // request; this value should be passed in a new `ListSchemasRequest`. |
| 214 | + string next_page_token = 2; |
| 215 | +} |
| 216 | + |
| 217 | +// Request for the `DeleteSchema` method. |
| 218 | +message DeleteSchemaRequest { |
| 219 | + // Required. Name of the schema to delete. |
| 220 | + // Format is `projects/{project}/schemas/{schema}`. |
| 221 | + string name = 1 [ |
| 222 | + (google.api.field_behavior) = REQUIRED, |
| 223 | + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } |
| 224 | + ]; |
| 225 | +} |
| 226 | + |
| 227 | +// Request for the `ValidateSchema` method. |
| 228 | +message ValidateSchemaRequest { |
| 229 | + // Required. The name of the project in which to validate schemas. |
| 230 | + // Format is `projects/{project-id}`. |
| 231 | + string parent = 1 [ |
| 232 | + (google.api.field_behavior) = REQUIRED, |
| 233 | + (google.api.resource_reference) = { |
| 234 | + type: "cloudresourcemanager.googleapis.com/Project" |
| 235 | + } |
| 236 | + ]; |
| 237 | + |
| 238 | + // Required. The schema object to validate. |
| 239 | + Schema schema = 2 [(google.api.field_behavior) = REQUIRED]; |
| 240 | +} |
| 241 | + |
| 242 | +// Response for the `ValidateSchema` method. |
| 243 | +message ValidateSchemaResponse {} |
| 244 | + |
| 245 | +// Request for the `ValidateMessage` method. |
| 246 | +message ValidateMessageRequest { |
| 247 | + // Required. The name of the project in which to validate schemas. |
| 248 | + // Format is `projects/{project-id}`. |
| 249 | + string parent = 1 [ |
| 250 | + (google.api.field_behavior) = REQUIRED, |
| 251 | + (google.api.resource_reference) = { |
| 252 | + type: "cloudresourcemanager.googleapis.com/Project" |
| 253 | + } |
| 254 | + ]; |
| 255 | + |
| 256 | + oneof schema_spec { |
| 257 | + // Name of the schema against which to validate. |
| 258 | + // |
| 259 | + // Format is `projects/{project}/schemas/{schema}`. |
| 260 | + string name = 2 [ |
| 261 | + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" } |
| 262 | + ]; |
| 263 | + |
| 264 | + // Ad-hoc schema against which to validate |
| 265 | + Schema schema = 3; |
| 266 | + } |
| 267 | + |
| 268 | + // Message to validate against the provided `schema_spec`. |
| 269 | + bytes message = 4; |
| 270 | + |
| 271 | + // The encoding expected for messages |
| 272 | + Encoding encoding = 5; |
| 273 | +} |
| 274 | + |
| 275 | +// Response for the `ValidateMessage` method. |
| 276 | +message ValidateMessageResponse {} |
| 277 | + |
| 278 | +// Possible encoding types for messages. |
| 279 | +enum Encoding { |
| 280 | + // Unspecified |
| 281 | + ENCODING_UNSPECIFIED = 0; |
| 282 | + |
| 283 | + // JSON encoding |
| 284 | + JSON = 1; |
| 285 | + |
| 286 | + // Binary encoding, as defined by the schema type. For some schema types, |
| 287 | + // binary encoding may not be available. |
| 288 | + BINARY = 2; |
| 289 | +} |
0 commit comments