|
| 1 | +// Copyright 2020 Google LLC |
| 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 | +// https://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 | +syntax = "proto3"; |
| 16 | + |
| 17 | +import "google/api/annotations.proto"; |
| 18 | +import "google/api/client.proto"; |
| 19 | +import "google/api/field_behavior.proto"; |
| 20 | +import "google/api/resource.proto"; |
| 21 | + |
| 22 | +service Library { |
| 23 | + // Create a single book. |
| 24 | + rpc CreateBook(CreateBookRequest) returns (Book) { |
| 25 | + option (google.api.http) = { |
| 26 | + post: "/v1/{parent=publishers/*}/books" |
| 27 | + body: "book" |
| 28 | + }; |
| 29 | + option (google.api.method_signature) = "parent,book"; |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | + |
| 34 | +// The request message for creating a book. |
| 35 | +message CreateBookRequest { |
| 36 | + // The parent collection where this book will be created. |
| 37 | + // Format: publishers/{publisher} |
| 38 | + string parent = 1 [ |
| 39 | + (google.api.field_behavior) = REQUIRED, |
| 40 | + (google.api.resource_reference) = { |
| 41 | + child_type: "library.googleapis.com/Book" |
| 42 | + }]; |
| 43 | + |
| 44 | + // The book to create. |
| 45 | + Book book = 2 [(google.api.field_behavior) = REQUIRED]; |
| 46 | + |
| 47 | + // If set, validate the request and preview the review, but do not actually |
| 48 | + // post it. |
| 49 | + bool validate_only = 3; |
| 50 | +} |
| 51 | + |
| 52 | +// A representation of a single book. |
| 53 | +message Book { |
| 54 | + option (google.api.resource) = { |
| 55 | + type: "library.googleapis.com/Book" |
| 56 | + pattern: "publishers/{publisher}/books/{book}" |
| 57 | + }; |
| 58 | + |
| 59 | + // The name of the book. |
| 60 | + // Format: publishers/{publisher}/books/{book} |
| 61 | + string name = 1; |
| 62 | + |
| 63 | + // The ISBN (International Standard Book Number) for this book. |
| 64 | + string isbn = 2; |
| 65 | + |
| 66 | + // The title of the book. |
| 67 | + string title = 3; |
| 68 | + |
| 69 | + // The author or authors of the book. |
| 70 | + repeated string authors = 4; |
| 71 | + |
| 72 | + // The rating assigned to the book. |
| 73 | + float rating = 5; |
| 74 | +} |
0 commit comments