|
| 1 | +// Copyright 2021 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 | +// 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 | +syntax = "proto3"; |
| 16 | + |
| 17 | +package google.example.showcase.v1; |
| 18 | + |
| 19 | +import "google/api/annotations.proto"; |
| 20 | +import "google/api/client.proto"; |
| 21 | +import "google/api/field_behavior.proto"; |
| 22 | +import "google/longrunning/operations.proto"; |
| 23 | +import "google/protobuf/duration.proto"; |
| 24 | +import "google/protobuf/timestamp.proto"; |
| 25 | +import "google/rpc/status.proto"; |
| 26 | + |
| 27 | +option go_package = "github.com/googleapis/gapic-showcase/server/genproto"; |
| 28 | +option java_multiple_files = true; |
| 29 | +option java_outer_classname = "EchoProto"; |
| 30 | +option java_package = "com.google.example.showcase.v1"; |
| 31 | +option ruby_package = "Google::Example::Showcase::V1"; |
| 32 | + |
| 33 | +// This service is used showcase the four main types of rpcs - unary, server |
| 34 | +// side streaming, client side streaming, and bidirectional streaming. This |
| 35 | +// service also exposes methods that explicitly implement server delay, and |
| 36 | +// paginated calls. Set the 'showcase-trailer' metadata key on any method |
| 37 | +// to have the values echoed in the response trailers. |
| 38 | +service Echo { |
| 39 | + option (google.api.default_host) = "showcase.googleapis.com"; |
| 40 | + |
| 41 | + // This method simply echoes the request. This method showcases unary RPCs. |
| 42 | + rpc Echo(EchoRequest) returns (EchoResponse) { |
| 43 | + option (google.api.http) = { |
| 44 | + post: "/v1/echo:echo" |
| 45 | + body: "*" |
| 46 | + }; |
| 47 | + } |
| 48 | + |
| 49 | + // This method splits the given content into words and will pass each word |
| 50 | + // back through the stream. This method showcases server-side streaming RPCs. |
| 51 | + rpc Expand(ExpandRequest) returns (stream EchoResponse) { |
| 52 | + option (google.api.http) = { |
| 53 | + post: "/v1/echo:expand" |
| 54 | + body: "*" |
| 55 | + }; |
| 56 | + option (google.api.method_signature) = "content,error"; |
| 57 | + } |
| 58 | + |
| 59 | + // This method will collect the words given to it. When the stream is closed |
| 60 | + // by the client, this method will return the a concatenation of the strings |
| 61 | + // passed to it. This method showcases client-side streaming RPCs. |
| 62 | + rpc Collect(stream EchoRequest) returns (EchoResponse) { |
| 63 | + option (google.api.http) = { |
| 64 | + post: "/v1/echo:collect" |
| 65 | + body: "*" |
| 66 | + }; |
| 67 | + } |
| 68 | + |
| 69 | + // This method, upon receiving a request on the stream, will pass the same |
| 70 | + // content back on the stream. This method showcases bidirectional |
| 71 | + // streaming RPCs. |
| 72 | + rpc Chat(stream EchoRequest) returns (stream EchoResponse) { |
| 73 | + } |
| 74 | + |
| 75 | + // This is similar to the Expand method but instead of returning a stream of |
| 76 | + // expanded words, this method returns a paged list of expanded words. |
| 77 | + rpc PagedExpand(PagedExpandRequest) returns (PagedExpandResponse) { |
| 78 | + option (google.api.http) = { |
| 79 | + post: "/v1/echo:pagedExpand" |
| 80 | + body: "*" |
| 81 | + }; |
| 82 | + } |
| 83 | + |
| 84 | + // This method will wait for the requested amount of time and then return. |
| 85 | + // This method showcases how a client handles a request timeout. |
| 86 | + rpc Wait(WaitRequest) returns (google.longrunning.Operation) { |
| 87 | + option (google.api.http) = { |
| 88 | + post: "/v1/echo:wait" |
| 89 | + body: "*" |
| 90 | + }; |
| 91 | + option (google.longrunning.operation_info) = { |
| 92 | + response_type: "WaitResponse" |
| 93 | + metadata_type: "WaitMetadata" |
| 94 | + }; |
| 95 | + } |
| 96 | + |
| 97 | + // This method will block (wait) for the requested amount of time |
| 98 | + // and then return the response or error. |
| 99 | + // This method showcases how a client handles delays or retries. |
| 100 | + rpc Block(BlockRequest) returns (BlockResponse) { |
| 101 | + option (google.api.http) = { |
| 102 | + post: "/v1/echo:block" |
| 103 | + body: "*" |
| 104 | + }; |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +// The request message used for the Echo, Collect and Chat methods. |
| 109 | +// If content or opt are set in this message then the request will succeed. |
| 110 | +// If status is set in this message then the status will be returned as an |
| 111 | +// error. |
| 112 | +message EchoRequest { |
| 113 | + // The response contents. |
| 114 | + oneof response { |
| 115 | + // The content to be echoed by the server. |
| 116 | + string content = 1; |
| 117 | + |
| 118 | + // The error to be thrown by the server. |
| 119 | + google.rpc.Status error = 2; |
| 120 | + } |
| 121 | + |
| 122 | + // The severity to be echoed by the server. |
| 123 | + Severity severity = 3; |
| 124 | +} |
| 125 | + |
| 126 | +// A severity enum used to test enum capabilities in GAPIC surfaces. |
| 127 | +enum Severity { |
| 128 | + // The severity is unnecessary. |
| 129 | + UNNECESSARY = 0; |
| 130 | + |
| 131 | + // The severity is necessary. |
| 132 | + NECESSARY = 1; |
| 133 | + |
| 134 | + // Urgent. |
| 135 | + URGENT = 2; |
| 136 | + |
| 137 | + // Critical. |
| 138 | + CRITICAL = 3; |
| 139 | +} |
| 140 | + |
| 141 | +// The response message for the Echo methods. |
| 142 | +message EchoResponse { |
| 143 | + // The content specified in the request. |
| 144 | + string content = 1; |
| 145 | + |
| 146 | + // The severity specified in the request. |
| 147 | + Severity severity = 2; |
| 148 | +} |
| 149 | + |
| 150 | +// The request message for the Expand method. |
| 151 | +message ExpandRequest { |
| 152 | + // The content that will be split into words and returned on the stream. |
| 153 | + string content = 1; |
| 154 | + |
| 155 | + // The error that is thrown after all words are sent on the stream. |
| 156 | + google.rpc.Status error = 2; |
| 157 | +} |
| 158 | + |
| 159 | +// The request for the PagedExpand method. |
| 160 | +message PagedExpandRequest { |
| 161 | + // Required. The string to expand. |
| 162 | + string content = 1 [(google.api.field_behavior) = REQUIRED]; |
| 163 | + |
| 164 | + // The amount of words to returned in each page. |
| 165 | + int32 page_size = 2; |
| 166 | + |
| 167 | + // The position of the page to be returned. |
| 168 | + string page_token = 3; |
| 169 | +} |
| 170 | + |
| 171 | +// The response for the PagedExpand method. |
| 172 | +message PagedExpandResponse { |
| 173 | + // The words that were expanded. |
| 174 | + repeated EchoResponse responses = 1; |
| 175 | + |
| 176 | + // The next page token. |
| 177 | + string next_page_token = 2; |
| 178 | +} |
| 179 | + |
| 180 | +// The request for Wait method. |
| 181 | +message WaitRequest { |
| 182 | + // The ending time or duration. |
| 183 | + oneof end { |
| 184 | + // The time that this operation will complete. |
| 185 | + google.protobuf.Timestamp end_time = 1; |
| 186 | + |
| 187 | + // The duration of this operation. |
| 188 | + google.protobuf.Duration ttl = 4; |
| 189 | + } |
| 190 | + |
| 191 | + // The response. |
| 192 | + oneof response { |
| 193 | + // The error that will be returned by the server. If this code is specified |
| 194 | + // to be the OK rpc code, an empty response will be returned. |
| 195 | + google.rpc.Status error = 2; |
| 196 | + |
| 197 | + // The response to be returned on operation completion. |
| 198 | + WaitResponse success = 3; |
| 199 | + } |
| 200 | +} |
| 201 | + |
| 202 | +// The result of the Wait operation. |
| 203 | +message WaitResponse { |
| 204 | + // This content of the result. |
| 205 | + string content = 1; |
| 206 | +} |
| 207 | + |
| 208 | +// The request for Block method. |
| 209 | +message BlockRequest { |
| 210 | + // The response. |
| 211 | + oneof response { |
| 212 | + // The error that will be returned by the server. If this code is specified |
| 213 | + // to be the OK rpc code, an empty response will be returned. |
| 214 | + google.rpc.Status error = 2; |
| 215 | + |
| 216 | + // The response to be returned that will signify successful method call. |
| 217 | + BlockResponse success = 3; |
| 218 | + } |
| 219 | + |
| 220 | + // The amount of time to block before returning a response. |
| 221 | + google.protobuf.Duration response_delay = 1; |
| 222 | +} |
| 223 | + |
| 224 | +// The response for Block method. |
| 225 | +message BlockResponse { |
| 226 | + // This content can contain anything, the server will not depend on a value |
| 227 | + // here. |
| 228 | + string content = 1; |
| 229 | +} |
0 commit comments