Zsolt Haraszti | bae1275 | 2016-10-10 09:55:30 -0700 | [diff] [blame] | 1 | syntax = "proto3"; |
| 2 | package examples.example; |
| 3 | |
| 4 | import "google/api/annotations.proto"; |
| 5 | import "google/protobuf/empty.proto"; |
| 6 | import "sub.proto"; |
| 7 | import "sub2.proto"; |
| 8 | import "google/protobuf/timestamp.proto"; |
| 9 | |
| 10 | // Intentionaly complicated message type to cover much features of Protobuf. |
| 11 | // NEXT ID: 27 |
| 12 | message ABitOfEverything { |
| 13 | // Nested is nested type. |
| 14 | message Nested { |
| 15 | // name is nested field. |
| 16 | string name = 1; |
| 17 | uint32 amount = 2; |
| 18 | // DeepEnum is one or zero. |
| 19 | enum DeepEnum { |
| 20 | // FALSE is false. |
| 21 | FALSE = 0; |
| 22 | // TRUE is true. |
| 23 | TRUE = 1; |
| 24 | } |
| 25 | DeepEnum ok = 3; |
| 26 | } |
| 27 | Nested single_nested = 25; |
| 28 | |
| 29 | string uuid = 1; |
| 30 | repeated Nested nested = 2; |
| 31 | float float_value = 3; |
| 32 | double double_value = 4; |
| 33 | int64 int64_value = 5; |
| 34 | uint64 uint64_value = 6; |
| 35 | int32 int32_value = 7; |
| 36 | fixed64 fixed64_value = 8; |
| 37 | fixed32 fixed32_value = 9; |
| 38 | bool bool_value = 10; |
| 39 | string string_value = 11; |
| 40 | // TODO(yugui) add bytes_value |
| 41 | uint32 uint32_value = 13; |
| 42 | NumericEnum enum_value = 14; |
| 43 | sfixed32 sfixed32_value = 15; |
| 44 | sfixed64 sfixed64_value = 16; |
| 45 | sint32 sint32_value = 17; |
| 46 | sint64 sint64_value = 18; |
| 47 | repeated string repeated_string_value = 19; |
| 48 | oneof oneof_value { |
| 49 | google.protobuf.Empty oneof_empty = 20; |
| 50 | string oneof_string = 21; |
| 51 | } |
| 52 | |
| 53 | map<string, NumericEnum> map_value = 22; |
| 54 | map<string, string> mapped_string_value = 23; |
| 55 | map<string, Nested> mapped_nested_value = 24; |
| 56 | |
| 57 | string nonConventionalNameValue = 26; |
| 58 | |
| 59 | google.protobuf.Timestamp timestamp_value = 27; |
| 60 | } |
| 61 | |
| 62 | // NumericEnum is one or zero. |
| 63 | enum NumericEnum { |
| 64 | // ZERO means 0 |
| 65 | ZERO = 0; |
| 66 | // ONE means 1 |
| 67 | ONE = 1; |
| 68 | } |
| 69 | |
| 70 | service ABitOfEverythingService { |
| 71 | rpc Create(ABitOfEverything) returns (ABitOfEverything) { |
| 72 | // TODO add enum_value |
| 73 | option (google.api.http) = { |
| 74 | post: "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}" |
| 75 | }; |
| 76 | } |
| 77 | rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { |
| 78 | option (google.api.http) = { |
| 79 | post: "/v1/example/a_bit_of_everything" |
| 80 | body: "*" |
| 81 | }; |
| 82 | } |
| 83 | rpc Lookup(sub2.IdMessage) returns (ABitOfEverything) { |
| 84 | option (google.api.http) = { |
| 85 | get: "/v1/example/a_bit_of_everything/{uuid}" |
| 86 | }; |
| 87 | } |
| 88 | rpc Update(ABitOfEverything) returns (google.protobuf.Empty) { |
| 89 | option (google.api.http) = { |
| 90 | put: "/v1/example/a_bit_of_everything/{uuid}" |
| 91 | body: "*" |
| 92 | }; |
| 93 | } |
| 94 | rpc Delete(sub2.IdMessage) returns (google.protobuf.Empty) { |
| 95 | option (google.api.http) = { |
| 96 | delete: "/v1/example/a_bit_of_everything/{uuid}" |
| 97 | }; |
| 98 | } |
| 99 | rpc Echo(examples.sub.StringMessage) returns (examples.sub.StringMessage) { |
| 100 | option (google.api.http) = { |
| 101 | get: "/v1/example/a_bit_of_everything/echo/{value}" |
| 102 | additional_bindings { |
| 103 | post: "/v2/example/echo" |
| 104 | body: "value" |
| 105 | } |
| 106 | additional_bindings { |
| 107 | get: "/v2/example/echo" |
| 108 | } |
| 109 | }; |
| 110 | } |
| 111 | rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { |
| 112 | option (google.api.http) = { |
| 113 | post: "/v1/example/a_bit_of_everything/{single_nested.name}" |
| 114 | body: "*" |
| 115 | }; |
| 116 | } |
| 117 | rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) { |
| 118 | option (google.api.http) = { |
| 119 | get: "/v2/example/timeout", |
| 120 | }; |
| 121 | } |
| 122 | } |