|
| 1 | +// Copyright 2016 Google Inc. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +// |
| 15 | +//////////////////////////////////////////////////////////////////////////////// |
| 16 | + |
| 17 | +syntax = "proto3"; |
| 18 | + |
| 19 | +package endpoints.examples.bookstore; |
| 20 | + |
| 21 | +option java_multiple_files = true; |
| 22 | +option java_outer_classname = "BookstoreProto"; |
| 23 | +option java_package = "com.google.endpoints.examples.bookstore"; |
| 24 | + |
| 25 | + |
| 26 | +import "google/protobuf/empty.proto"; |
| 27 | + |
| 28 | +// A simple Bookstore API. |
| 29 | +// |
| 30 | +// The API manages shelves and books resources. Shelves contain books. |
| 31 | +service Bookstore { |
| 32 | + // Returns a list of all shelves in the bookstore. |
| 33 | + rpc ListShelves(google.protobuf.Empty) returns (ListShelvesResponse) {} |
| 34 | + // Creates a new shelf in the bookstore. |
| 35 | + rpc CreateShelf(CreateShelfRequest) returns (Shelf) {} |
| 36 | + // Returns a specific bookstore shelf. |
| 37 | + rpc GetShelf(GetShelfRequest) returns (Shelf) {} |
| 38 | + // Deletes a shelf, including all books that are stored on the shelf. |
| 39 | + rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) {} |
| 40 | + // Returns a list of books on a shelf. |
| 41 | + rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {} |
| 42 | + // Creates a new book. |
| 43 | + rpc CreateBook(CreateBookRequest) returns (Book) {} |
| 44 | + // Returns a specific book. |
| 45 | + rpc GetBook(GetBookRequest) returns (Book) {} |
| 46 | + // Deletes a book from a shelf. |
| 47 | + rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty) {} |
| 48 | +} |
| 49 | + |
| 50 | +// A shelf resource. |
| 51 | +message Shelf { |
| 52 | + // A unique shelf id. |
| 53 | + int64 id = 1; |
| 54 | + // A theme of the shelf (fiction, poetry, etc). |
| 55 | + string theme = 2; |
| 56 | +} |
| 57 | + |
| 58 | +// A book resource. |
| 59 | +message Book { |
| 60 | + // A unique book id. |
| 61 | + int64 id = 1; |
| 62 | + // An author of the book. |
| 63 | + string author = 2; |
| 64 | + // A book title. |
| 65 | + string title = 3; |
| 66 | +} |
| 67 | + |
| 68 | +// Response to ListShelves call. |
| 69 | +message ListShelvesResponse { |
| 70 | + // Shelves in the bookstore. |
| 71 | + repeated Shelf shelves = 1; |
| 72 | +} |
| 73 | + |
| 74 | +// Request message for CreateShelf method. |
| 75 | +message CreateShelfRequest { |
| 76 | + // The shelf resource to create. |
| 77 | + Shelf shelf = 1; |
| 78 | +} |
| 79 | + |
| 80 | +// Request message for GetShelf method. |
| 81 | +message GetShelfRequest { |
| 82 | + // The ID of the shelf resource to retrieve. |
| 83 | + int64 shelf = 1; |
| 84 | +} |
| 85 | + |
| 86 | +// Request message for DeleteShelf method. |
| 87 | +message DeleteShelfRequest { |
| 88 | + // The ID of the shelf to delete. |
| 89 | + int64 shelf = 1; |
| 90 | +} |
| 91 | + |
| 92 | +// Request message for ListBooks method. |
| 93 | +message ListBooksRequest { |
| 94 | + // ID of the shelf which books to list. |
| 95 | + int64 shelf = 1; |
| 96 | +} |
| 97 | + |
| 98 | +// Response message to ListBooks method. |
| 99 | +message ListBooksResponse { |
| 100 | + // The books on the shelf. |
| 101 | + repeated Book books = 1; |
| 102 | +} |
| 103 | + |
| 104 | +// Request message for CreateBook method. |
| 105 | +message CreateBookRequest { |
| 106 | + // The ID of the shelf on which to create a book. |
| 107 | + int64 shelf = 1; |
| 108 | + // A book resource to create on the shelf. |
| 109 | + Book book = 2; |
| 110 | +} |
| 111 | + |
| 112 | +// Request message for GetBook method. |
| 113 | +message GetBookRequest { |
| 114 | + // The ID of the shelf from which to retrieve a book. |
| 115 | + int64 shelf = 1; |
| 116 | + // The ID of the book to retrieve. |
| 117 | + int64 book = 2; |
| 118 | +} |
| 119 | + |
| 120 | +// Request message for DeleteBook method. |
| 121 | +message DeleteBookRequest { |
| 122 | + // The ID of the shelf from which to delete a book. |
| 123 | + int64 shelf = 1; |
| 124 | + // The ID of the book to delete. |
| 125 | + int64 book = 2; |
| 126 | +} |
0 commit comments