From f4e3d6437344c569d19f76b5c8cace12d51275f1 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 26 Oct 2021 09:39:03 +0530 Subject: [PATCH 01/13] feat!: add/modify stencil APIs BREAKING CHANGE: Modify existing download and upload APIs Add new CRUD APIs for each namespace, schema and version entities. Rename "descriptors" to "schema" in URL path --- odpf/stencil/v1/stencil.proto | 317 ++++++++++++++++++++++++++-------- 1 file changed, 244 insertions(+), 73 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 619879fa..50973999 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -3,11 +3,12 @@ package odpf.stencil.v1; import "google/api/annotations.proto"; import "google/api/field_behavior.proto"; +import "google/api/empty.proto"; import "google/protobuf/descriptor.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -option go_package = "github.com/odpf/proton/stencil/v1;stencilv1"; +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) = { @@ -18,119 +19,289 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { }; service StencilService { - rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) { + rpc ListNamespace(google.protobuf.Empty) returns (ListNamespaceResponse) { + option (google.api.http) = { + get: "/v1/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: "/v1/namespaces/{id}" + }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - consumes: "multipart/form-data"; - produces: "application/json"; + tags: "namespace"; + summary: "Get namespace by id"; + }; + } + rpc CreateNamespace(CreateNamespaceRequest) returns (CreateNamespaceResponse) { + option (google.api.http) = { + post: "/v1/namespaces", + body: "*" }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "namespace"; + summary: "Create namespace entry"; + }; } - rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) { + rpc UpdateNamespace(UpdateNamespaceRequest) returns (UpdateNamespaceResponse) { + option (google.api.http) = { + put: "/v1/namespaces/{id}" + }; + 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: "/v1/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: "/v1/namespaces/{id}/schemas" + }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - produces: "application/octet-stream"; + tags: "schema"; + summary: "List schemas under the namespace"; + }; + } + rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { + option (google.api.http) = { + post: "/v1/namespaces/{id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Create schema under the namespace"; + }; + } + rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { + option (google.api.http) = { + patch: "/v1/namespaces/{id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Update only schema metadata"; + }; + } + rpc DeleteSchemas(DeleteSchemasRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/namespaces/{id}/schemas" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Delete all schemas under specified namespace"; + }; + } + rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { + option (google.api.http) = { + get: "/v1/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: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + tags: "schema"; + summary: "Delete specified schema"; + }; } - rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) { + rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { option (google.api.http) = { - get: "/v1/snapshots" + get: "/v1/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"; + }; } - // PromoteSnapshot promotes particular snapshot version as latest - rpc PromoteSnapshot(PromoteSnapshotRequest) returns (PromoteSnapshotResponse) { + rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) { option (google.api.http) = { - patch: "/v1/snapshots/{id}/promote" + get: "/v1/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"; + }; } - // Search matches given query with message names and field names - // returns filtered message/field names along with snapshot details - rpc Search(SearchRequest) returns (SearchResponse) { + rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { option (google.api.http) = { - get: "/v1/search" + delete: "/v1/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"; + }; } } -enum Rule { - UNKNOWN = 0; - FILE_NO_BREAKING_CHANGE = 1; - MESSAGE_NO_DELETE = 2; - FIELD_NO_BREAKING_CHANGE = 3; - ENUM_NO_BREAKING_CHANGE = 4; +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 { + UNKNOWN = 0; + PROTOBUF = 1; + AVRO = 2; + JSON = 3; + } + string id = 1; + Format format = 2; + string authority = 3; + string description = 4; + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp updated_at = 6; } -message Snapshot { - int64 id = 1; - string namespace = 2 [(google.api.field_behavior) = REQUIRED]; - string name = 3; - string version = 4; - bool latest = 5; +message Version { + // auto increment version number + int64 version = 1; + // unique id, used to globally refer to this version + string id = 2; + google.protobuf.Timestamp created_at = 3; } -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 ListNamespaceResponse { + repeated string namespaces = 1; } -message DownloadDescriptorResponse { - bytes data = 1; +message GetNamespaceRequest { + string id = 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 GetNamespaceResponse { + Namespace namespace = 1; } -message Checks { - repeated Rule except = 2; +message CreateNamespaceRequest { + string id = 1; + Schema.Format format = 2; + string description = 3; } -message UploadDescriptorResponse { - bool success = 1; - bool dryrun = 2; - string errors = 3; +message CreateNamespaceResponse { + Namespace namespace = 1; } -message ListSnapshotsRequest { - string namespace = 1; - string name = 2; - string version = 3; - bool latest = 4; +message UpdateNamespaceRequest { + string id = 1; } -message ListSnapshotsResponse { - repeated Snapshot snapshots = 1; +message UpdateNamespaceResponse { + Namespace namespace = 1; } -message SearchRequest { - string namespace = 1; - string name = 2; - string version = 3; - bool latest = 4; - string query = 5; +message DeleteNamespaceRequest { + string id = 1; +} +message DeleteNamespaceResponse { + string message = 1; } -message SearchResult { - string path = 1; - string package = 2; - repeated string messages = 3; - repeated string fields = 4; - repeated Snapshot snapshots = 5; +message ListSchemasRequest { + string id = 1; +} +message ListSchemasResponse { + repeated string schemas = 1; } -message SearchResponse { - repeated SearchResult results = 1; +message DeleteSchemasRequest { + string id = 1; +} + +message DeleteSchemasResponse { + string message = 1; +} + +message GetSchemaRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message GetSchemaResponse { + int64 version = 1; + Schema.Format format = 2; + bytes data = 3; +} + +message CreateSchemaRequest { + string namespace_id = 1; + string schema_id = 2; + // can be used to override the namespace level format + Schema.Format format = 3; + string authority = 4; + string description = 5; +} + +message CreateSchemaResponse { + Schema schema = 1; +} + +message UpdateSchemaMetadataRequest { + Schema.Format format = 1; + string description = 2; +} + +message UpdateSchemaMetadataResponse { + Schema schema = 1; +} + +message DeleteSchemaRequest { + string id = 1; +} + +message DeleteSchemaResponse { + string message = 1; +} + +message ListVersionsRequest { + string namespace_id = 1; + string schema_id = 2; +} + +message ListVersionsResponse { + repeated int64 versions = 1; +} + +message GetVersionRequest { + string namespace_id = 1; + string schema_id = 2; + string version_id = 3; +} + +message GetVersionResponse { + bytes data = 1; } -message PromoteSnapshotRequest { - int64 id = 1; +message DeleteVersionRequest { + string namespace_id = 1; + string schema_id = 2; + string version_id = 3; } -message PromoteSnapshotResponse { - Snapshot snapshot = 1; +message DeleteVersionResponse { + string message = 1; } From e6808da75c8294b63c0efab03bcdeba6bd8134e4 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 26 Oct 2021 09:52:51 +0530 Subject: [PATCH 02/13] refactor: replace google.protobuf.Empty type with empty message types for rpc --- odpf/stencil/v1/stencil.proto | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 50973999..8f83a185 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -2,9 +2,8 @@ syntax = "proto3"; package odpf.stencil.v1; import "google/api/annotations.proto"; -import "google/api/field_behavior.proto"; -import "google/api/empty.proto"; import "google/protobuf/descriptor.proto"; +import "google/protobuf/timestamp.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; @@ -19,7 +18,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { }; service StencilService { - rpc ListNamespace(google.protobuf.Empty) returns (ListNamespaceResponse) { + rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceResponse) { option (google.api.http) = { get: "/v1/namespaces" }; @@ -93,7 +92,7 @@ service StencilService { summary: "Update only schema metadata"; }; } - rpc DeleteSchemas(DeleteSchemasRequest) returns (google.protobuf.Empty) { + rpc DeleteSchemas(DeleteSchemasRequest) returns (DeleteSchemasResponse) { option (google.api.http) = { delete: "/v1/namespaces/{id}/schemas" }; @@ -184,6 +183,8 @@ message Version { google.protobuf.Timestamp created_at = 3; } +message ListNamespaceRequest {} + message ListNamespaceResponse { repeated string namespaces = 1; } From fda7981e36843159a38f7f77cbb490db12d7f85a Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 26 Oct 2021 09:53:58 +0530 Subject: [PATCH 03/13] refactor: remove unused message --- odpf/stencil/v1/stencil.proto | 8 -------- 1 file changed, 8 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 8f83a185..bbf4a050 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -175,14 +175,6 @@ message Schema { google.protobuf.Timestamp updated_at = 6; } -message Version { - // auto increment version number - int64 version = 1; - // unique id, used to globally refer to this version - string id = 2; - google.protobuf.Timestamp created_at = 3; -} - message ListNamespaceRequest {} message ListNamespaceResponse { From 5246e6504ea9d639b63cef6fddd0fed12c667fb0 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 26 Oct 2021 09:59:00 +0530 Subject: [PATCH 04/13] chore: fix formatting --- odpf/stencil/v1/stencil.proto | 308 +++++++++++++++++----------------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index bbf4a050..496c7378 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -11,290 +11,290 @@ 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; + info: { + version: "0.1.4"; + }; + schemes: HTTP; }; service StencilService { - rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceResponse) { - option (google.api.http) = { - get: "/v1/namespaces" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceResponse) { + option (google.api.http) = { + get: "/v1/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: "/v1/namespaces/{id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc GetNamespace(GetNamespaceRequest) returns (GetNamespaceResponse) { + option (google.api.http) = { + get: "/v1/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: "/v1/namespaces", - body: "*" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc CreateNamespace(CreateNamespaceRequest) returns (CreateNamespaceResponse) { + option (google.api.http) = { + post: "/v1/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: "/v1/namespaces/{id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc UpdateNamespace(UpdateNamespaceRequest) returns (UpdateNamespaceResponse) { + option (google.api.http) = { + put: "/v1/namespaces/{id}" + }; + 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: "/v1/namespaces/{id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc DeleteNamespace(DeleteNamespaceRequest) returns (DeleteNamespaceResponse) { + option (google.api.http) = { + delete: "/v1/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"; + description: "Ensure all schemas under this namespace is deleted, otherwise it will throw error"; }; - } - rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { - option (google.api.http) = { - get: "/v1/namespaces/{id}/schemas" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { + option (google.api.http) = { + get: "/v1/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: "/v1/namespaces/{id}/schemas/{schema_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { + option (google.api.http) = { + post: "/v1/namespaces/{id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; summary: "Create schema under the namespace"; }; - } - rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { - option (google.api.http) = { - patch: "/v1/namespaces/{id}/schemas/{schema_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { + option (google.api.http) = { + patch: "/v1/namespaces/{id}/schemas/{schema_id}" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; summary: "Update only schema metadata"; }; - } - rpc DeleteSchemas(DeleteSchemasRequest) returns (DeleteSchemasResponse) { - option (google.api.http) = { - delete: "/v1/namespaces/{id}/schemas" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc DeleteSchemas(DeleteSchemasRequest) returns (DeleteSchemasResponse) { + option (google.api.http) = { + delete: "/v1/namespaces/{id}/schemas" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; summary: "Delete all schemas under specified namespace"; }; - } - rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { - option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { + option (google.api.http) = { + get: "/v1/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" + 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: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" }; - } - rpc DeleteSchema(DeleteSchemaRequest) returns (DeleteSchemaResponse) { - option (google.api.http) = { - delete: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; summary: "Delete specified schema"; }; - } - rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { - option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { + } + rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { + option (google.api.http) = { + get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions" + }; + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; - tags: "version"; + tags: "version"; summary: "List all version numbers for schema"; }; - } - rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) { - option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - tags: "schema"; + } + rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) { + option (google.api.http) = { + get: "/v1/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 DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { - option (google.api.http) = { - delete: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" - }; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { - tags: "schema"; + } + rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { + option (google.api.http) = { + delete: "/v1/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; + 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 { - UNKNOWN = 0; - PROTOBUF = 1; - AVRO = 2; - JSON = 3; - } - string id = 1; - Format format = 2; - string authority = 3; - string description = 4; - google.protobuf.Timestamp created_at = 5; - google.protobuf.Timestamp updated_at = 6; + enum Format { + UNKNOWN = 0; + PROTOBUF = 1; + AVRO = 2; + JSON = 3; + } + string id = 1; + Format format = 2; + string authority = 3; + string description = 4; + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp updated_at = 6; } message ListNamespaceRequest {} message ListNamespaceResponse { - repeated string namespaces = 1; + repeated string namespaces = 1; } message GetNamespaceRequest { - string id = 1; + string id = 1; } message GetNamespaceResponse { - Namespace namespace = 1; + Namespace namespace = 1; } message CreateNamespaceRequest { - string id = 1; - Schema.Format format = 2; - string description = 3; + string id = 1; + Schema.Format format = 2; + string description = 3; } message CreateNamespaceResponse { - Namespace namespace = 1; + Namespace namespace = 1; } message UpdateNamespaceRequest { - string id = 1; + string id = 1; } message UpdateNamespaceResponse { - Namespace namespace = 1; + Namespace namespace = 1; } message DeleteNamespaceRequest { - string id = 1; + string id = 1; } message DeleteNamespaceResponse { - string message = 1; + string message = 1; } message ListSchemasRequest { - string id = 1; + string id = 1; } message ListSchemasResponse { - repeated string schemas = 1; + repeated string schemas = 1; } message DeleteSchemasRequest { - string id = 1; + string id = 1; } message DeleteSchemasResponse { - string message = 1; + string message = 1; } message GetSchemaRequest { - string namespace_id = 1; - string schema_id = 2; + string namespace_id = 1; + string schema_id = 2; } message GetSchemaResponse { - int64 version = 1; - Schema.Format format = 2; - bytes data = 3; + int64 version = 1; + Schema.Format format = 2; + bytes data = 3; } message CreateSchemaRequest { - string namespace_id = 1; - string schema_id = 2; - // can be used to override the namespace level format - Schema.Format format = 3; - string authority = 4; - string description = 5; + string namespace_id = 1; + string schema_id = 2; + // can be used to override the namespace level format + Schema.Format format = 3; + string authority = 4; + string description = 5; } message CreateSchemaResponse { - Schema schema = 1; + Schema schema = 1; } message UpdateSchemaMetadataRequest { - Schema.Format format = 1; - string description = 2; + Schema.Format format = 1; + string description = 2; } message UpdateSchemaMetadataResponse { - Schema schema = 1; + Schema schema = 1; } message DeleteSchemaRequest { - string id = 1; + string id = 1; } message DeleteSchemaResponse { - string message = 1; + string message = 1; } message ListVersionsRequest { - string namespace_id = 1; - string schema_id = 2; + string namespace_id = 1; + string schema_id = 2; } message ListVersionsResponse { - repeated int64 versions = 1; + repeated int64 versions = 1; } message GetVersionRequest { - string namespace_id = 1; - string schema_id = 2; - string version_id = 3; + string namespace_id = 1; + string schema_id = 2; + string version_id = 3; } message GetVersionResponse { - bytes data = 1; + bytes data = 1; } message DeleteVersionRequest { - string namespace_id = 1; - string schema_id = 2; - string version_id = 3; + string namespace_id = 1; + string schema_id = 2; + string version_id = 3; } message DeleteVersionResponse { - string message = 1; + string message = 1; } From e1dd83e648561942ff5c12c250e4b9637df959e6 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 26 Oct 2021 10:04:36 +0530 Subject: [PATCH 05/13] chore: revert go_packge option --- odpf/stencil/v1/stencil.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 496c7378..12cde781 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -option go_package = "github.com/odpf/proton/stencil/v1beta1;stencilv1beta1"; +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) = { From fde9aee3feef764af9b8c300c8aca053c92e6638 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 28 Oct 2021 20:55:41 +0530 Subject: [PATCH 06/13] fix(stencil): add data field --- odpf/stencil/v1/stencil.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 12cde781..52178eba 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -76,7 +76,7 @@ service StencilService { } rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { option (google.api.http) = { - post: "/v1/namespaces/{id}/schemas/{schema_id}" + post: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -247,6 +247,7 @@ message CreateSchemaRequest { Schema.Format format = 3; string authority = 4; string description = 5; + bytes data = 6; } message CreateSchemaResponse { From 926317dbb4ef42845082d489c6ca29eaf8d8b968 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 28 Oct 2021 21:01:59 +0530 Subject: [PATCH 07/13] fix(stencil): add missing field in namespace requests --- odpf/stencil/v1/stencil.proto | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 52178eba..334459a7 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -85,7 +85,7 @@ service StencilService { } rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { option (google.api.http) = { - patch: "/v1/namespaces/{id}/schemas/{schema_id}" + patch: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -130,7 +130,7 @@ service StencilService { summary: "List all version numbers for schema"; }; } - rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) { + rpc GetVersionedSchema(GetVersionRequest) returns (GetVersionResponse) { option (google.api.http) = { get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" }; @@ -255,8 +255,10 @@ message CreateSchemaResponse { } message UpdateSchemaMetadataRequest { - Schema.Format format = 1; - string description = 2; + string namespace_id = 1; + string schema_id = 2; + Schema.Format format = 3; + string description = 4; } message UpdateSchemaMetadataResponse { @@ -264,7 +266,8 @@ message UpdateSchemaMetadataResponse { } message DeleteSchemaRequest { - string id = 1; + string namespace_id = 1; + string schema_id = 2; } message DeleteSchemaResponse { From e98ae2d8885ee8f1efe9856dea451336ae2d5be0 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 28 Oct 2021 21:11:22 +0530 Subject: [PATCH 08/13] chore: add previous protos as intermediatory step for dev --- odpf/stencil/v1/stencil.proto | 120 +++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 334459a7..d259cb0f 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package odpf.stencil.v1; 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"; @@ -16,8 +17,125 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { }; 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; +} + +service StencilServiceV1 { rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceResponse) { option (google.api.http) = { get: "/v1/namespaces" From 1c45e98de65d3ae191760490c6f860f4860a6f2e Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 28 Oct 2021 23:53:46 +0530 Subject: [PATCH 09/13] chore(stencil): fix typo --- odpf/stencil/v1/stencil.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index d259cb0f..704600ef 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -136,7 +136,7 @@ message PromoteSnapshotResponse { } service StencilServiceV1 { - rpc ListNamespace(ListNamespaceRequest) returns (ListNamespaceResponse) { + rpc ListNamespaces(ListNamespaceRequest) returns (ListNamespaceResponse) { option (google.api.http) = { get: "/v1/namespaces" }; From 8761d0315efc9cfbfe6919f0f76ed55b0ba014fa Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Fri, 29 Oct 2021 12:30:31 +0530 Subject: [PATCH 10/13] fix(stencil): add missing field in namespace update request --- odpf/stencil/v1/stencil.proto | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 704600ef..06788fd9 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -166,7 +166,8 @@ service StencilServiceV1 { } rpc UpdateNamespace(UpdateNamespaceRequest) returns (UpdateNamespaceResponse) { option (google.api.http) = { - put: "/v1/namespaces/{id}" + put: "/v1/namespaces/{id}", + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "namespace"; @@ -319,6 +320,8 @@ message CreateNamespaceResponse { message UpdateNamespaceRequest { string id = 1; + Schema.Format format = 2; + string description = 3; } message UpdateNamespaceResponse { From 721e005f4a405aa5847b6a1986e2ee1ceba7e041 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Mon, 1 Nov 2021 21:28:28 +0530 Subject: [PATCH 11/13] fix(stencil): schema rpcs --- odpf/stencil/v1/stencil.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 06788fd9..e51769fe 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -195,7 +195,8 @@ service StencilServiceV1 { } rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { option (google.api.http) = { - post: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + post: "/v1/namespaces/{namespace_id}/schemas/{schema_id}", + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -205,6 +206,7 @@ service StencilServiceV1 { rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { option (google.api.http) = { patch: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; From f0c77f3350289b909860ca2136d3fe5b6ba4ce2d Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Fri, 5 Nov 2021 09:01:35 +0530 Subject: [PATCH 12/13] feat: modify stencil APIs --- odpf/stencil/v1/stencil.proto | 229 +++++++++------------------------- 1 file changed, 59 insertions(+), 170 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index e51769fe..b7c636e5 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -17,126 +17,9 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { }; 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; -} - -service StencilServiceV1 { - rpc ListNamespaces(ListNamespaceRequest) returns (ListNamespaceResponse) { +service StencilService { + rpc ListNamespaces(ListNamespacesRequest) returns (ListNamespacesResponse) { option (google.api.http) = { get: "/v1/namespaces" }; @@ -200,29 +83,29 @@ service StencilServiceV1 { }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; - summary: "Create schema under the namespace"; + summary: "Create schema under the namespace. Returns version number, unique ID and location"; }; } - rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { + rpc GetSchemaMetadata(GetSchemaMetadataRequest) returns (GetSchemaMetadataResponse) { option (google.api.http) = { - patch: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" - body: "*" + get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/meta" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; - summary: "Update only schema metadata"; + summary: "Create schema under the namespace. Returns version number, unique ID and location"; }; } - rpc DeleteSchemas(DeleteSchemasRequest) returns (DeleteSchemasResponse) { + rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { option (google.api.http) = { - delete: "/v1/namespaces/{id}/schemas" + patch: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; - summary: "Delete all schemas under specified namespace"; + summary: "Update only schema metadata"; }; } - rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { + rpc GetLatestSchema(GetLatestSchemaRequest) returns (GetLatestSchemaResponse) { option (google.api.http) = { get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" }; @@ -241,24 +124,24 @@ service StencilServiceV1 { summary: "Delete specified schema"; }; } - rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { + rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions" + get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; tags: "version"; - summary: "List all version numbers for schema"; + summary: "Get schema for specified version"; }; } - rpc GetVersionedSchema(GetVersionRequest) returns (GetVersionResponse) { + rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" + get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; tags: "version"; - summary: "Get schema for specified version"; + summary: "List all version numbers for schema"; }; } rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { @@ -283,22 +166,26 @@ message Namespace { message Schema { enum Format { - UNKNOWN = 0; - PROTOBUF = 1; - AVRO = 2; - JSON = 3; + FORMAT_UNSPECIFIED = 0; + FORMAT_PROTOBUF = 1; + FORMAT_AVRO = 2; + FORMAT_JSON = 3; } - string id = 1; + enum Compatibility { + COMPATIBILITY_UNSPECIFIED = 0; + COMPATIBILITY_FULL = 1; + } + string name = 1; Format format = 2; string authority = 3; - string description = 4; + Compatibility compatibility = 4; google.protobuf.Timestamp created_at = 5; google.protobuf.Timestamp updated_at = 6; } -message ListNamespaceRequest {} +message ListNamespacesRequest {} -message ListNamespaceResponse { +message ListNamespacesResponse { repeated string namespaces = 1; } @@ -311,8 +198,8 @@ message GetNamespaceResponse { } message CreateNamespaceRequest { - string id = 1; - Schema.Format format = 2; + string id = 1 [(google.api.field_behavior) = REQUIRED]; + Schema.Format format = 2 [(google.api.field_behavior) = REQUIRED]; string description = 3; } @@ -322,7 +209,7 @@ message CreateNamespaceResponse { message UpdateNamespaceRequest { string id = 1; - Schema.Format format = 2; + Schema.Format format = 2 [(google.api.field_behavior) = REQUIRED]; string description = 3; } @@ -344,48 +231,50 @@ message ListSchemasResponse { repeated string schemas = 1; } -message DeleteSchemasRequest { - string id = 1; +message GetLatestSchemaRequest { + string namespace_id = 1; + string schema_id = 2; } -message DeleteSchemasResponse { - string message = 1; +message GetLatestSchemaResponse { + bytes data = 3; } -message GetSchemaRequest { +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 GetSchemaResponse { - int64 version = 1; - Schema.Format format = 2; - bytes data = 3; +message CreateSchemaResponse { + int32 version = 1; + string id = 2; + string location = 3; } -message CreateSchemaRequest { +message GetSchemaMetadataRequest { string namespace_id = 1; string schema_id = 2; - // can be used to override the namespace level format - Schema.Format format = 3; - string authority = 4; - string description = 5; - bytes data = 6; } -message CreateSchemaResponse { - Schema schema = 1; +message GetSchemaMetadataResponse { + Schema.Format format = 1; + Schema.Compatibility compatibility = 2; + string authority = 3; } message UpdateSchemaMetadataRequest { string namespace_id = 1; string schema_id = 2; - Schema.Format format = 3; - string description = 4; + Schema.Compatibility compatibility = 3; } message UpdateSchemaMetadataResponse { - Schema schema = 1; + Schema.Format format = 1; + Schema.Compatibility compatibility = 2; + string authority = 3; } message DeleteSchemaRequest { @@ -403,23 +292,23 @@ message ListVersionsRequest { } message ListVersionsResponse { - repeated int64 versions = 1; + repeated int32 versions = 1; } -message GetVersionRequest { +message GetSchemaRequest { string namespace_id = 1; string schema_id = 2; - string version_id = 3; + int32 version_id = 3; } -message GetVersionResponse { +message GetSchemaResponse { bytes data = 1; } message DeleteVersionRequest { string namespace_id = 1; string schema_id = 2; - string version_id = 3; + int32 version_id = 3; } message DeleteVersionResponse { From 062a6b87aea85160e3b457cfc8a2538a3e6ec117 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 16 Nov 2021 09:44:51 +0530 Subject: [PATCH 13/13] refactor(stencil): move proto package to v1beta1 --- odpf/stencil/{v1 => v1beta1}/stencil.proto | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) rename odpf/stencil/{v1 => v1beta1}/stencil.proto (89%) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1beta1/stencil.proto similarity index 89% rename from odpf/stencil/v1/stencil.proto rename to odpf/stencil/v1beta1/stencil.proto index b7c636e5..0e4aea6a 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1beta1/stencil.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package odpf.stencil.v1; +package odpf.stencil.v1beta1; import "google/api/annotations.proto"; import "google/api/field_behavior.proto"; @@ -8,7 +8,7 @@ import "google/protobuf/timestamp.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -option go_package = "github.com/odpf/proton/stencil/v1;stencilv1"; +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) = { @@ -21,7 +21,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { service StencilService { rpc ListNamespaces(ListNamespacesRequest) returns (ListNamespacesResponse) { option (google.api.http) = { - get: "/v1/namespaces" + get: "/v1beta1/namespaces" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "namespace"; @@ -30,7 +30,7 @@ service StencilService { } rpc GetNamespace(GetNamespaceRequest) returns (GetNamespaceResponse) { option (google.api.http) = { - get: "/v1/namespaces/{id}" + get: "/v1beta1/namespaces/{id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "namespace"; @@ -39,7 +39,7 @@ service StencilService { } rpc CreateNamespace(CreateNamespaceRequest) returns (CreateNamespaceResponse) { option (google.api.http) = { - post: "/v1/namespaces", + post: "/v1beta1/namespaces", body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { @@ -49,7 +49,7 @@ service StencilService { } rpc UpdateNamespace(UpdateNamespaceRequest) returns (UpdateNamespaceResponse) { option (google.api.http) = { - put: "/v1/namespaces/{id}", + put: "/v1beta1/namespaces/{id}", body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { @@ -59,7 +59,7 @@ service StencilService { } rpc DeleteNamespace(DeleteNamespaceRequest) returns (DeleteNamespaceResponse) { option (google.api.http) = { - delete: "/v1/namespaces/{id}" + delete: "/v1beta1/namespaces/{id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "namespace"; @@ -69,7 +69,7 @@ service StencilService { } rpc ListSchemas(ListSchemasRequest) returns (ListSchemasResponse) { option (google.api.http) = { - get: "/v1/namespaces/{id}/schemas" + get: "/v1beta1/namespaces/{id}/schemas" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -78,7 +78,7 @@ service StencilService { } rpc CreateSchema(CreateSchemaRequest) returns (CreateSchemaResponse) { option (google.api.http) = { - post: "/v1/namespaces/{namespace_id}/schemas/{schema_id}", + post: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}", body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { @@ -88,7 +88,7 @@ service StencilService { } rpc GetSchemaMetadata(GetSchemaMetadataRequest) returns (GetSchemaMetadataResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/meta" + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/meta" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -97,7 +97,7 @@ service StencilService { } rpc UpdateSchemaMetadata(UpdateSchemaMetadataRequest) returns (UpdateSchemaMetadataResponse) { option (google.api.http) = { - patch: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + patch: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { @@ -107,7 +107,7 @@ service StencilService { } rpc GetLatestSchema(GetLatestSchemaRequest) returns (GetLatestSchemaResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -117,7 +117,7 @@ service StencilService { } rpc DeleteSchema(DeleteSchemaRequest) returns (DeleteSchemaResponse) { option (google.api.http) = { - delete: "/v1/namespaces/{namespace_id}/schemas/{schema_id}" + delete: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -126,7 +126,7 @@ service StencilService { } rpc GetSchema(GetSchemaRequest) returns (GetSchemaResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -136,7 +136,7 @@ service StencilService { } rpc ListVersions(ListVersionsRequest) returns (ListVersionsResponse) { option (google.api.http) = { - get: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions" + get: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema"; @@ -146,7 +146,7 @@ service StencilService { } rpc DeleteVersion(DeleteVersionRequest) returns (DeleteVersionResponse) { option (google.api.http) = { - delete: "/v1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" + delete: "/v1beta1/namespaces/{namespace_id}/schemas/{schema_id}/versions/{version_id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { tags: "schema";