Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
- adding 'parent' concept in the resource model
- fixing protoc docs
  • Loading branch information
toumorokoshi committed Sep 22, 2023
1 parent 4d49c67 commit d9cd1c4
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 74 deletions.
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
The standard GoLang toolchain is used, with the addition of protobuf for
compiling the resource definition.

1. `protoc ./aepc/schema/resourcedefinition.proto --go_opt paths=source_relative --go_out=.`
1. `protoc ./schema/resourcedefinition.proto --go_opt paths=source_relative --go_out=.`
2. `go build main.go`
6 changes: 5 additions & 1 deletion examples/bookstore.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// NOTE: since we are missing some proto annotations that
// must be added, the proto representation is outdated. See bookstore.yaml
syntax = "proto3";
package tutorial;
option go_package = "proto";

service Bookstore {}
// bookstore.examples.com
service Bookstore {
}

message Book {

Expand Down
7 changes: 5 additions & 2 deletions examples/bookstore.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
name: Bookstore
name: bookstore.example.com
resources:
- kind: Book
- kind: Book
parents:
- "bookstore.example.com/Publisher"
- kind: Publisher
22 changes: 22 additions & 0 deletions examples/bookstore.yaml.output.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ message ReadBookRequest {
string path = 1;
}

message Publisher {
string path = 1;
}

message CreatePublisherRequest {
string id = 1;

Publisher resource = 2;
}

message ReadPublisherRequest {
string path = 1;
}

service Bookstore {
rpc CreateBook ( CreateBookRequest ) returns ( Book ) {
option (google.api.http) = { post: "/book" };
Expand All @@ -26,4 +40,12 @@ service Bookstore {
rpc ReadBook ( ReadBookRequest ) returns ( Book ) {
option (google.api.http) = { get: "/{path=book/*}" };
}

rpc CreatePublisher ( CreatePublisherRequest ) returns ( Publisher ) {
option (google.api.http) = { post: "/publisher" };
}

rpc ReadPublisher ( ReadPublisherRequest ) returns ( Publisher ) {
option (google.api.http) = { get: "/{path=publisher/*}" };
}
}
143 changes: 82 additions & 61 deletions schema/resourcedefinition.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions schema/resourcedefinition.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ message Service {
}

message Resource {
// Kind is the type of the resource
// The type of the resource. Used to programmatically
// refer to and identify the resource.
string kind = 1;
repeated string parents = 2;
map<string, Property> properties = 3;
// The plural of the resource. Used in documentation.
string plural = 2;
// The list of parent resources, referred to via the kind.
repeated string parents = 3;
map<string, Property> properties = 4;
// TODO: add method support
// repeated Method methods = 3;
}
Expand Down
Loading

0 comments on commit d9cd1c4

Please sign in to comment.