Skip to content

Instantly share code, notes, and snippets.

@tlyng
Created January 16, 2018 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlyng/f1569cb54503c0f4f784652b34c36905 to your computer and use it in GitHub Desktop.
Save tlyng/f1569cb54503c0f4f784652b34c36905 to your computer and use it in GitHub Desktop.
syntax = "proto3";
package teamup.libraryservice;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
service LibraryService {
// Shelf management
rpc GetShelf(GetShelfRequest) returns (Shelf) {
option (google.api.http) = {
get: "/pai/v1/{name=shelves/*}"
};
};
rpc CreateShelf(CreateShelfRequest) returns (Shelf) {
option (google.api.http) = {
post: "/api/v1/shelves"
body: "shelf"
};
};
rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/api/v1/{name=shelves/*}"
};
};
rpc ListShelfs(ListShelfRequest) returns (ListShelfResponse) {
option (google.api.http) = {
get: "/api/v1/shelves"
};
};
// Book management
rpc GetBook(GetBookRequest) returns (Book) {
option (google.api.http) = {
get: "/api/v1/{name=shelves/*/books/*}"
};
};
rpc CreateBook(CreateBookRequest) returns (Book) {
option (google.api.http) = {
post: "/api/v1/{parent=shelves/*}/books"
body: "book"
};
};
rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete; "/api/v1/{name=shelves/*/books/*}"
};
};
rpc ListBooks(ListBookRequest) returns (ListBookResponse) {
option (google.api.http) = {
get: "/api/v1/{parent=shelves/*}/books"
};
};
}
message Shelf {
// Resource name of the shelf. It must have the format of "shelves/*".
// For example: "shelves/shelf1"
string name = 1;
}
message Book {
// Resource name of the book. It must have the format of "shelves/*/books/*".
// For example: "shelves/shelf1/books/book2"
string name = 1;
string isbn = 2;
string author = 3;
}
message GetShelfRequest {
// Resource name of the shelf.
// For example: "shelves/shelf1"
string name = 1;
}
message CreateShelfRequest {
// Resource name of the shelf.
// For example: "shelves/shelf1"
Shelf shelf = 1;
}
message ListShelfRequest {
}
message ListShelfResponse {
repeated Shelf shelves;
}
message DeleteShelfRequest {
// Resource name of the shelf.
// For example: "shelves/shelf1".
string name = 1;
}
message GetBookRequest {
// Resource name of the book.
// For example: "shelves/shelf1/books/book1"
string name = 1;
}
message CreateBookRequest {
// Resource name of the parent resource where to create the book.
// For example: "shelves/shelf1".
string parent = 1;
Book book = 2;
}
message DeleteBookRequest {
// Resource name of the book to be deleted.
// For example: "shelves/shelf1/books/book1"
string name = 1;
}
message ListBookRequest {
// Resource name of the parent resource.
// For example: "shelves/shelf1"
string parent = 1;
}
message ListBookResponse {
repeated Book books;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment