From 8aff255d624268cbe692bbffd3586c733640918d Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 2 Sep 2021 09:59:01 +0530 Subject: [PATCH 1/5] feat(stencil): add stencil protos --- odpf/stencil/v1/stencil.proto | 88 +++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 odpf/stencil/v1/stencil.proto diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto new file mode 100644 index 00000000..a1a5b79a --- /dev/null +++ b/odpf/stencil/v1/stencil.proto @@ -0,0 +1,88 @@ +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/stencil/server/api/v1/pb"; + +// These annotations are used when generating the OpenAPI file. +option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { + info: { + version: "0.1.3"; + }; + external_docs: { + description: "Stencil server"; + } + schemes: HTTP; +}; + +message Snapshot { + int64 id = 1; + string namespace = 2 [(google.api.field_behavior) = REQUIRED]; + string name = 3; + string version = 4; + bool latest = 5; +} + +message DownloadRequest { + 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 DownloadResponse { + bytes data = 1; +} + +message UploadRequest { + 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; + repeated string skiprules = 7; +} + +message UploadResponse { + bool success = 1; + bool dryrun = 2; + string errors = 3; +} + +message ListSnapshotsResponse { + repeated Snapshot snapshots = 1; +} + +message ListSnapshotsRequest { + string namespace = 1; + string name = 2; + string version = 3; + bool latest = 4; +} + +message UpdateLatestRequest { + int64 id = 1; + bool latest = 2; +} + +service StencilService { + rpc UploadDescriptors (UploadRequest) returns (UploadResponse) {} + rpc DownloadDescriptors (DownloadRequest) returns (DownloadResponse) {} + rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) { + option (google.api.http) = { + get: "/v1/snapshots" + }; + } + rpc UpdateLatest(UpdateLatestRequest) returns (Snapshot) { + option (google.api.http) = { + patch: "/v1/snapshots/{id}", + body: "*" + }; + } +} From 9f8a2d95f06646e47a49fd50f33b36507c4ef1ac Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Thu, 2 Sep 2021 18:34:25 +0530 Subject: [PATCH 2/5] refactor: change rpc method names --- odpf/stencil/v1/stencil.proto | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index a1a5b79a..1382160d 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -28,18 +28,18 @@ message Snapshot { bool latest = 5; } -message DownloadRequest { +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 DownloadResponse { +message DownloadDescriptorResponse { bytes data = 1; } -message UploadRequest { +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]; @@ -49,7 +49,7 @@ message UploadRequest { repeated string skiprules = 7; } -message UploadResponse { +message UploadDescriptorResponse { bool success = 1; bool dryrun = 2; string errors = 3; @@ -66,23 +66,21 @@ message ListSnapshotsRequest { bool latest = 4; } -message UpdateLatestRequest { +message PromoteSnapshotRequest { int64 id = 1; - bool latest = 2; } service StencilService { - rpc UploadDescriptors (UploadRequest) returns (UploadResponse) {} - rpc DownloadDescriptors (DownloadRequest) returns (DownloadResponse) {} + rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) {} + rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) {} rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) { option (google.api.http) = { get: "/v1/snapshots" }; } - rpc UpdateLatest(UpdateLatestRequest) returns (Snapshot) { + rpc PromoteSnapshot(PromoteSnapshotRequest) returns (Snapshot) { option (google.api.http) = { - patch: "/v1/snapshots/{id}", - body: "*" + patch: "/v1/snapshots/{id}:promote" }; } } From 907f15942960cc5c814a681668388dd7381e49d7 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Mon, 6 Sep 2021 11:08:44 +0530 Subject: [PATCH 3/5] refactor(stencil): modify package name and rpc methods --- odpf/stencil/v1/stencil.proto | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 1382160d..79a10271 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -7,7 +7,7 @@ import "google/protobuf/descriptor.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; -option go_package = "github.com/odpf/stencil/server/api/v1/pb"; +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) = { @@ -70,6 +70,10 @@ message PromoteSnapshotRequest { int64 id = 1; } +message PromoteSnapshotResponse { + Snapshot snapshot = 1; +} + service StencilService { rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) {} rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) {} @@ -78,7 +82,8 @@ service StencilService { get: "/v1/snapshots" }; } - rpc PromoteSnapshot(PromoteSnapshotRequest) returns (Snapshot) { + // PromoteSnapshot promotes particular snapshot version as latest + rpc PromoteSnapshot(PromoteSnapshotRequest) returns (PromoteSnapshotResponse) { option (google.api.http) = { patch: "/v1/snapshots/{id}:promote" }; From c67556ded32b60841f3dc63db1692349903b159e Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Mon, 6 Sep 2021 12:10:09 +0530 Subject: [PATCH 4/5] refactor(stencil): create rules enum --- odpf/stencil/v1/stencil.proto | 42 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index 79a10271..af4b7ca4 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -20,6 +20,30 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { schemes: HTTP; }; +service StencilService { + rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) {} + rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) {} + 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" + }; + } +} + +enum Rules { + 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]; @@ -46,7 +70,7 @@ message UploadDescriptorRequest { bytes data = 4 [(google.api.field_behavior) = REQUIRED]; bool latest = 5; bool dryrun = 6; - repeated string skiprules = 7; + repeated Rules skiprules = 7; } message UploadDescriptorResponse { @@ -73,19 +97,3 @@ message PromoteSnapshotRequest { message PromoteSnapshotResponse { Snapshot snapshot = 1; } - -service StencilService { - rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) {} - rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) {} - 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" - }; - } -} From a3930a0a333c1d96dcc6f97fd0187b412bf18089 Mon Sep 17 00:00:00 2001 From: Harikrishna Date: Tue, 7 Sep 2021 11:26:15 +0530 Subject: [PATCH 5/5] refactor(stencil): add checks type to have skiprules --- odpf/stencil/v1/stencil.proto | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/odpf/stencil/v1/stencil.proto b/odpf/stencil/v1/stencil.proto index af4b7ca4..227a399a 100644 --- a/odpf/stencil/v1/stencil.proto +++ b/odpf/stencil/v1/stencil.proto @@ -12,17 +12,23 @@ 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.3"; + version: "0.1.4"; }; - external_docs: { - description: "Stencil server"; - } schemes: HTTP; }; service StencilService { - rpc UploadDescriptor (UploadDescriptorRequest) returns (UploadDescriptorResponse) {} - rpc DownloadDescriptor (DownloadDescriptorRequest) returns (DownloadDescriptorResponse) {} + 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" @@ -36,7 +42,7 @@ service StencilService { } } -enum Rules { +enum Rule { UNKNOWN = 0; FILE_NO_BREAKING_CHANGE = 1; MESSAGE_NO_DELETE = 2; @@ -70,7 +76,11 @@ message UploadDescriptorRequest { bytes data = 4 [(google.api.field_behavior) = REQUIRED]; bool latest = 5; bool dryrun = 6; - repeated Rules skiprules = 7; + Checks checks = 7; +} + +message Checks { + repeated Rule except = 2; } message UploadDescriptorResponse {