aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/googleapis/google/example/library/v1/library.proto
blob: c31f77201e2d34c8d9fa9f52af30a658fa3c41a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.example.library.v1;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

option go_package = "google.golang.org/genproto/googleapis/example/library/v1;library";
option java_multiple_files = true;
option java_outer_classname = "LibraryProto";
option java_package = "com.google.example.library.v1";


// This API represents a simple digital library.  It lets you manage Shelf
// resources and Book resources in the library. It defines the following
// resource model:
//
// - The API has a collection of [Shelf][google.example.library.v1.Shelf]
//   resources, named `shelves/*`
//
// - Each Shelf has a collection of [Book][google.example.library.v1.Book]
//   resources, named `shelves/*/books/*`
service LibraryService {
  // Creates a shelf, and returns the new Shelf.
  rpc CreateShelf(CreateShelfRequest) returns (Shelf) {
    option (google.api.http) = { post: "/v1/shelves" body: "shelf" };
  }

  // Gets a shelf. Returns NOT_FOUND if the shelf does not exist.
  rpc GetShelf(GetShelfRequest) returns (Shelf) {
    option (google.api.http) = { get: "/v1/{name=shelves/*}" };
  }

  // Lists shelves. The order is unspecified but deterministic. Newly created
  // shelves will not necessarily be added to the end of this list.
  rpc ListShelves(ListShelvesRequest) returns (ListShelvesResponse) {
    option (google.api.http) = { get: "/v1/shelves" };
  }

  // Deletes a shelf. Returns NOT_FOUND if the shelf does not exist.
  rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = { delete: "/v1/{name=shelves/*}" };
  }

  // Merges two shelves by adding all books from the shelf named
  // `other_shelf_name` to shelf `name`, and deletes
  // `other_shelf_name`. Returns the updated shelf.
  // The book ids of the moved books may not be the same as the original books.
  //
  // Returns NOT_FOUND if either shelf does not exist.
  // This call is a no-op if the specified shelves are the same.
  rpc MergeShelves(MergeShelvesRequest) returns (Shelf) {
    option (google.api.http) = { post: "/v1/{name=shelves/*}:merge" body: "*" };
  }

  // Creates a book, and returns the new Book.
  rpc CreateBook(CreateBookRequest) returns (Book) {
    option (google.api.http) = { post: "/v1/{name=shelves/*}/books" body: "book" };
  }

  // Gets a book. Returns NOT_FOUND if the book does not exist.
  rpc GetBook(GetBookRequest) returns (Book) {
    option (google.api.http) = { get: "/v1/{name=shelves/*/books/*}" };
  }

  // Lists books in a shelf. The order is unspecified but deterministic. Newly
  // created books will not necessarily be added to the end of this list.
  // Returns NOT_FOUND if the shelf does not exist.
  rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {
    option (google.api.http) = { get: "/v1/{name=shelves/*}/books" };
  }

  // Deletes a book. Returns NOT_FOUND if the book does not exist.
  rpc DeleteBook(DeleteBookRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = { delete: "/v1/{name=shelves/*/books/*}" };
  }

  // Updates a book. Returns INVALID_ARGUMENT if the name of the book
  // is non-empty and does equal the previous name.
  rpc UpdateBook(UpdateBookRequest) returns (Book) {
    option (google.api.http) = { put: "/v1/{name=shelves/*/books/*}" body: "book" };
  }

  // Moves a book to another shelf, and returns the new book. The book
  // id of the new book may not be the same as the original book.
  rpc MoveBook(MoveBookRequest) returns (Book) {
    option (google.api.http) = { post: "/v1/{name=shelves/*/books/*}:move" body: "*" };
  }
}

// A single book in the library.
message Book {
  // The resource name of the book.
  // Book names have the form `shelves/{shelf_id}/books/{book_id}`.
  // The name is ignored when creating a book.
  string name = 1;

  // The name of the book author.
  string author = 2;

  // The title of the book.
  string title = 3;

  // Value indicating whether the book has been read.
  bool read = 4;
}

// A Shelf contains a collection of books with a theme.
message Shelf {
  // The resource name of the shelf.
  // Shelf names have the form `shelves/{shelf_id}`.
  // The name is ignored when creating a shelf.
  string name = 1;

  // The theme of the shelf
  string theme = 2;
}

// Request message for LibraryService.CreateShelf.
message CreateShelfRequest {
  // The shelf to create.
  Shelf shelf = 1;
}

// Request message for LibraryService.GetShelf.
message GetShelfRequest {
  // The name of the shelf to retrieve.
  string name = 1;
}

// Request message for LibraryService.ListShelves.
message ListShelvesRequest {
  // Requested page size. Server may return fewer shelves than requested.
  // If unspecified, server will pick an appropriate default.
  int32 page_size = 1;

  // A token identifying a page of results the server should return.
  // Typically, this is the value of
  // [ListShelvesResponse.next_page_token][google.example.library.v1.ListShelvesResponse.next_page_token]
  // returned from the previous call to `ListShelves` method.
  string page_token = 2;
}

// Response message for LibraryService.ListShelves.
message ListShelvesResponse {
  // The list of shelves.
  repeated Shelf shelves = 1;

  // A token to retrieve next page of results.
  // Pass this value in the
  // [ListShelvesRequest.page_token][google.example.library.v1.ListShelvesRequest.page_token]
  // field in the subsequent call to `ListShelves` method to retrieve the next
  // page of results.
  string next_page_token = 2;
}

// Request message for LibraryService.DeleteShelf.
message DeleteShelfRequest {
  // The name of the shelf to delete.
  string name = 1;
}

// Describes the shelf being removed (other_shelf_name) and updated
// (name) in this merge.
message MergeShelvesRequest {
  // The name of the shelf we're adding books to.
  string name = 1;

  // The name of the shelf we're removing books from and deleting.
  string other_shelf_name = 2;
}

// Request message for LibraryService.CreateBook.
message CreateBookRequest {
  // The name of the shelf in which the book is created.
  string name = 1;

  // The book to create.
  Book book = 2;
}

// Request message for LibraryService.GetBook.
message GetBookRequest {
  // The name of the book to retrieve.
  string name = 1;
}

// Request message for LibraryService.ListBooks.
message ListBooksRequest {
  // The name of the shelf whose books we'd like to list.
  string name = 1;

  // Requested page size. Server may return fewer books than requested.
  // If unspecified, server will pick an appropriate default.
  int32 page_size = 2;

  // A token identifying a page of results the server should return.
  // Typically, this is the value of
  // [ListBooksResponse.next_page_token][google.example.library.v1.ListBooksResponse.next_page_token].
  // returned from the previous call to `ListBooks` method.
  string page_token = 3;
}

// Response message for LibraryService.ListBooks.
message ListBooksResponse {
  // The list of books.
  repeated Book books = 1;

  // A token to retrieve next page of results.
  // Pass this value in the
  // [ListBooksRequest.page_token][google.example.library.v1.ListBooksRequest.page_token]
  // field in the subsequent call to `ListBooks` method to retrieve the next
  // page of results.
  string next_page_token = 2;
}

// Request message for LibraryService.UpdateBook.
message UpdateBookRequest {
  // The name of the book to update.
  string name = 1;

  // The book to update with. The name must match or be empty.
  Book book = 2;
}

// Request message for LibraryService.DeleteBook.
message DeleteBookRequest {
  // The name of the book to delete.
  string name = 1;
}

// Describes what book to move (name) and what shelf we're moving it
// to (other_shelf_name).
message MoveBookRequest {
  // The name of the book to move.
  string name = 1;

  // The name of the destination shelf.
  string other_shelf_name = 2;
}