xref: /aosp_15_r20/external/sdk-platform-java/gapic-generator-java/src/test/proto/compliance.proto (revision 882aa7c72c3cd3b66e72a261bdd69b93f7de7670)
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//     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/cloud/extended_operations.proto";
20
21package google.showcase.v1beta1;
22
23option go_package = "github.com/googleapis/gapic-showcase/server/genproto";
24option java_package = "com.google.showcase.v1beta1";
25option java_multiple_files = true;
26
27// This service is used to test that GAPICs can transcode proto3 requests to
28// REST format correctly for various types of HTTP annotations.
29service Compliance {
30  // This service is meant to only run locally on the port 7469 (keypad digits
31  // for "show").
32  option (google.api.default_host) = "localhost:7469";
33
34  // This method echoes the ComplianceData request. This method exercises
35  // sending the entire request object in the REST body.
36  rpc RepeatDataBody(RepeatRequest) returns (RepeatResponse) {
37    option (google.api.http) = {
38      post: "/v1beta1/repeat:body"
39      body: "*"
40    };
41  }
42
43  // This method echoes the ComplianceData request. This method exercises
44  // sending the a message-type field in the REST body. Per AIP-127, only
45  // top-level, non-repeated fields can be sent this way.
46  rpc RepeatDataBodyInfo(RepeatRequest) returns (RepeatResponse) {
47    option (google.api.http) = {
48      post: "/v1beta1/repeat:bodyinfo"
49      body: "info"
50    };
51  }
52
53  // This method echoes the ComplianceData request. This method exercises
54  // sending all request fields as query parameters.
55  rpc RepeatDataQuery(RepeatRequest) returns (RepeatResponse) {
56    option (google.api.http) = {
57      get: "/v1beta1/repeat:query"
58    };
59  }
60
61  // This method echoes the ComplianceData request. This method exercises
62  // sending some parameters as "simple" path variables (i.e., of the form
63  // "/bar/{foo}" rather than "/{foo=bar/*}"), and the rest as query parameters.
64  rpc RepeatDataSimplePath(RepeatRequest) returns (RepeatResponse) {
65    option (google.api.http) = {
66      get: "/v1beta1/repeat/{info.f_string}/{info.f_int32}/{info.f_double}/{info.f_bool}/{info.f_kingdom}:simplepath"
67    };
68  }
69
70  // Same as RepeatDataSimplePath, but with a path resource.
71  rpc RepeatDataPathResource(RepeatRequest) returns (RepeatResponse) {
72    option (google.api.http) = {
73      get: "/v1beta1/repeat/{info.f_string=first/*}/{info.f_child.f_string=second/*}/bool/{info.f_bool}:pathresource"
74    };
75  }
76
77  // Same as RepeatDataSimplePath, but with a trailing resource.
78  rpc RepeatDataPathTrailingResource(RepeatRequest) returns (RepeatResponse) {
79    option (google.api.http) = {
80      get: "/v1beta1/repeat/{info.f_string=first/*}/{info.f_child.f_string=second/**}:pathtrailingresource"
81    };
82  }
83
84  // This method requests an enum value from the server. Depending on the contents of EnumRequest, the enum value returned will be a known enum declared in the
85  // .proto file, or a made-up enum value the is unknown to the client. To verify that clients can round-trip unknown enum vaues they receive, use the
86  // response from this RPC as the request to VerifyEnum()
87  //
88  // The values of enums sent by the server when a known or unknown value is requested will be the same within a single Showcase server run (this is needed for
89  // VerifyEnum() to work) but are not guaranteed to be the same across separate Showcase server runs.
90  rpc GetEnum(EnumRequest) returns (EnumResponse) {
91    option (google.api.http) = {
92      get: "/v1beta1/compliance/enum"
93    };
94  }
95
96  // This method is used to verify that clients can round-trip enum values, which is particularly important for unknown enum values over REST. VerifyEnum()
97  // verifies that its request, which is presumably the response that the client previously got to a GetEnum(), contains the correct data. If so, it responds
98  // with the same EnumResponse; otherwise, the RPC errors.
99  //
100  // This works because the values of enums sent by the server when a known or unknown value is requested will be the same within a single Showcase server run,
101  // although they are not guaranteed to be the same across separate Showcase server runs.
102  rpc VerifyEnum(EnumResponse) returns (EnumResponse) {
103    option (google.api.http) = {
104      post: "/v1beta1/compliance/enum"
105    };
106  }
107
108}
109
110message EnumRequest {
111  // Whether the client is requesting a new, unknown enum value or a known enum value already declard in this proto file.
112  bool unknown_enum = 1;
113}
114
115message EnumResponse {
116  // The original request for a known or unknown enum from the server.
117  EnumRequest request = 1;
118
119  // The actual enum the server provided.
120  Continent continent = 2;
121}
122
123message RepeatRequest {
124  string name = 1;
125  ComplianceData info = 2;
126
127  // If true, the server will verify that the received request matches
128  // the request with the same name in the compliance test suite.
129  bool server_verify = 3;
130}
131
132message RepeatResponse {
133  ComplianceData info = 1;
134}
135
136// ComplianceSuite contains a set of requests that microgenerators should issue
137// over REST to the Compliance service to test their gRPC-to-REST transcoding
138// implementation.
139message ComplianceSuite {
140  repeated ComplianceGroup group = 1;
141}
142
143// ComplianceGroups encapsulates a group of RPC requests to the Compliance
144// server: one request for each combination of elements of `rpcs` and of
145// `requests`.
146message ComplianceGroup {
147  string name = 1;
148  repeated string rpcs = 2;
149  repeated RepeatRequest requests = 3;
150}
151
152// ComplianceData is a message used for testing REST transcoding of
153// different data types.
154message ComplianceData {
155  enum LifeKingdom {
156    LIFE_KINGDOM_UNSPECIFIED = 0;
157    ARCHAEBACTERIA = 1;
158    EUBACTERIA = 2;
159    PROTISTA = 3;
160    FUNGI = 4;
161    PLANTAE = 5;
162    ANIMALIA = 6;
163}
164  // scalar types
165
166  string f_string = 1;
167
168  int32 f_int32 = 2;
169  sint32 f_sint32 = 3;
170  sfixed32 f_sfixed32 = 4;
171
172  uint32 f_uint32 = 5;
173  fixed32 f_fixed32 = 6;
174
175  int64 f_int64 = 7;
176  sint64 f_sint64 = 8;
177  sfixed64 f_sfixed64 = 9;
178
179  uint64 f_uint64 = 10;
180  fixed64 f_fixed64 = 11;
181
182  double f_double = 12;
183  float f_float = 13;
184
185  optional bool f_bool = 14;
186
187  bytes f_bytes = 15;
188
189  LifeKingdom f_kingdom = 22;
190
191  ComplianceDataChild f_child = 16;
192
193  // optional fields
194
195  optional string p_string = 17;
196  optional int32 p_int32 = 18;
197  optional double p_double = 19;
198  optional bool p_bool = 20;
199  optional LifeKingdom p_kingdom = 23;
200  optional ComplianceDataChild p_child = 21;
201}
202
203message ComplianceDataChild {
204  string f_string = 1;
205  float f_float = 2;
206  double f_double = 3;
207  bool f_bool = 4;
208  Continent f_continent = 11;
209  ComplianceDataGrandchild f_child = 5;
210
211  optional string p_string = 6;
212  optional float p_float = 7;
213  optional double p_double = 8;
214  optional bool p_bool = 9;
215  Continent p_continent = 12;
216  optional ComplianceDataGrandchild p_child = 10;
217}
218
219message ComplianceDataGrandchild {
220  string f_string = 1;
221  double f_double = 2;
222  bool f_bool = 3;
223}
224
225enum Continent {
226  CONTINENT_UNSPECIFIED = 0;
227  AFRICA = 1;
228  AMERICA = 2;
229  ANTARTICA = 3;
230  AUSTRALIA = 4;
231  EUROPE = 5;
232}