-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.proto
380 lines (353 loc) · 12.9 KB
/
service.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
// ************************************************************************
// Copyright (C) 2022 plgd.dev, s.r.o.
//
// 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 service.pb;
import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "pb/clear_cache.proto";
import "pb/get_device.proto";
import "pb/get_devices.proto";
import "pb/get_resource.proto";
import "pb/create_resource.proto";
import "pb/delete_resource.proto";
import "pb/update_resource.proto";
import "pb/get_device_resource_links.proto";
import "pb/own_device.proto";
import "pb/disown_device.proto";
import "pb/get_configuration.proto";
import "pb/get_identity_certificate.proto";
import "pb/get_json_web_keys.proto";
import "pb/initialize.proto";
import "pb/reset.proto";
import "pb/onboard_device.proto";
import "pb/offboard_device.proto";
import "grpc-gateway/pb/devices.proto";
import "resource-aggregate/pb/events.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "plgd client application - API";
version: "1.0";
description: "";
contact: {
name: "plgd.dev";
url: "https://github.com/plgd-dev/device";
email: "info@plgd.dev";
};
license: {
name: "Apache License 2.0";
url: "https://github.com/plgd-dev/device/blob/v2/LICENSE";
};
};
schemes: [ HTTPS ];
consumes: [ "application/json", "application/protojson" ];
produces: [ "application/json", "application/protojson" ];
security_definitions: {
security: {
key: "OAuth2";
value: {
type: TYPE_OAUTH2;
flow: FLOW_ACCESS_CODE;
description: "OAuth2 authorization is used when GetConfigurationResponse.device_authentication_mode == X509";
}
}
}
};
option go_package = "github.com/plgd-dev/client-application/pb;pb";
// https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
service ClientApplication {
rpc GetDevices (GetDevicesRequest) returns (stream grpcgateway.pb.Device) {
option (google.api.http) = {
get: "/api/v1/devices"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Devices" ]
summary: "Discover devices by client application."
description: "This operation fills cache of mappings deviceId to endpoints and this cache is used by other calls."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc GetDevice (GetDeviceRequest) returns (grpcgateway.pb.Device) {
option (google.api.http) = {
get: "/api/v1/devices/{device_id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Get device information from the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc GetDeviceResourceLinks(GetDeviceResourceLinksRequest) returns (resourceaggregate.pb.ResourceLinksPublished) {
option (google.api.http) = {
get: "/api/v1/devices/{device_id}/resource-links"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Get resource links of the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc GetResource(GetResourceRequest) returns (grpcgateway.pb.Resource) {
option (google.api.http) = {
get: "/api/v1/devices/{resource_id.device_id}/resources/{resource_id.href=**}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Resource" ]
summary: "Get a resource from the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc UpdateResource(UpdateResourceRequest) returns (grpcgateway.pb.UpdateResourceResponse) {
option (google.api.http) = {
put: "/api/v1/devices/{resource_id.device_id}/resources/{resource_id.href=**}"
body: "content"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Resource" ]
summary: "Update a resource at the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc CreateResource(CreateResourceRequest) returns (grpcgateway.pb.CreateResourceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{resource_id.device_id}/resource-links/{resource_id.href=**}"
body: "content"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Resource" ]
summary: "Create a resource at the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc DeleteResource(DeleteResourceRequest) returns (grpcgateway.pb.DeleteResourceResponse) {
option (google.api.http) = {
delete: "/api/v1/devices/{resource_id.device_id}/resource-links/{resource_id.href=**}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Resource" ]
summary: "Delete a resource at the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc OwnDevice(OwnDeviceRequest) returns (OwnDeviceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{device_id}/own"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Own the device."
description: "When GetConfigurationResponse.device_authentication_mode == X509 and GetConfigurationResponse.remote_provisioning.mode == USER_AGENT the finish own need to be called:\n - own returns identity CSR of the device which need to be signed by certificate authority\n - in own/{state} call provides signed identity certificate to the device.option\nLook to https://raw.githubusercontent.com/plgd-dev/client-application/main/ownDevice.plantuml for flows."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc FinishOwnDevice(FinishOwnDeviceRequest) returns (FinishOwnDeviceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{device_id}/own/{state}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Finishing own the device for remote provisioning via USER_AGENT."
description: "Available only when GetConfigurationResponse.device_authentication_mode == X509 and GetConfigurationResponse.remote_provisioning.mode == USER_AGENT."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc DisownDevice(DisownDeviceRequest) returns (DisownDeviceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{device_id}/disown"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Disown the device."
description: "Device needs to be stored in cache otherwise it returns not found."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc ClearCache(ClearCacheRequest) returns (ClearCacheResponse) {
option (google.api.http) = {
delete: "/api/v1/devices"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Devices" ]
summary: "Deletes all devices from the cache."
description: "To fill the cache again, call GetDevices."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc GetConfiguration(GetConfigurationRequest) returns (GetConfigurationResponse) {
option (google.api.http) = {
get: "/.well-known/configuration"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Provides configuration for clients of client application."
};
}
rpc GetJSONWebKeys(GetJSONWebKeysRequest) returns (google.protobuf.Struct) {
option (google.api.http) = {
get: "/.well-known/jwks.json"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Get jwks.json."
description: "Available only when GetConfigurationResponse.device_authentication_mode == X509 and GetConfigurationResponse.remote_provisioning.mode == USER_AGENT."
};
}
rpc GetIdentityCertificate(GetIdentityCertificateRequest) returns (GetIdentityCertificateResponse) {
option (google.api.http) = {
get: "/api/v1/identity/certificate"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Get identity certificate of the client application."
description: "Available only when GetConfigurationResponse.device_authentication_mode == X509 and GetConfigurationResponse.remote_provisioning.mode == USER_AGENT."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc Initialize(InitializeRequest) returns (InitializeResponse) {
option (google.api.http) = {
post: "/api/v1/initialize"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Initialize application when GetConfiguration.is_initialized is set to false."
description: "Look to https://raw.githubusercontent.com/plgd-dev/client-application/main/initialize.plantuml for flows."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc FinishInitialize(FinishInitializeRequest) returns (FinishInitializeResponse) {
option (google.api.http) = {
post: "/api/v1/initialize/{state}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Finishing initialization for remote provisioning via USER_AGENT."
description: "Available only when GetConfigurationResponse.device_authentication_mode == X509 and GetConfigurationResponse.remote_provisioning.mode == USER_AGENT."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc Reset(ResetRequest) returns (ResetResponse) {
option (google.api.http) = {
post: "/api/v1/reset"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "client-application" ]
summary: "Flushes identity certificate, private key, device cache and jwks.json."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc OnboardDevice(OnboardDeviceRequest) returns (OnboardDeviceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{device_id}/onboard"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Onboard the device."
description: "Provisions device to the plgd hub."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
rpc OffboardDevice(OffboardDeviceRequest) returns (OffboardDeviceResponse) {
option (google.api.http) = {
post: "/api/v1/devices/{device_id}/offboard"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Device" ]
summary: "Offboard the device."
description: "Disconnects device from the plgd hub."
security: {
security_requirement: {
key: "OAuth2";
}
}
};
}
}