/
snippets.proto
164 lines (127 loc) · 4.5 KB
/
snippets.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// -*- coding: utf-8 -*-
// Copyright 2021 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package animalia.mollusca.v1;
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/wrappers.proto";
service Snippets {
option (google.api.default_host) = "mollusca.example.com";
rpc MethodOneSignature(SignatureRequest) returns(Response) {
option (google.api.method_signature) = "my_string,my_int,my_bool";
}
rpc MethodLroSignatures(SignatureRequest) returns(google.longrunning.Operation) {
option (google.api.method_signature) = "my_string,my_int,my_bool";
option (google.longrunning.operation_info) = {
response_type: "LroResponse"
metadata_type: "LroMetadata"
};
}
rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {
option (google.api.http) = {
get: "/v1/{parent=items/*}/resources"
};
option (google.api.method_signature) = "parent";
}
rpc MethodServerStreaming(SignatureRequest) returns(stream Response) {
option (google.api.method_signature) = "my_string,my_int,my_bool";
option (google.api.method_signature) = "";
}
rpc MethodBidiStreaming(stream SignatureRequestOneRequiredField) returns (stream Response);
rpc OneOfMethod(OneOfRequest) returns (Response);
rpc OneOfMethodRequiredField(OneOfRequestWithRequiredField) returns (Response);
}
enum Enum {
DEFAULT = 0; // First value must be 0 and is the default
}
message ListResourcesRequest {
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "snippets.example.com/Resource"
}];
string resource_with_wildcard = 2 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "snippets.example.com/ResourceWithWildcardSegment"
}];
int32 page_size = 3;
string page_token = 4;
}
message ListResourcesResponse {
repeated Resource resources = 1;
string next_page_token = 2;
}
message ParentResource {
option (google.api.resource) = {
type: "snippets.example.com/ParentResource"
pattern: "items/{item_id}"
};
string name = 1;
}
message Resource {
option (google.api.resource) = {
type: "snippets.example.com/Resource"
pattern: "items/{item_id}/parts/{part_id}"
};
string name = 1;
}
message ResourceWithWildcardSegment {
option (google.api.resource) = {
type: "snippets.example.com/ResourceWithWildcardSegment"
pattern: "items/{item_id}/parts/{part_id=**}"
};
string name = 1;
}
message MessageWithNesting {
message NestedMessage {
string required_string = 1 [(google.api.field_behavior) = REQUIRED];
string optional_string = 2;
}
NestedMessage message = 1 [(google.api.field_behavior) = REQUIRED];
int32 my_int = 2 [(google.api.field_behavior) = REQUIRED];
}
message SignatureRequestOneRequiredField {
string my_string = 1 [(google.api.field_behavior) = REQUIRED];
}
message SignatureRequest {
string my_string = 1 [(google.api.field_behavior) = REQUIRED];
int32 my_int = 2 [(google.api.field_behavior) = REQUIRED];
bool my_bool = 3 [(google.api.field_behavior) = REQUIRED];
map<int32, string> map_int_string = 4;
MessageWithNesting my_message = 5 [(google.api.field_behavior) = REQUIRED];
Enum single_enum = 6 [(google.api.field_behavior) = REQUIRED];
}
message Response {
}
message LroResponse {
}
message LroMetadata {
}
message OneOfRequest {
string non_one_of_string = 1 [(google.api.field_behavior) = REQUIRED];
oneof my_one_of {
string my_string = 2;
int32 my_number = 3;
}
}
message OneOfRequestWithRequiredField {
string non_one_of_string = 1 [(google.api.field_behavior) = REQUIRED];
// Some APIs mark every field in a "required" oneof as required
oneof my_one_of {
string my_string = 2 [(google.api.field_behavior) = REQUIRED];
int32 my_number = 3 [(google.api.field_behavior) = REQUIRED];
}
}