xref: /aosp_15_r20/external/sdk-platform-java/gapic-generator-java/src/test/proto/messaging.proto (revision 882aa7c72c3cd3b66e72a261bdd69b93f7de7670)
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/empty.proto";
23import "google/protobuf/field_mask.proto";
24import "google/protobuf/timestamp.proto";
25import "google/rpc/error_details.proto";
26
27package google.showcase.v1beta1;
28
29option go_package = "github.com/googleapis/gapic-showcase/server/genproto";
30option java_package = "com.google.showcase.v1beta1";
31option java_multiple_files = true;
32option ruby_package = "Google::Showcase::V1Beta1";
33
34// A simple messaging service that implements chat rooms and profile posts.
35//
36// This messaging service showcases the features that API clients
37// generated by gapic-generators implement.
38service Messaging {
39  // This service is meant to only run locally on the port 7469 (keypad digits
40  // for "show").
41  option (google.api.default_host) = "localhost:7469";
42
43  // Creates a room.
44  rpc CreateRoom(CreateRoomRequest) returns (Room) {
45    option (google.api.http) = {
46      post: "/v1beta1/rooms"
47      body: "*"
48    };
49    option (google.api.method_signature) = "room.display_name,room.description";
50  }
51
52  // Retrieves the Room with the given resource name.
53  rpc GetRoom(GetRoomRequest) returns (Room) {
54    option (google.api.http) = {
55      get: "/v1beta1/{name=rooms/*}"
56    };
57    option (google.api.method_signature) = "name";
58  }
59
60  // Updates a room.
61  rpc UpdateRoom(UpdateRoomRequest) returns (Room) {
62    option (google.api.http) = {
63      patch: "/v1beta1/{room.name=rooms/*}"
64      body: "*"
65    };
66  }
67
68  // Deletes a room and all of its blurbs.
69  rpc DeleteRoom(DeleteRoomRequest) returns (google.protobuf.Empty) {
70    option (google.api.http) = {
71      delete: "/v1beta1/{name=rooms/*}"
72    };
73    option (google.api.method_signature) = "name";
74  }
75
76  // Lists all chat rooms.
77  rpc ListRooms(ListRoomsRequest) returns (ListRoomsResponse) {
78    option (google.api.http) = {
79      get: "/v1beta1/rooms"
80    };
81  }
82
83  // Creates a blurb. If the parent is a room, the blurb is understood to be a
84  // message in that room. If the parent is a profile, the blurb is understood
85  // to be a post on the profile.
86  rpc CreateBlurb(CreateBlurbRequest) returns (Blurb) {
87    option (google.api.http) = {
88      post: "/v1beta1/{parent=rooms/*}/blurbs"
89      body: "*"
90      additional_bindings: {
91        post: "/v1beta1/{parent=users/*/profile}/blurbs"
92        body: "*"
93      }
94    };
95    option (google.api.method_signature) = "parent,blurb.text";
96    option (google.api.method_signature) = "parent,blurb.image";
97  }
98
99  // Retrieves the Blurb with the given resource name.
100  rpc GetBlurb(GetBlurbRequest) returns (Blurb) {
101    option (google.api.http) = {
102      get: "/v1beta1/{name=rooms/*/blurbs/*}"
103      additional_bindings: { get: "/v1beta1/{name=users/*/profile/blurbs/*}" }
104    };
105    option (google.api.method_signature) = "name";
106  }
107
108  // Updates a blurb.
109  rpc UpdateBlurb(UpdateBlurbRequest) returns (Blurb) {
110    option (google.api.http) = {
111      patch: "/v1beta1/{blurb.name=rooms/*/blurbs/*}"
112      body: "*"
113      additional_bindings: {
114        patch: "/v1beta1/{blurb.name=users/*/profile/blurbs/*}"
115        body: "*"
116      }
117    };
118  }
119
120  // Deletes a blurb.
121  rpc DeleteBlurb(DeleteBlurbRequest) returns (google.protobuf.Empty) {
122    option (google.api.http) = {
123      delete: "/v1beta1/{name=rooms/*/blurbs/*}"
124      additional_bindings: {
125        delete: "/v1beta1/{name=users/*/profile/blurbs/*}"
126      }
127    };
128    option (google.api.method_signature) = "name";
129  }
130
131  // Lists blurbs for a specific chat room or user profile depending on the
132  // parent resource name.
133  rpc ListBlurbs(ListBlurbsRequest) returns (ListBlurbsResponse) {
134    option (google.api.http) = {
135      get: "/v1beta1/{parent=rooms/*}/blurbs"
136      additional_bindings: { get: "/v1beta1/{parent=users/*/profile}/blurbs" }
137    };
138    option (google.api.method_signature) = "parent";
139  }
140
141  // This method searches through all blurbs across all rooms and profiles
142  // for blurbs containing to words found in the query. Only posts that
143  // contain an exact match of a queried word will be returned.
144  rpc SearchBlurbs(SearchBlurbsRequest) returns (google.longrunning.Operation) {
145    option (google.api.http) = {
146      post: "/v1beta1/{parent=rooms/*}/blurbs:search"
147      body: "*"
148      additional_bindings: {
149        post: "/v1beta1/{parent=users/*/profile}/blurbs:search"
150      }
151    };
152    option (google.longrunning.operation_info) = {
153      response_type: "SearchBlurbsResponse"
154      metadata_type: "SearchBlurbsMetadata"
155    };
156    option (google.api.method_signature) = "query";
157  }
158
159  // This returns a stream that emits the blurbs that are created for a
160  // particular chat room or user profile.
161  rpc StreamBlurbs(StreamBlurbsRequest) returns (stream StreamBlurbsResponse) {
162    option (google.api.http) = {
163      post: "/v1beta1/{name=rooms/*}/blurbs:stream"
164      body: "*"
165      additional_bindings: {
166        post: "/v1beta1/{name=users/*/profile}/blurbs:stream"
167        body: "*"
168      }
169    };
170  }
171
172  // This is a stream to create multiple blurbs. If an invalid blurb is
173  // requested to be created, the stream will close with an error.
174  rpc SendBlurbs(stream CreateBlurbRequest) returns (SendBlurbsResponse) {
175    option (google.api.http) = {
176      post: "/v1beta1/{parent=rooms/*}/blurbs:send"
177      body: "*"
178      additional_bindings: {
179        post: "/v1beta1/{parent=users/*/profile}/blurbs:send"
180        body: "*"
181      }
182    };
183  }
184
185  // This method starts a bidirectional stream that receives all blurbs that
186  // are being created after the stream has started and sends requests to create
187  // blurbs. If an invalid blurb is requested to be created, the stream will
188  // close with an error.
189  rpc Connect(stream ConnectRequest) returns (stream StreamBlurbsResponse);
190}
191
192// A chat room.
193message Room {
194  option (google.api.resource) = {
195    type: "showcase.googleapis.com/Room"
196    pattern: "rooms/{room}"
197  };
198
199  // The resource name of the chat room.
200  string name = 1;
201
202  // The human readable name of the chat room.
203  string display_name = 2 [(google.api.field_behavior) = REQUIRED];
204
205  // The description of the chat room.
206  string description = 3;
207
208  // The timestamp at which the room was created.
209  google.protobuf.Timestamp create_time = 4
210      [(google.api.field_behavior) = OUTPUT_ONLY];
211
212  // The latest timestamp at which the room was updated.
213  google.protobuf.Timestamp update_time = 5
214      [(google.api.field_behavior) = OUTPUT_ONLY];
215}
216
217// The request message for the google.showcase.v1beta1.Messaging\CreateRoom
218// method.
219message CreateRoomRequest {
220  // The room to create.
221  Room room = 1;
222}
223
224// The request message for the google.showcase.v1beta1.Messaging\GetRoom
225// method.
226message GetRoomRequest {
227  // The resource name of the requested room.
228  string name = 1 [
229    (google.api.resource_reference).type = "showcase.googleapis.com/Room",
230    (google.api.field_behavior) = REQUIRED
231  ];
232}
233
234// The request message for the google.showcase.v1beta1.Messaging\UpdateRoom
235// method.
236message UpdateRoomRequest {
237  // The room to update.
238  Room room = 1;
239
240  // The field mask to determine which fields are to be updated. If empty, the
241  // server will assume all fields are to be updated.
242  google.protobuf.FieldMask update_mask = 2;
243}
244
245// The request message for the google.showcase.v1beta1.Messaging\DeleteRoom
246// method.
247message DeleteRoomRequest {
248  // The resource name of the requested room.
249  string name = 1 [
250    (google.api.resource_reference).type = "showcase.googleapis.com/Room",
251    (google.api.field_behavior) = REQUIRED
252  ];
253}
254
255// The request message for the google.showcase.v1beta1.Messaging\ListRooms
256// method.
257message ListRoomsRequest {
258  // The maximum number of rooms return. Server may return fewer rooms
259  // than requested. If unspecified, server will pick an appropriate default.
260  int32 page_size = 1;
261
262  // The value of google.showcase.v1beta1.ListRoomsResponse.next_page_token
263  // returned from the previous call to
264  // `google.showcase.v1beta1.Messaging\ListRooms` method.
265  string page_token = 2;
266}
267
268// The response message for the google.showcase.v1beta1.Messaging\ListRooms
269// method.
270message ListRoomsResponse {
271  // The list of rooms.
272  repeated Room rooms = 1;
273
274  // A token to retrieve next page of results.
275  // Pass this value in ListRoomsRequest.page_token field in the subsequent
276  // call to `google.showcase.v1beta1.Messaging\ListRooms` method to retrieve
277  // the next page of results.
278  string next_page_token = 2;
279}
280
281// This protocol buffer message represents a blurb sent to a chat room or
282// posted on a user profile.
283message Blurb {
284  option (google.api.resource) = {
285    type: "showcase.googleapis.com/Blurb"
286    pattern: "users/{user}/profile/blurbs/legacy/{legacy_user}~{blurb}"
287    pattern: "users/{user}/profile/blurbs/{blurb}"
288    pattern: "rooms/{room}/blurbs/{blurb}"
289    pattern: "rooms/{room}/blurbs/legacy/{legacy_room}.{blurb}"
290  };
291
292  // The resource name of the chat room.
293  string name = 1;
294
295  oneof content {
296    // The textual content of this blurb.
297    string text = 3;
298
299    // The image content of this blurb.
300    bytes image = 4;
301  }
302
303  // The timestamp at which the blurb was created.
304  google.protobuf.Timestamp create_time = 5
305      [(google.api.field_behavior) = OUTPUT_ONLY];
306
307  // The latest timestamp at which the blurb was updated.
308  google.protobuf.Timestamp update_time = 6
309      [(google.api.field_behavior) = OUTPUT_ONLY];
310
311  // (-- aip.dev/not-precedent: This is designed for testing non-slash
312  //     resource patterns. Ordinarily, non-slash separators are discouraged.
313  //     --)
314  oneof legacy_id {
315    // The legacy id of the room. This field is used to signal
316    // the use of the compound resource pattern
317    // `rooms/{room}/blurbs/legacy/{legacy_room}.{blurb}`
318    string legacy_room_id = 7;
319
320    // The legacy id of the user. This field is used to signal
321    // the use of the compound resource pattern
322    // `users/{user}/profile/blurbs/legacy/{legacy_user}~{blurb}`
323    string legacy_user_id = 8;
324  }
325}
326
327// The request message for the google.showcase.v1beta1.Messaging\CreateBlurb
328// method.
329message CreateBlurbRequest {
330  // The resource name of the chat room or user profile that this blurb will
331  // be tied to.
332  string parent = 1 [
333    (google.api.resource_reference).child_type =
334        "showcase.googleapis.com/Blurb",
335    (google.api.field_behavior) = REQUIRED
336  ];
337
338  // The blurb to create.
339  Blurb blurb = 2;
340}
341
342// The request message for the google.showcase.v1beta1.Messaging\GetBlurb
343// method.
344message GetBlurbRequest {
345  // The resource name of the requested blurb.
346  string name = 1 [
347    (google.api.resource_reference).type = "showcase.googleapis.com/Blurb",
348    (google.api.field_behavior) = REQUIRED
349  ];
350}
351
352// The request message for the google.showcase.v1beta1.Messaging\UpdateBlurb
353// method.
354message UpdateBlurbRequest {
355  // The blurb to update.
356  Blurb blurb = 1;
357
358  // The field mask to determine wich fields are to be updated. If empty, the
359  // server will assume all fields are to be updated.
360  google.protobuf.FieldMask update_mask = 2;
361}
362
363// The request message for the google.showcase.v1beta1.Messaging\DeleteBlurb
364// method.
365message DeleteBlurbRequest {
366  // The resource name of the requested blurb.
367  string name = 1 [
368    (google.api.resource_reference).type = "showcase.googleapis.com/Blurb",
369    (google.api.field_behavior) = REQUIRED
370  ];
371}
372
373// The request message for the google.showcase.v1beta1.Messaging\ListBlurbs
374// method.
375message ListBlurbsRequest {
376  // The resource name of the requested room or profile whos blurbs to list.
377  string parent = 1 [
378    (google.api.resource_reference).child_type =
379        "showcase.googleapis.com/Blurb",
380    (google.api.field_behavior) = REQUIRED
381  ];
382
383  // The maximum number of blurbs to return. Server may return fewer
384  // blurbs than requested. If unspecified, server will pick an appropriate
385  // default.
386  int32 page_size = 2;
387
388  // The value of google.showcase.v1beta1.ListBlurbsResponse.next_page_token
389  // returned from the previous call to
390  // `google.showcase.v1beta1.Messaging\ListBlurbs` method.
391  string page_token = 3;
392}
393
394// The response message for the google.showcase.v1beta1.Messaging\ListBlurbs
395// method.
396message ListBlurbsResponse {
397  // The list of blurbs.
398  repeated Blurb blurbs = 1;
399
400  // A token to retrieve next page of results.
401  // Pass this value in ListBlurbsRequest.page_token field in the subsequent
402  // call to `google.showcase.v1beta1.Blurb\ListBlurbs` method to retrieve
403  // the next page of results.
404  string next_page_token = 2;
405}
406
407// The request message for the google.showcase.v1beta1.Messaging\SearchBlurbs
408// method.
409message SearchBlurbsRequest {
410  // The query used to search for blurbs containing to words of this string.
411  // Only posts that contain an exact match of a queried word will be returned.
412  string query = 1 [(google.api.field_behavior) = REQUIRED];
413
414  // The rooms or profiles to search. If unset, `SearchBlurbs` will search all
415  // rooms and all profiles.
416  string parent = 2 [(google.api.resource_reference).child_type =
417                         "showcase.googleapis.com/Blurb"];
418
419  // The maximum number of blurbs return. Server may return fewer
420  // blurbs than requested. If unspecified, server will pick an appropriate
421  // default.
422  int32 page_size = 3;
423
424  // The value of
425  // google.showcase.v1beta1.SearchBlurbsResponse.next_page_token
426  // returned from the previous call to
427  // `google.showcase.v1beta1.Messaging\SearchBlurbs` method.
428  string page_token = 4;
429}
430
431// The operation metadata message for the
432// google.showcase.v1beta1.Messaging\SearchBlurbs method.
433message SearchBlurbsMetadata {
434  // This signals to the client when to next poll for response.
435  google.rpc.RetryInfo retry_info = 1;
436}
437
438// The operation response message for the
439// google.showcase.v1beta1.Messaging\SearchBlurbs method.
440message SearchBlurbsResponse {
441  // Blurbs that matched the search query.
442  repeated Blurb blurbs = 1;
443
444  // A token to retrieve next page of results.
445  // Pass this value in SearchBlurbsRequest.page_token field in the subsequent
446  // call to `google.showcase.v1beta1.Blurb\SearchBlurbs` method to
447  // retrieve the next page of results.
448  string next_page_token = 2;
449}
450
451// The request message for the google.showcase.v1beta1.Messaging\StreamBlurbs
452// method.
453message StreamBlurbsRequest {
454  // The resource name of a chat room or user profile whose blurbs to stream.
455  string name = 1 [
456    (google.api.resource_reference).child_type =
457        "showcase.googleapis.com/Blurb",
458    (google.api.field_behavior) = REQUIRED
459  ];
460
461  // The time at which this stream will close.
462  google.protobuf.Timestamp expire_time = 2
463      [(google.api.field_behavior) = REQUIRED];
464}
465
466// The response message for the google.showcase.v1beta1.Messaging\StreamBlurbs
467// method.
468message StreamBlurbsResponse {
469  // The blurb that was either created, updated, or deleted.
470  Blurb blurb = 1;
471
472  // The action that triggered the blurb to be returned.
473  enum Action {
474    ACTION_UNSPECIFIED = 0;
475
476    // Specifies that the blurb was created.
477    CREATE = 1;
478
479    // Specifies that the blurb was updated.
480    UPDATE = 2;
481
482    // Specifies that the blurb was deleted.
483    DELETE = 3;
484  }
485
486  // The action that triggered the blurb to be returned.
487  Action action = 2;
488}
489
490// The response message for the google.showcase.v1beta1.Messaging\SendBlurbs
491// method.
492message SendBlurbsResponse {
493  // The names of successful blurb creations.
494  repeated string names = 1;
495}
496
497// The request message for the google.showcase.v1beta1.Messaging\Connect
498// method.
499message ConnectRequest {
500  message ConnectConfig {
501    // The room or profile to follow and create messages for.
502    string parent = 1 [(google.api.resource_reference).child_type =
503                           "showcase.googleapis.com/Blurb"];
504  }
505
506  oneof request {
507    // Provides information that specifies how to process subsequent requests.
508    // The first `ConnectRequest` message must contain a `config`  message.
509    ConnectConfig config = 1;
510
511    // The blurb to be created.
512    Blurb blurb = 2;
513  }
514}
515