From 985e917e72f2e077518335cf1b1ff5bb1bfec550 Mon Sep 17 00:00:00 2001 From: Yusuke Tsutsumi Date: Sun, 15 Sep 2024 17:57:25 -0700 Subject: [PATCH] fix(lint): use buf plugins for lint and fixes for AEP compliance. Using buf plugins for linting is a more ergonomic approach, avoiding the need to manually clone googleapis. Fixes to reach AEP compliance: - removing apply method as it is not an official AEP at the moment. --- .github/workflows/test.yml | 9 +- buf.lock | 8 +- buf.yaml | 6 +- example/bookstore/v1/bookstore.pb.go | 211 ++++++-------------- example/bookstore/v1/bookstore.pb.gw.go | 119 ----------- example/bookstore/v1/bookstore.proto | 17 -- example/bookstore/v1/bookstore.swagger.json | 43 ---- example/bookstore/v1/bookstore.yaml | 2 +- example/bookstore/v1/bookstore_grpc.pb.go | 39 ---- example/bookstore/v1/bookstore_openapi.json | 18 -- schema/resourcedefinition.pb.go | 116 +++++++---- schema/resourcedefinition.proto | 64 ++++-- 12 files changed, 198 insertions(+), 454 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1aa5c8..9491169 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,13 +21,14 @@ jobs: - name: "test: no change to generated files." run: | - go install github.com/bufbuild/buf/cmd/buf@v1.38.0 + go install github.com/bufbuild/buf/cmd/buf@v1.42.0 ./scripts/verify-goldens.sh - name: "test: example server function" run: | ./scripts/test_http_api.sh - # - name: Run script - # run: | - # ./scripts/run-api-linter.sh + - name: run api-linter + run: | + go install github.com/aep-dev/api-linter/cmd/buf-plugin-aep@latest + buf lint --path example/bookstore/v1/bookstore.proto diff --git a/buf.lock b/buf.lock index 6c4355d..c83a0ee 100644 --- a/buf.lock +++ b/buf.lock @@ -1,8 +1,6 @@ # Generated by buf. DO NOT EDIT. -version: v1 +version: v2 deps: - - remote: buf.build - owner: googleapis - repository: googleapis + - name: buf.build/googleapis/googleapis commit: 28151c0d0a1641bf938a7672c500e01d - digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de + digest: b5:93b70089baa4fc05a92d3e52db91a4b7812db3b57b9664f6cb301733938cb630e377a938e8a56779388171c749c1d42a2e9a6c6230f2ff45f127a8102a6a27d0 diff --git a/buf.yaml b/buf.yaml index 204dbaa..ea81f26 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,9 +1,11 @@ -version: v1 +version: v2 breaking: use: - FILE lint: use: - - DEFAULT + - AEP +plugins: + - plugin: buf-plugin-aep deps: - buf.build/googleapis/googleapis:28151c0d0a1641bf938a7672c500e01d diff --git a/example/bookstore/v1/bookstore.pb.go b/example/bookstore/v1/bookstore.pb.go index 9926b77..7fb7b87 100644 --- a/example/bookstore/v1/bookstore.pb.go +++ b/example/bookstore/v1/bookstore.pb.go @@ -474,64 +474,6 @@ func (x *ListBookResponse) GetNextPageToken() string { return "" } -// Request message for the ApplyBook method -type ApplyBookRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The globally unique identifier for the resource - Path string `protobuf:"bytes,10018,opt,name=path,proto3" json:"path,omitempty"` - // The resource to perform the operation on. - Book *Book `protobuf:"bytes,10015,opt,name=book,proto3" json:"book,omitempty"` -} - -func (x *ApplyBookRequest) Reset() { - *x = ApplyBookRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ApplyBookRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ApplyBookRequest) ProtoMessage() {} - -func (x *ApplyBookRequest) ProtoReflect() protoreflect.Message { - mi := &file_example_bookstore_v1_bookstore_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ApplyBookRequest.ProtoReflect.Descriptor instead. -func (*ApplyBookRequest) Descriptor() ([]byte, []int) { - return file_example_bookstore_v1_bookstore_proto_rawDescGZIP(), []int{7} -} - -func (x *ApplyBookRequest) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *ApplyBookRequest) GetBook() *Book { - if x != nil { - return x.Book - } - return nil -} - var File_example_bookstore_v1_bookstore_proto protoreflect.FileDescriptor var file_example_bookstore_v1_bookstore_proto_rawDesc = []byte{ @@ -604,62 +546,47 @@ var file_example_bookstore_v1_bookstore_proto_rawDesc = []byte{ 0x6f, 0x6b, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x9b, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x81, 0x01, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x6f, - 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x37, 0x0a, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x18, 0xa2, 0x4e, 0x20, 0x01, 0x28, 0x09, 0x42, 0x22, 0xe0, 0x41, 0x02, 0xfa, 0x41, 0x1c, - 0x0a, 0x1a, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x34, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x9f, 0x4e, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, 0x03, 0xe0, - 0x41, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0xda, 0x05, 0x0a, 0x09, 0x42, 0x6f, 0x6f, - 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x7e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, - 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, + 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xea, 0x04, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x12, 0x7e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, + 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, + 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x2b, 0xda, 0x41, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x2c, 0x62, 0x6f, 0x6f, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, + 0x6b, 0x22, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, + 0x73, 0x7d, 0x12, 0x6b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x24, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x2b, 0xda, 0x41, 0x0b, 0x70, 0x61, - 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x62, 0x6f, 0x6f, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, - 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, - 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x7d, 0x12, 0x6b, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, - 0x6b, 0x12, 0x24, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, - 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, + 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, + 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, + 0x83, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, + 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, - 0x6f, 0x6f, 0x6b, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, - 0x2f, 0x2a, 0x7d, 0x12, 0x83, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, - 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, - 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x30, 0xda, 0x41, 0x10, 0x62, 0x6f, 0x6f, 0x6b, - 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x17, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, - 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6d, 0x0a, 0x0a, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x2a, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, - 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x7b, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x25, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, - 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x65, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x20, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x62, - 0x6f, 0x6f, 0x6b, 0x73, 0x7d, 0x12, 0x6e, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x42, 0x6f, - 0x6f, 0x6b, 0x12, 0x26, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, - 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x42, - 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, - 0x62, 0x6f, 0x6f, 0x6b, 0x1a, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, - 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x42, 0x0c, 0x5a, 0x0a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6f, 0x6b, 0x22, 0x30, 0xda, 0x41, 0x10, 0x62, 0x6f, 0x6f, 0x6b, 0x2c, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, + 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, + 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x6d, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, + 0x6f, 0x6f, 0x6b, 0x12, 0x27, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, + 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1e, 0xda, 0x41, 0x04, 0x70, 0x61, 0x74, 0x68, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x11, 0x2a, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, + 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x7b, 0x0a, 0x08, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, + 0x12, 0x25, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2e, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x20, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, + 0x12, 0x0f, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x62, 0x6f, 0x6f, 0x6b, 0x73, + 0x7d, 0x42, 0x0c, 0x5a, 0x0a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -674,7 +601,7 @@ func file_example_bookstore_v1_bookstore_proto_rawDescGZIP() []byte { return file_example_bookstore_v1_bookstore_proto_rawDescData } -var file_example_bookstore_v1_bookstore_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_example_bookstore_v1_bookstore_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_example_bookstore_v1_bookstore_proto_goTypes = []interface{}{ (*Book)(nil), // 0: example.bookstore.v1.Book (*CreateBookRequest)(nil), // 1: example.bookstore.v1.CreateBookRequest @@ -683,33 +610,29 @@ var file_example_bookstore_v1_bookstore_proto_goTypes = []interface{}{ (*DeleteBookRequest)(nil), // 4: example.bookstore.v1.DeleteBookRequest (*ListBookRequest)(nil), // 5: example.bookstore.v1.ListBookRequest (*ListBookResponse)(nil), // 6: example.bookstore.v1.ListBookResponse - (*ApplyBookRequest)(nil), // 7: example.bookstore.v1.ApplyBookRequest - (*fieldmaskpb.FieldMask)(nil), // 8: google.protobuf.FieldMask - (*emptypb.Empty)(nil), // 9: google.protobuf.Empty + (*fieldmaskpb.FieldMask)(nil), // 7: google.protobuf.FieldMask + (*emptypb.Empty)(nil), // 8: google.protobuf.Empty } var file_example_bookstore_v1_bookstore_proto_depIdxs = []int32{ - 0, // 0: example.bookstore.v1.CreateBookRequest.book:type_name -> example.bookstore.v1.Book - 0, // 1: example.bookstore.v1.UpdateBookRequest.book:type_name -> example.bookstore.v1.Book - 8, // 2: example.bookstore.v1.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask - 0, // 3: example.bookstore.v1.ListBookResponse.results:type_name -> example.bookstore.v1.Book - 0, // 4: example.bookstore.v1.ApplyBookRequest.book:type_name -> example.bookstore.v1.Book - 1, // 5: example.bookstore.v1.Bookstore.CreateBook:input_type -> example.bookstore.v1.CreateBookRequest - 2, // 6: example.bookstore.v1.Bookstore.GetBook:input_type -> example.bookstore.v1.GetBookRequest - 3, // 7: example.bookstore.v1.Bookstore.UpdateBook:input_type -> example.bookstore.v1.UpdateBookRequest - 4, // 8: example.bookstore.v1.Bookstore.DeleteBook:input_type -> example.bookstore.v1.DeleteBookRequest - 5, // 9: example.bookstore.v1.Bookstore.ListBook:input_type -> example.bookstore.v1.ListBookRequest - 7, // 10: example.bookstore.v1.Bookstore.ApplyBook:input_type -> example.bookstore.v1.ApplyBookRequest - 0, // 11: example.bookstore.v1.Bookstore.CreateBook:output_type -> example.bookstore.v1.Book - 0, // 12: example.bookstore.v1.Bookstore.GetBook:output_type -> example.bookstore.v1.Book - 0, // 13: example.bookstore.v1.Bookstore.UpdateBook:output_type -> example.bookstore.v1.Book - 9, // 14: example.bookstore.v1.Bookstore.DeleteBook:output_type -> google.protobuf.Empty - 6, // 15: example.bookstore.v1.Bookstore.ListBook:output_type -> example.bookstore.v1.ListBookResponse - 0, // 16: example.bookstore.v1.Bookstore.ApplyBook:output_type -> example.bookstore.v1.Book - 11, // [11:17] is the sub-list for method output_type - 5, // [5:11] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 0, // 0: example.bookstore.v1.CreateBookRequest.book:type_name -> example.bookstore.v1.Book + 0, // 1: example.bookstore.v1.UpdateBookRequest.book:type_name -> example.bookstore.v1.Book + 7, // 2: example.bookstore.v1.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask + 0, // 3: example.bookstore.v1.ListBookResponse.results:type_name -> example.bookstore.v1.Book + 1, // 4: example.bookstore.v1.Bookstore.CreateBook:input_type -> example.bookstore.v1.CreateBookRequest + 2, // 5: example.bookstore.v1.Bookstore.GetBook:input_type -> example.bookstore.v1.GetBookRequest + 3, // 6: example.bookstore.v1.Bookstore.UpdateBook:input_type -> example.bookstore.v1.UpdateBookRequest + 4, // 7: example.bookstore.v1.Bookstore.DeleteBook:input_type -> example.bookstore.v1.DeleteBookRequest + 5, // 8: example.bookstore.v1.Bookstore.ListBook:input_type -> example.bookstore.v1.ListBookRequest + 0, // 9: example.bookstore.v1.Bookstore.CreateBook:output_type -> example.bookstore.v1.Book + 0, // 10: example.bookstore.v1.Bookstore.GetBook:output_type -> example.bookstore.v1.Book + 0, // 11: example.bookstore.v1.Bookstore.UpdateBook:output_type -> example.bookstore.v1.Book + 8, // 12: example.bookstore.v1.Bookstore.DeleteBook:output_type -> google.protobuf.Empty + 6, // 13: example.bookstore.v1.Bookstore.ListBook:output_type -> example.bookstore.v1.ListBookResponse + 9, // [9:14] is the sub-list for method output_type + 4, // [4:9] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_example_bookstore_v1_bookstore_proto_init() } @@ -802,18 +725,6 @@ func file_example_bookstore_v1_bookstore_proto_init() { return nil } } - file_example_bookstore_v1_bookstore_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ApplyBookRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -821,7 +732,7 @@ func file_example_bookstore_v1_bookstore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_example_bookstore_v1_bookstore_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/example/bookstore/v1/bookstore.pb.gw.go b/example/bookstore/v1/bookstore.pb.gw.go index 8c7679d..787621d 100644 --- a/example/bookstore/v1/bookstore.pb.gw.go +++ b/example/bookstore/v1/bookstore.pb.gw.go @@ -391,74 +391,6 @@ func local_request_Bookstore_ListBook_0(ctx context.Context, marshaler runtime.M } -func request_Bookstore_ApplyBook_0(ctx context.Context, marshaler runtime.Marshaler, client BookstoreClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ApplyBookRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Book); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["path"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") - } - - protoReq.Path, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) - } - - msg, err := client.ApplyBook(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Bookstore_ApplyBook_0(ctx context.Context, marshaler runtime.Marshaler, server BookstoreServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq ApplyBookRequest - var metadata runtime.ServerMetadata - - newReader, berr := utilities.IOReaderFactory(req.Body) - if berr != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) - } - if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Book); err != nil && err != io.EOF { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["path"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path") - } - - protoReq.Path, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path", err) - } - - msg, err := server.ApplyBook(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterBookstoreHandlerServer registers the http handlers for service Bookstore to "mux". // UnaryRPC :call BookstoreServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -590,31 +522,6 @@ func RegisterBookstoreHandlerServer(ctx context.Context, mux *runtime.ServeMux, }) - mux.Handle("PUT", pattern_Bookstore_ApplyBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Bookstore_ApplyBook_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_Bookstore_ApplyBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -766,28 +673,6 @@ func RegisterBookstoreHandlerClient(ctx context.Context, mux *runtime.ServeMux, }) - mux.Handle("PUT", pattern_Bookstore_ApplyBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - var err error - var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/example.bookstore.v1.Bookstore/ApplyBook", runtime.WithHTTPPathPattern("/{path=books/*}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Bookstore_ApplyBook_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - - forward_Bookstore_ApplyBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -801,8 +686,6 @@ var ( pattern_Bookstore_DeleteBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) pattern_Bookstore_ListBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 4, 1, 5, 1}, []string{"books", "parent"}, "")) - - pattern_Bookstore_ApplyBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 2, 5, 1}, []string{"books", "path"}, "")) ) var ( @@ -815,6 +698,4 @@ var ( forward_Bookstore_DeleteBook_0 = runtime.ForwardResponseMessage forward_Bookstore_ListBook_0 = runtime.ForwardResponseMessage - - forward_Bookstore_ApplyBook_0 = runtime.ForwardResponseMessage ) diff --git a/example/bookstore/v1/bookstore.proto b/example/bookstore/v1/bookstore.proto index 82fc563..485134a 100644 --- a/example/bookstore/v1/bookstore.proto +++ b/example/bookstore/v1/bookstore.proto @@ -52,11 +52,6 @@ service Bookstore { option (google.api.method_signature) = "parent"; } - - // An aep-compliant Apply method for books. - rpc ApplyBook ( ApplyBookRequest ) returns ( Book ) { - option (google.api.http) = { put: "/{path=books/*}", body: "book" }; - } } // A Book resource. @@ -151,15 +146,3 @@ message ListBookResponse { // The page token indicating the ending point of this response. string next_page_token = 10011; } - -// Request message for the ApplyBook method -message ApplyBookRequest { - // The globally unique identifier for the resource - string path = 10018 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { type: "bookstore.example.com/Book" } - ]; - - // The resource to perform the operation on. - Book book = 10015 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/example/bookstore/v1/bookstore.swagger.json b/example/bookstore/v1/bookstore.swagger.json index b81661a..aa3e6ed 100644 --- a/example/bookstore/v1/bookstore.swagger.json +++ b/example/bookstore/v1/bookstore.swagger.json @@ -178,49 +178,6 @@ "Bookstore" ] }, - "put": { - "summary": "An aep-compliant Apply method for books.", - "operationId": "Bookstore_ApplyBook", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/v1Book" - } - }, - "default": { - "description": "An unexpected error response.", - "schema": { - "$ref": "#/definitions/rpcStatus" - } - } - }, - "parameters": [ - { - "name": "path", - "description": "The globally unique identifier for the resource", - "in": "path", - "required": true, - "type": "string", - "pattern": "books/[^/]+" - }, - { - "name": "book", - "description": "The resource to perform the operation on.", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/v1Book", - "required": [ - "book" - ] - } - } - ], - "tags": [ - "Bookstore" - ] - }, "patch": { "summary": "An aep-compliant Update method for Book.", "operationId": "Bookstore_UpdateBook", diff --git a/example/bookstore/v1/bookstore.yaml b/example/bookstore/v1/bookstore.yaml index f9a36d8..8cd0a1a 100644 --- a/example/bookstore/v1/bookstore.yaml +++ b/example/bookstore/v1/bookstore.yaml @@ -29,7 +29,7 @@ resources: update: {} delete: {} list: {} - apply: {} +# apply: {} # do not uncomment until there is an AEP on apply. # - kind: "Publisher" # plural: "publishers" # methods: diff --git a/example/bookstore/v1/bookstore_grpc.pb.go b/example/bookstore/v1/bookstore_grpc.pb.go index 8fbaba2..4820410 100644 --- a/example/bookstore/v1/bookstore_grpc.pb.go +++ b/example/bookstore/v1/bookstore_grpc.pb.go @@ -25,7 +25,6 @@ const ( Bookstore_UpdateBook_FullMethodName = "/example.bookstore.v1.Bookstore/UpdateBook" Bookstore_DeleteBook_FullMethodName = "/example.bookstore.v1.Bookstore/DeleteBook" Bookstore_ListBook_FullMethodName = "/example.bookstore.v1.Bookstore/ListBook" - Bookstore_ApplyBook_FullMethodName = "/example.bookstore.v1.Bookstore/ApplyBook" ) // BookstoreClient is the client API for Bookstore service. @@ -42,8 +41,6 @@ type BookstoreClient interface { DeleteBook(ctx context.Context, in *DeleteBookRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) // An aep-compliant List method for books. ListBook(ctx context.Context, in *ListBookRequest, opts ...grpc.CallOption) (*ListBookResponse, error) - // An aep-compliant Apply method for books. - ApplyBook(ctx context.Context, in *ApplyBookRequest, opts ...grpc.CallOption) (*Book, error) } type bookstoreClient struct { @@ -99,15 +96,6 @@ func (c *bookstoreClient) ListBook(ctx context.Context, in *ListBookRequest, opt return out, nil } -func (c *bookstoreClient) ApplyBook(ctx context.Context, in *ApplyBookRequest, opts ...grpc.CallOption) (*Book, error) { - out := new(Book) - err := c.cc.Invoke(ctx, Bookstore_ApplyBook_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // BookstoreServer is the server API for Bookstore service. // All implementations must embed UnimplementedBookstoreServer // for forward compatibility @@ -122,8 +110,6 @@ type BookstoreServer interface { DeleteBook(context.Context, *DeleteBookRequest) (*emptypb.Empty, error) // An aep-compliant List method for books. ListBook(context.Context, *ListBookRequest) (*ListBookResponse, error) - // An aep-compliant Apply method for books. - ApplyBook(context.Context, *ApplyBookRequest) (*Book, error) mustEmbedUnimplementedBookstoreServer() } @@ -146,9 +132,6 @@ func (UnimplementedBookstoreServer) DeleteBook(context.Context, *DeleteBookReque func (UnimplementedBookstoreServer) ListBook(context.Context, *ListBookRequest) (*ListBookResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListBook not implemented") } -func (UnimplementedBookstoreServer) ApplyBook(context.Context, *ApplyBookRequest) (*Book, error) { - return nil, status.Errorf(codes.Unimplemented, "method ApplyBook not implemented") -} func (UnimplementedBookstoreServer) mustEmbedUnimplementedBookstoreServer() {} // UnsafeBookstoreServer may be embedded to opt out of forward compatibility for this service. @@ -252,24 +235,6 @@ func _Bookstore_ListBook_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Bookstore_ApplyBook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ApplyBookRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(BookstoreServer).ApplyBook(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Bookstore_ApplyBook_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(BookstoreServer).ApplyBook(ctx, req.(*ApplyBookRequest)) - } - return interceptor(ctx, in, info, handler) -} - // Bookstore_ServiceDesc is the grpc.ServiceDesc for Bookstore service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -297,10 +262,6 @@ var Bookstore_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListBook", Handler: _Bookstore_ListBook_Handler, }, - { - MethodName: "ApplyBook", - Handler: _Bookstore_ApplyBook_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "example/bookstore/v1/bookstore.proto", diff --git a/example/bookstore/v1/bookstore_openapi.json b/example/bookstore/v1/bookstore_openapi.json index 548f8d0..2926b75 100644 --- a/example/bookstore/v1/bookstore_openapi.json +++ b/example/bookstore/v1/bookstore_openapi.json @@ -85,24 +85,6 @@ } } ] - }, - "put": { - "responses": { - "200": { - "schema": { - "$ref": "#/definitions/Book" - } - } - }, - "parameters": [ - { - "in": "body", - "name": "body", - "schema": { - "$ref": "#/definitions/Book" - } - } - ] } } }, diff --git a/schema/resourcedefinition.pb.go b/schema/resourcedefinition.pb.go index afc9485..d64dc52 100644 --- a/schema/resourcedefinition.pb.go +++ b/schema/resourcedefinition.pb.go @@ -1,8 +1,7 @@ // resourcedefinition contains the // schema of the resource definition. -// regenerate with -// -// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\ +// regenerate with: +// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\ // --go_out=. // Code generated by protoc-gen-go. DO NOT EDIT. @@ -27,22 +26,30 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// The pritimive types supported by the schema. type Type int32 const ( - Type_UNSPECIFIED Type = 0 - Type_STRING Type = 1 - Type_INT32 Type = 2 - Type_INT64 Type = 3 - Type_DOUBLE Type = 4 - Type_FLOAT Type = 5 - Type_BOOLEAN Type = 6 + // The type is unspecified. + Type_TYPE_UNSPECIFIED Type = 0 + // The type is a string. + Type_STRING Type = 1 + // The type is an int32. + Type_INT32 Type = 2 + // The type is an int64. + Type_INT64 Type = 3 + // The type is a double. + Type_DOUBLE Type = 4 + // The type is a float. + Type_FLOAT Type = 5 + // The type is a boolean. + Type_BOOLEAN Type = 6 ) // Enum value maps for Type. var ( Type_name = map[int32]string{ - 0: "UNSPECIFIED", + 0: "TYPE_UNSPECIFIED", 1: "STRING", 2: "INT32", 3: "INT64", @@ -51,13 +58,13 @@ var ( 6: "BOOLEAN", } Type_value = map[string]int32{ - "UNSPECIFIED": 0, - "STRING": 1, - "INT32": 2, - "INT64": 3, - "DOUBLE": 4, - "FLOAT": 5, - "BOOLEAN": 6, + "TYPE_UNSPECIFIED": 0, + "STRING": 1, + "INT32": 2, + "INT64": 3, + "DOUBLE": 4, + "FLOAT": 5, + "BOOLEAN": 6, } ) @@ -88,12 +95,15 @@ func (Type) EnumDescriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{0} } +// An API service. type Service struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The name of the API service. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The resources that the API service exposes. Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` // These are additional objects (list of properties) that may be referenced from another property. Objects []*Object `protobuf:"bytes,3,rep,name=objects,proto3" json:"objects,omitempty"` @@ -152,6 +162,7 @@ func (x *Service) GetObjects() []*Object { return nil } +// A resource. type Resource struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -164,9 +175,9 @@ type Resource struct { Plural string `protobuf:"bytes,2,opt,name=plural,proto3" json:"plural,omitempty"` // The list of parent resources, referred to via the kind. Parents []string `protobuf:"bytes,3,rep,name=parents,proto3" json:"parents,omitempty"` - // Properties + // Properties of the resource. Also often referred to as it's schema. Properties map[string]*Property `protobuf:"bytes,4,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // method support + // methods support by the resource. Methods *Methods `protobuf:"bytes,5,opt,name=methods,proto3" json:"methods,omitempty"` } @@ -237,12 +248,16 @@ func (x *Resource) GetMethods() *Methods { return nil } +// An object is a collection of properties, that does not have methods of it's +// on in the API. It is currently only used as a property of a resource. type Object struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + // The name of the object. + Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` + // The properties of the object. Properties map[string]*Property `protobuf:"bytes,2,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -292,18 +307,26 @@ func (x *Object) GetProperties() map[string]*Property { return nil } +// Methods supported by a resource. type Methods struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Create *Methods_CreateMethod `protobuf:"bytes,1,opt,name=create,proto3" json:"create,omitempty"` - Read *Methods_ReadMethod `protobuf:"bytes,2,opt,name=read,proto3" json:"read,omitempty"` - Update *Methods_UpdateMethod `protobuf:"bytes,3,opt,name=update,proto3" json:"update,omitempty"` - Delete *Methods_DeleteMethod `protobuf:"bytes,4,opt,name=delete,proto3" json:"delete,omitempty"` - List *Methods_ListMethod `protobuf:"bytes,5,opt,name=list,proto3" json:"list,omitempty"` + // Specific properties of the create method for the resource. + Create *Methods_CreateMethod `protobuf:"bytes,1,opt,name=create,proto3" json:"create,omitempty"` + // Specific properties of the read method for the resource. + Read *Methods_ReadMethod `protobuf:"bytes,2,opt,name=read,proto3" json:"read,omitempty"` + // Specific properties of the update method for the resource. + Update *Methods_UpdateMethod `protobuf:"bytes,3,opt,name=update,proto3" json:"update,omitempty"` + // Specific properties of the delete emethod for the resource. + Delete *Methods_DeleteMethod `protobuf:"bytes,4,opt,name=delete,proto3" json:"delete,omitempty"` + // Specific properties of the list for the resource. + List *Methods_ListMethod `protobuf:"bytes,5,opt,name=list,proto3" json:"list,omitempty"` + // Specific properties of the global_list for the resource. GlobalList *Methods_GlobalListMethod `protobuf:"bytes,6,opt,name=global_list,json=globalList,proto3" json:"global_list,omitempty"` - Apply *Methods_ApplyMethod `protobuf:"bytes,7,opt,name=apply,proto3" json:"apply,omitempty"` + // Specific properties of the apply for the resource. + Apply *Methods_ApplyMethod `protobuf:"bytes,7,opt,name=apply,proto3" json:"apply,omitempty"` } func (x *Methods) Reset() { @@ -387,6 +410,7 @@ func (x *Methods) GetApply() *Methods_ApplyMethod { return nil } +// A property represents a field in a resource or object. type Property struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -400,9 +424,11 @@ type Property struct { Types isProperty_Types `protobuf_oneof:"types"` // field number used for protobuf or other systems where fields must // be explicitly enumerated. - Number int32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` - ReadOnly bool `protobuf:"varint,3,opt,name=readOnly,proto3" json:"readOnly,omitempty"` - Required bool `protobuf:"varint,4,opt,name=required,proto3" json:"required,omitempty"` + Number int32 `protobuf:"varint,2,opt,name=number,proto3" json:"number,omitempty"` + // true if the property is read only. + ReadOnly bool `protobuf:"varint,3,opt,name=readOnly,proto3" json:"readOnly,omitempty"` + // true if the property is required. + Required bool `protobuf:"varint,4,opt,name=required,proto3" json:"required,omitempty"` } func (x *Property) Reset() { @@ -448,7 +474,7 @@ func (x *Property) GetType() Type { if x, ok := x.GetTypes().(*Property_Type); ok { return x.Type } - return Type_UNSPECIFIED + return Type_TYPE_UNSPECIFIED } func (x *Property) GetObjectType() *ObjectType { @@ -630,7 +656,7 @@ func (x *ArrayType) GetType() Type { if x, ok := x.GetArrayDetails().(*ArrayType_Type); ok { return x.Type } - return Type_UNSPECIFIED + return Type_TYPE_UNSPECIFIED } func (x *ArrayType) GetObjectType() *ObjectType { @@ -656,6 +682,7 @@ func (*ArrayType_Type) isArrayType_ArrayDetails() {} func (*ArrayType_ObjectType) isArrayType_ArrayDetails() {} +// The properties of the create method. type Methods_CreateMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -694,6 +721,7 @@ func (*Methods_CreateMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 0} } +// The properties of the read method. type Methods_ReadMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -732,6 +760,7 @@ func (*Methods_ReadMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 1} } +// The properties of the update method. type Methods_UpdateMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -770,6 +799,7 @@ func (*Methods_UpdateMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 2} } +// The properties of the delete method. type Methods_DeleteMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -808,6 +838,7 @@ func (*Methods_DeleteMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 3} } +// The properties of the list method. type Methods_ListMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -846,6 +877,7 @@ func (*Methods_ListMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 4} } +// THe properties of the global list method. type Methods_GlobalListMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -884,6 +916,7 @@ func (*Methods_GlobalListMethod) Descriptor() ([]byte, []int) { return file_schema_resourcedefinition_proto_rawDescGZIP(), []int{3, 5} } +// THe properties of the apply method. type Methods_ApplyMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1012,14 +1045,15 @@ var file_schema_resourcedefinition_proto_rawDesc = []byte{ 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x61, - 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2a, 0x5d, 0x0a, 0x04, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, - 0x01, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, - 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, - 0x45, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x10, 0x05, 0x12, 0x0b, - 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x06, 0x42, 0x09, 0x5a, 0x07, 0x2f, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x2a, 0x62, 0x0a, 0x04, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, + 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, + 0x02, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, + 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, + 0x54, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x06, + 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/schema/resourcedefinition.proto b/schema/resourcedefinition.proto index c02d1b2..65b77ac 100644 --- a/schema/resourcedefinition.proto +++ b/schema/resourcedefinition.proto @@ -1,20 +1,24 @@ // resourcedefinition contains the // schema of the resource definition. -// regenerate with -// -// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\ +// regenerate with: +// protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative\ // --go_out=. syntax = "proto3"; option go_package = "/schema"; +// An API service. message Service { + // The name of the API service. string name = 1; + + // The resources that the API service exposes. repeated Resource resources = 2; // These are additional objects (list of properties) that may be referenced from another property. repeated Object objects = 3; } +// A resource. message Resource { // The type of the resource. Used to programmatically // refer to and identify the resource. @@ -23,45 +27,55 @@ message Resource { string plural = 2; // The list of parent resources, referred to via the kind. repeated string parents = 3; - // Properties + // Properties of the resource. Also often referred to as it's schema. map properties = 4; - // method support + // methods support by the resource. Methods methods = 5; } +// An object is a collection of properties, that does not have methods of it's +// on in the API. It is currently only used as a property of a resource. message Object { + // The name of the object. string kind = 1; + // The properties of the object. map properties = 2; } +// Methods supported by a resource. message Methods { + // The properties of the create method. message CreateMethod {} + // The properties of the read method. message ReadMethod {} + // The properties of the update method. message UpdateMethod {} + // The properties of the delete method. message DeleteMethod {} + // The properties of the list method. message ListMethod {} + // THe properties of the global list method. message GlobalListMethod {} + // THe properties of the apply method. message ApplyMethod {} + // Specific properties of the create method for the resource. CreateMethod create = 1; + // Specific properties of the read method for the resource. ReadMethod read = 2; + // Specific properties of the update method for the resource. UpdateMethod update = 3; + // Specific properties of the delete emethod for the resource. DeleteMethod delete = 4; + // Specific properties of the list for the resource. ListMethod list = 5; + // Specific properties of the global_list for the resource. GlobalListMethod global_list = 6; + // Specific properties of the apply for the resource. ApplyMethod apply = 7; } -enum Type { - UNSPECIFIED = 0; - STRING = 1; - INT32 = 2; - INT64 = 3; - DOUBLE = 4; - FLOAT = 5; - BOOLEAN = 6; -} - +// A property represents a field in a resource or object. message Property { oneof types { Type type = 1; @@ -71,7 +85,9 @@ message Property { // field number used for protobuf or other systems where fields must // be explicitly enumerated. int32 number = 2; + // true if the property is read only. bool readOnly = 3; + // true if the property is required. bool required = 4; } @@ -87,3 +103,21 @@ message ArrayType { ObjectType object_type = 2; } } + +// The pritimive types supported by the schema. +enum Type { + // The type is unspecified. + TYPE_UNSPECIFIED = 0; + // The type is a string. + STRING = 1; + // The type is an int32. + INT32 = 2; + // The type is an int64. + INT64 = 3; + // The type is a double. + DOUBLE = 4; + // The type is a float. + FLOAT = 5; + // The type is a boolean. + BOOLEAN = 6; +} \ No newline at end of file