schema.proto 8.6 KB

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