1// Copyright 2018 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 15syntax = "proto3"; 16 17import "google/api/annotations.proto"; 18import "google/api/client.proto"; 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/longrunning/operations.proto"; 22import "google/protobuf/duration.proto"; 23import "google/protobuf/timestamp.proto"; 24import "google/rpc/status.proto"; 25 26package google.showcase.v1beta1; 27 28option go_package = "github.com/googleapis/gapic-showcase/server/genproto"; 29option java_package = "com.google.showcase.v1beta1"; 30option java_multiple_files = true; 31 32option (google.api.resource_definition) = { 33 type: "showcase.googleapis.com/AnythingGoes" 34 pattern: "*" 35}; 36 37// This service is used showcase the four main types of rpcs - unary, server 38// side streaming, client side streaming, and bidirectional streaming. This 39// service also exposes methods that explicitly implement server delay, and 40// paginated calls. Set the 'showcase-trailer' metadata key on any method 41// to have the values echoed in the response trailers. 42service Echo { 43 // This service is meant to only run locally on the port 7469 (keypad digits 44 // for "show"). 45 option (google.api.default_host) = "localhost:7469"; 46 option (google.api.oauth_scopes) = 47 "https://www.googleapis.com/auth/cloud-platform"; 48 49 // This method simply echos the request. This method is showcases unary rpcs. 50 rpc Echo(EchoRequest) returns (EchoResponse) { 51 option (google.api.http) = { 52 post: "/v1beta1/echo:echo" 53 body: "*" 54 }; 55 option (google.api.method_signature) = "content"; 56 option (google.api.method_signature) = "error"; 57 option (google.api.method_signature) = "content,severity"; 58 option (google.api.method_signature) = "name"; 59 option (google.api.method_signature) = "parent"; 60 option (google.api.method_signature) = ""; 61 } 62 63 // This method split the given content into words and will pass each word back 64 // through the stream. This method showcases server-side streaming rpcs. 65 rpc Expand(ExpandRequest) returns (stream EchoResponse) { 66 option (google.api.http) = { 67 post: "/v1beta1/echo:expand" 68 body: "*" 69 }; 70 option (google.api.method_signature) = "content,error"; 71 } 72 73 // This method will collect the words given to it. When the stream is closed 74 // by the client, this method will return the a concatenation of the strings 75 // passed to it. This method showcases client-side streaming rpcs. 76 rpc Collect(stream EchoRequest) returns (EchoResponse) { 77 option (google.api.http) = { 78 post: "/v1beta1/echo:collect" 79 body: "*" 80 }; 81 } 82 83 // This method, upon receiving a request on the stream, the same content will 84 // be passed back on the stream. This method showcases bidirectional 85 // streaming rpcs. 86 rpc Chat(stream EchoRequest) returns (stream EchoResponse); 87 88 rpc ChatAgain(stream EchoRequest) returns (stream EchoResponse) { 89 option (google.api.method_signature) = "content"; 90 } 91 92 // This is similar to the Expand method but instead of returning a stream of 93 // expanded words, this method returns a paged list of expanded words. 94 rpc PagedExpand(PagedExpandRequest) returns (PagedExpandResponse) { 95 option (google.api.http) = { 96 post: "/v1beta1/echo:pagedExpand" 97 body: "*" 98 }; 99 } 100 101 rpc SimplePagedExpand(PagedExpandRequest) returns (PagedExpandResponse) { 102 option (google.api.http) = { 103 post: "/v1beta1/echo:pagedExpand" 104 body: "*" 105 }; 106 option (google.api.method_signature) = ""; 107 } 108 109 // This method will wait the requested amount of and then return. 110 // This method showcases how a client handles a request timing out. 111 rpc Wait(WaitRequest) returns (google.longrunning.Operation) { 112 option (google.api.http) = { 113 post: "/v1beta1/echo:wait" 114 body: "*" 115 }; 116 option (google.longrunning.operation_info) = { 117 response_type: "WaitResponse" 118 metadata_type: "WaitMetadata" 119 }; 120 option (google.api.method_signature) = "end_time"; 121 option (google.api.method_signature) = "ttl"; 122 } 123 124 // This method will block (wait) for the requested amount of time 125 // and then return the response or error. 126 // This method showcases how a client handles delays or retries. 127 rpc Block(BlockRequest) returns (BlockResponse) { 128 option (google.api.http) = { 129 post: "/v1beta1/echo:block" 130 body: "*" 131 }; 132 }; 133 134 // This method primarily tests Java name collisions by using the Object 135 // message. 136 rpc CollideName(EchoRequest) returns (Object) { 137 option (google.api.http) = { 138 post: "/v1beta1/echo:foo" 139 body: "*" 140 }; 141 } 142} 143 144// A severity enum used to test enum capabilities in GAPIC surfaces 145enum Severity { 146 UNNECESSARY = 0; 147 NECESSARY = 1; 148 URGENT = 2; 149 CRITICAL = 3; 150} 151 152message Foobar { 153 option (google.api.resource) = { 154 type: "showcase.googleapis.com/Foobar" 155 pattern: "projects/{project}/foobars/{foobar}" 156 pattern: "projects/{project}/chocolate/variants/{variant}/foobars/{foobar}" 157 pattern: "foobars/{foobar}" 158 pattern: "bar_foos/{bar_foo}/foobars/{foobar}" 159 pattern: "*" 160 }; 161 162 string name = 1; 163 string info = 2; 164} 165 166// The request message used for the Echo, Collect and Chat methods. 167// If content or opt are set in this message then the request will succeed. 168// If status is set in this message 169// then the status will be returned as an error. 170message EchoRequest { 171 string name = 5 [ 172 (google.api.resource_reference).type = "showcase.googleapis.com/Foobar", 173 (google.api.field_behavior) = REQUIRED 174 ]; 175 176 string parent = 6 [ 177 (google.api.resource_reference).child_type = 178 "showcase.googleapis.com/AnythingGoes", 179 (google.api.field_behavior) = REQUIRED 180 ]; 181 182 oneof response { 183 // The content to be echoed by the server. 184 string content = 1; 185 186 // The error to be thrown by the server. 187 google.rpc.Status error = 2; 188 } 189 190 // The severity to be echoed by the server. 191 Severity severity = 3; 192 193 Foobar foobar = 4; 194} 195 196// The response message for the Echo methods. 197message EchoResponse { 198 // The content specified in the request. 199 string content = 1; 200 201 // The severity specified in the request. 202 Severity severity = 2; 203} 204 205// Tests name collisions with java.lang.Object. 206message Object { 207 // The content specified in the request. 208 string content = 1; 209} 210 211// The request message for the Expand method. 212message ExpandRequest { 213 // The content that will be split into words and returned on the stream. 214 string content = 1; 215 216 // The error that is thrown after all words are sent on the stream. 217 google.rpc.Status error = 2; 218 219 string info = 3; 220} 221 222// The request for the PagedExpand method. 223message PagedExpandRequest { 224 // The string to expand. 225 string content = 1 [(google.api.field_behavior) = REQUIRED]; 226 227 // The amount of words to returned in each page. 228 int32 page_size = 2; 229 230 // The position of the page to be returned. 231 string page_token = 3; 232} 233 234// The response for the PagedExpand method. 235message PagedExpandResponse { 236 // The words that were expanded. 237 repeated EchoResponse responses = 1; 238 239 // The next page token. 240 string next_page_token = 2; 241} 242 243// The request for Wait method. 244message WaitRequest { 245 oneof end { 246 // The time that this operation will complete. 247 google.protobuf.Timestamp end_time = 1; 248 249 // The duration of this operation. 250 google.protobuf.Duration ttl = 4; 251 } 252 253 oneof response { 254 // The error that will be returned by the server. If this code is specified 255 // to be the OK rpc code, an empty response will be returned. 256 google.rpc.Status error = 2; 257 258 // The response to be returned on operation completion. 259 WaitResponse success = 3; 260 } 261} 262 263// The result of the Wait operation. 264message WaitResponse { 265 // This content of the result. 266 string content = 1; 267} 268 269// The metadata for Wait operation. 270message WaitMetadata { 271 // The time that this operation will complete. 272 google.protobuf.Timestamp end_time = 1; 273} 274 275// The request for Block method. 276message BlockRequest { 277 // The amount of time to block before returning a response. 278 google.protobuf.Duration response_delay = 1; 279 280 oneof response { 281 // The error that will be returned by the server. If this code is specified 282 // to be the OK rpc code, an empty response will be returned. 283 google.rpc.Status error = 2; 284 285 // The response to be returned that will signify successful method call. 286 BlockResponse success = 3; 287 } 288} 289 290// The response for Block method. 291message BlockResponse { 292 // This content can contain anything, the server will not depend on a value 293 // here. 294 string content = 1; 295} 296