diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto deleted file mode 100644 index 619879fa..00000000 --- a/odpf/stencil/v1/stencil.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; -package odpf.stencil.v1; - -import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; -import "google/protobuf/descriptor.proto"; -import "protoc-gen-openapiv2/options/annotations.proto"; - - -option go_package = "github.com/odpf/proton/stencil/v1;stencilv1"; - -// These annotations are used when generating the OpenAPI file. -option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - info: { - version: "0.1.4"; - }; - schemes: HTTP; -}; - -service StencilService { - rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) { - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - consumes: "multipart/form-data"; - produces: "application/json"; - }; - } - rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) { - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - produces: "application/octet-stream"; - }; - } - rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) { - option (google.api.http) = { - get: "/v1/snapshots" - }; - } - // PromoteSnapshot promotes particular snapshot version as latest - rpc PromoteSnapshot(PromoteSnapshotRequest) returns (PromoteSnapshotResponse) { - option (google.api.http) = { - patch: "/v1/snapshots/{id}/promote" - }; - } - // Search matches given query with message names and field names - // returns filtered message/field names along with snapshot details - rpc Search(SearchRequest) returns (SearchResponse) { - option (google.api.http) = { - get: "/v1/search" - }; - } -} - -enum Rule { - UNKNOWN = 0; - FILE_NO_BREAKING_CHANGE = 1; - MESSAGE_NO_DELETE = 2; - FIELD_NO_BREAKING_CHANGE = 3; - ENUM_NO_BREAKING_CHANGE = 4; -} - -message Snapshot { - int64 id = 1; - string namespace = 2 [(google.api.field_behavior) = REQUIRED]; - string name = 3; - string version = 4; - bool latest = 5; -} - -message DownloadDescriptorRequest { - string namespace = 1 [(google.api.field_behavior) = REQUIRED]; - string name = 2 [(google.api.field_behavior) = REQUIRED]; - string version = 3 [(google.api.field_behavior) = REQUIRED]; - repeated string fullnames = 4; -} - -message DownloadDescriptorResponse { - bytes data = 1; -} - -message UploadDescriptorRequest { - string namespace = 1 [(google.api.field_behavior) = REQUIRED]; - string name = 2 [(google.api.field_behavior) = REQUIRED]; - string version = 3 [(google.api.field_behavior) = REQUIRED]; - bytes data = 4 [(google.api.field_behavior) = REQUIRED]; - bool latest = 5; - bool dryrun = 6; - Checks checks = 7; -} - -message Checks { - repeated Rule except = 2; -} - -message UploadDescriptorResponse { - bool success = 1; - bool dryrun = 2; - string errors = 3; -} - -message ListSnapshotsRequest { - string namespace = 1; - string name = 2; - string version = 3; - bool latest = 4; -} - -message ListSnapshotsResponse { - repeated Snapshot snapshots = 1; -} - -message SearchRequest { - string namespace = 1; - string name = 2; - string version = 3; - bool latest = 4; - string query = 5; -} - -message SearchResult { - string path = 1; - string package = 2; - repeated string messages = 3; - repeated string fields = 4; - repeated Snapshot snapshots = 5; -} - -message SearchResponse { - repeated SearchResult results = 1; -} - -message PromoteSnapshotRequest { - int64 id = 1; -} - -message PromoteSnapshotResponse { - Snapshot snapshot = 1; -} diff --git a/odpf/stencil/v1beta1/stencil.proto b/odpf/stencil/v1beta1/stencil.proto new file mode 100644 index 00000000..0e4aea6a --- /dev/null +++ b/odpf/stencil/v1beta1/stencil.proto @@ -0,0 +1,316 @@ +syntax = "proto3"; +package odpf.stencil.v1beta1; + +import "google/api/annotations.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/descriptor.proto"; +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; + + +option go_package = "github.com/odpf/proton/stencil/v1beta1;stencilv1beta1"; + +// These annotations are used when generating the OpenAPI file. +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { + info: { + version: "0.1.4"; + }; + schemes: HTTP; +}; + +service StencilService { + rpc ListNamespaces(ListNamespacesRequest) returns (ListNamespacesResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "List names of namespaces"; + }; + } + rpc GetNamespace(GetNamespaceRequest) returns (GetNamespaceResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "Get namespace by id"; + }; + } + rpc CreateNamespace(CreateNamespaceRequest) returns (CreateNamespaceResponse) { + option (google.api.http) = { + post: "/v1beta1/namespaces", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "Create namespace entry"; + }; + } + rpc UpdateNamespace(UpdateNamespaceRequest) returns (UpdateNamespaceResponse) { + option (google.api.http) = { + put: "/v1beta1/namespaces/{id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "Update namespace entity by id"; + }; + } + rpc DeleteNamespace(DeleteNamespaceRequest) returns (DeleteNamespaceResponse) { + option (google.api.http) = { + delete: "/v1beta1/namespaces/{id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "Delete namespace by id"; + description: "Ensure all schemas under this namespace is deleted, otherwise it will throw error"; + }; + } + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{id}/schemas" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "List schemas under the namespace"; + }; + } + rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { + option (google.api.http) = { + post: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}", + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Create schema under the namespace. Returns version number, unique ID and location"; + }; + } + rpc GetSchemaMetadata(GetSchemaMetadataRequest) returns (GetSchemaMetadataResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/meta" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Create schema under the namespace. Returns version number, unique ID and location"; + }; + } + rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { + option (google.api.http) = { + patch: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" + body: "*" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Update only schema metadata"; + }; + } + rpc GetLatestSchema(GetLatestSchemaRequest) returns (GetLatestSchemaResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Get latest schema for specified schema id and namespace id"; + description: "Returns schema data in byte64 format. Clients can decode 'data' field to expected data format" + }; + } + rpc DeleteSchema(DeleteSchemaRequest) returns (DeleteSchemaResponse) { + option (google.api.http) = { + delete: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Delete specified schema"; + }; + } + rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + tags: "version"; + summary: "Get schema for specified version"; + }; + } + rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { + option (google.api.http) = { + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + tags: "version"; + summary: "List all version numbers for schema"; + }; + } + rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { + option (google.api.http) = { + delete: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + tags: "version"; + summary: "Delete specified version of the schema"; + }; + } +} + +message Namespace { + string id = 1; + Schema.Format format = 2; + string description = 3; + google.protobuf.Timestamp created_at = 4; + google.protobuf.Timestamp updated_at = 5; +} + +message Schema { + enum Format { + FORMAT_UNSPECIFIED = 0; + FORMAT_PROTOBUF = 1; + FORMAT_AVRO = 2; + FORMAT_JSON = 3; + } + enum Compatibility { + COMPATIBILITY_UNSPECIFIED = 0; + COMPATIBILITY_FULL = 1; + } + string name = 1; + Format format = 2; + string authority = 3; + Compatibility compatibility = 4; + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp updated_at = 6; +} + +message ListNamespacesRequest {} + +message ListNamespacesResponse { + repeated string namespaces = 1; +} + +message GetNamespaceRequest { + string id = 1; +} + +message GetNamespaceResponse { + Namespace namespace = 1; +} + +message CreateNamespaceRequest { + string id = 1 [(google.api.field_behavior) = REQUIRED]; + Schema.Format format = 2 [(google.api.field_behavior) = REQUIRED]; + string description = 3; +} + +message CreateNamespaceResponse { + Namespace namespace = 1; +} + +message UpdateNamespaceRequest { + string id = 1; + Schema.Format format = 2 [(google.api.field_behavior) = REQUIRED]; + string description = 3; +} + +message UpdateNamespaceResponse { + Namespace namespace = 1; +} + +message DeleteNamespaceRequest { + string id = 1; +} +message DeleteNamespaceResponse { + string message = 1; +} + +message ListSchemasRequest { + string id = 1; +} +message ListSchemasResponse { + repeated string schemas = 1; +} + +message GetLatestSchemaRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message GetLatestSchemaResponse { + bytes data = 3; +} + +message CreateSchemaRequest { + string namespace_id = 1; + string schema_id = 2; + bytes data = 3 [(google.api.field_behavior) = REQUIRED]; + Schema.Format format = 4; + Schema.Compatibility compatibility = 5; +} + +message CreateSchemaResponse { + int32 version = 1; + string id = 2; + string location = 3; +} + +message GetSchemaMetadataRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message GetSchemaMetadataResponse { + Schema.Format format = 1; + Schema.Compatibility compatibility = 2; + string authority = 3; +} + +message UpdateSchemaMetadataRequest { + string namespace_id = 1; + string schema_id = 2; + Schema.Compatibility compatibility = 3; +} + +message UpdateSchemaMetadataResponse { + Schema.Format format = 1; + Schema.Compatibility compatibility = 2; + string authority = 3; +} + +message DeleteSchemaRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message DeleteSchemaResponse { + string message = 1; +} + +message ListVersionsRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message ListVersionsResponse { + repeated int32 versions = 1; +} + +message GetSchemaRequest { + string namespace_id = 1; + string schema_id = 2; + int32 version_id = 3; +} + +message GetSchemaResponse { + bytes data = 1; +} + +message DeleteVersionRequest { + string namespace_id = 1; + string schema_id = 2; + int32 version_id = 3; +} + +message DeleteVersionResponse { + string message = 1; +}