/
types.go
550 lines (475 loc) · 21.2 KB
/
types.go
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
/*
* *******************************************************************************
* * Copyright (c) 2019 Edgeworx, Inc.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/
package client
// Flows - Keep for legacy
type FlowInfo struct {
Name string `json:"name"`
Description string `json:"description"`
IsActivated bool `json:"isActivated"`
IsSystem bool `json:"isSystem"`
UserID int `json:"userId"`
ID int `json:"id"`
}
type FlowCreateRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
}
type FlowCreateResponse struct {
ID int `json:"id"`
Name string `json:"name"`
}
type FlowUpdateRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
IsActivated *bool `json:"isActivated,omitempty"`
IsSystem *bool `json:"isSystem,omitempty"`
ID int `json:"-"`
}
type FlowListResponse struct {
Flows []FlowInfo `json:"flows"`
}
// Applications
type ApplicationInfo struct {
Name string `json:"name"`
Description string `json:"description"`
IsActivated bool `json:"isActivated"`
IsSystem bool `json:"isSystem"`
UserID int `json:"userId"`
ID int `json:"id"`
Microservices []MicroserviceInfo `json:"microservices"`
Routes []Route `json:"routes"`
}
type ApplicationCreateResponse struct {
ID int `json:"id"`
}
type ApplicationPatchRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
IsActivated *bool `json:"isActivated,omitempty"`
IsSystem *bool `json:"isSystem,omitempty"`
}
type ApplicationListResponse struct {
Applications []ApplicationInfo `json:"applications"`
}
// Application Templates
type ApplicationTemplate struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Variables []TemplateVariable `json:"variables,omitempty"`
Application *ApplicationTemplateInfo `json:"application,omitempty"`
}
type ApplicationTemplateCreateRequest = ApplicationTemplate
type TemplateVariable struct {
Key string `json:"key" yaml:"key,omitempty"`
Description string `json:"description" yaml:"description,omitempty"`
DefaultValue interface{} `json:"defaultValue,omitempty" yaml:"defaultValue,omitempty"`
Value interface{} `json:"value,omitempty" yaml:"value,omitempty"`
}
type ApplicationTemplateInfo struct {
Microservices []interface{} `json:"microservices"`
Routes []interface{} `json:"routes"`
}
type ApplicationTemplateCreateResponse struct {
Name string `json:"name"`
ID int `json:"id"`
}
type ApplicationTemplateUpdateResponse = ApplicationTemplateCreateResponse
type ApplicationTemplateMetadataUpdateRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
}
type ApplicationTemplateListResponse struct {
ApplicationTemplates []ApplicationTemplate
}
// Registries
type RegistryInfo struct {
ID int `json:"id"`
URL string `json:"url"`
IsPublic bool `json:"isPublic"`
IsSecure bool `json:"isSecure"`
Certificate string `json:"certificate"`
RequiresCert bool `json:"requiresCert"`
Username string `json:"username"`
Email string `json:"userEmail"`
}
type RegistryCreateRequest struct {
URL string `json:"url"`
IsPublic bool `json:"isPublic"`
Certificate string `json:"certificate"`
RequiresCert bool `json:"requiresCert"`
Username string `json:"username"`
Email string `json:"email"`
Password string `json:"password"`
}
type RegistryCreateResponse struct {
ID int `json:"id"`
}
type RegistryUpdateRequest struct {
URL *string `json:"url,omitempty"`
IsPublic *bool `json:"isPublic,omitempty"`
Certificate *string `json:"certificate,omitempty"`
RequiresCert *bool `json:"requiresCert,omitempty"`
Username *string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
Password *string `json:"password,omitempty"`
ID int `json:"-"`
}
type RegistryListResponse struct {
Registries []RegistryInfo `json:"registries"`
}
// Catalog (Keeping it basic, because it will be reworked soon)
type CatalogImage struct {
ContainerImage string `json:"containerImage"`
AgentTypeID int `json:"fogTypeId"`
}
type CatalogItemInfo struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Images []CatalogImage `json:"images"`
RegistryID int `json:"registryId"`
Category string `json:"category"`
}
type CatalogItemCreateRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Images []CatalogImage `json:"images"`
RegistryID int `json:"registryId"`
}
type CatalogItemCreateResponse struct {
ID int `json:"id"`
}
type CatalogItemUpdateRequest struct {
ID int
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Images []CatalogImage `json:"images,omitempty"`
RegistryID int `json:"registryId,omitempty"`
}
type CatalogListResponse struct {
CatalogItems []CatalogItemInfo `json:"catalogItems"`
}
// Microservices
type MicroservicePublicPortRouterInfo struct {
Port int64 `json:"port"`
Host string `json:"host"`
}
type MicroservicePublicPortInfo struct {
Schemes []string `json:"schemes"`
Links []string `json:"links"`
Protocol string `json:"protocol"`
Enabled bool `json:"enabled"`
Router *MicroservicePublicPortRouterInfo `json:"router,omitempty"`
}
type MicroserviceProxyPortInfo struct {
Host string `json:"host"`
Port int64 `json:"port"`
Protocol string `json:"protocol"`
Scheme string `json:"scheme"`
}
type MicroservicePortMappingInfo struct {
Internal int64 `json:"internal"`
External int64 `json:"external"`
Public *MicroservicePublicPortInfo `json:"public,omitempty"`
Proxy *MicroserviceProxyPortInfo `json:"proxy,omitempty"`
Protocol string `json:"protocol,omitempty"`
}
type MicroserviceVolumeMappingInfo struct {
HostDestination string `json:"hostDestination"`
ContainerDestination string `json:"containerDestination"`
AccessMode string `json:"accessMode"`
Type string `json:"type,omitempty"`
}
type MicroserviceEnvironmentInfo struct {
Key string `json:"key"`
Value string `json:"value"`
}
type MicroserviceStatusInfo struct {
Status string `json:"status"`
StartTime int64 `json:"startTime"`
OperatingDuration int64 `json:"operatingDuration"`
MemoryUsage float64 `json:"memoryUsage"`
CPUUsage float64 `json:"cpuUsage"`
ContainerID string `json:"containerId"`
Percentage float64 `json:"percentage"`
ErrorMessage string `json:"errorMessage"`
}
type MicroserviceInfo struct {
UUID string `json:"uuid"`
Config string `json:"config"`
Name string `json:"name"`
RootHostAccess bool `json:"rootHostAccess"`
LogSize int `json:"logSize"`
Delete bool `json:"delete"`
DeleteWithCleanup bool `json:"deleteWithCleanup"`
FlowID int `json:"flowId"`
ApplicationID int `json:"applicationID"`
Application string `json:"application"`
CatalogItemID int `json:"catalogItemId"`
AgentUUID string `json:"iofogUuid"`
UserID int `json:"userId"`
RegistryID int `json:"registryId"`
Ports []MicroservicePortMappingInfo `json:"ports"`
Volumes []MicroserviceVolumeMappingInfo `json:"volumeMappings"`
Commands []string `json:"cmd"`
Env []MicroserviceEnvironmentInfo `json:"env"`
ExtraHosts []MicroserviceExtraHost `json:"extraHosts"`
Status MicroserviceStatusInfo `json:"status"`
Images []CatalogImage `json:"images"`
}
type MicroserviceExtraHost struct {
Name string `json:"name,omitempty"`
Address string `json:"address,omitempty"`
Value string `json:"value,omitempty"`
}
type MicroserviceCreateResponse struct {
UUID string `json:"uuid"`
}
type MicroserviceListResponse struct {
Microservices []MicroserviceInfo
}
type MicroservicePortMappingListResponse struct {
PortMappings []MicroservicePortMappingInfo `json:"ports"`
}
type MicroservicePublicPort struct {
MicroserviceUUID string `json:"microserviceUuid"`
PublicPort PublicPort `json:"publicPort"`
}
type PublicPort struct {
Protocol string `json:"protocol"`
Queue string `json:"queueName"`
Port int `json:"publicPort"`
}
// Users
type User struct {
Name string `json:"firstName"`
Surname string `json:"lastName"`
Email string `json:"email"`
Password string `json:"password"`
}
type ControllerVersions struct {
Controller string `json:"controller"`
EcnViewer string `json:"ecnViewer"`
}
type ControllerStatus struct {
Status string `json:"status"`
UptimeSeconds float64 `json:"uptimeSec"`
Versions ControllerVersions `json:"versions"`
}
type LoginRequest struct {
Email string `json:"email"`
Password string `json:"password"`
}
type UpdateUserPasswordRequest struct {
OldPassword string `json:"oldPassword"`
NewPassword string `json:"newPassword"`
}
type LoginResponse struct {
AccessToken string `json:"accessToken"`
}
type ListAgentsRequest struct {
System bool `json:"system"`
Filters []AgentListFilter `json:"filters"`
}
type CreateAgentRequest struct {
AgentUpdateRequest `json:",inline"`
}
type CreateAgentResponse struct {
UUID string
}
type GetAgentProvisionKeyResponse struct {
Key string `json:"key"`
ExpireTimeMsUTC int64 `json:"expirationTime"`
}
type AgentInfo struct {
UUID string `json:"uuid" yaml:"uuid"`
Name string `json:"name" yaml:"name"`
Host string `json:"host" yaml:"host"`
Location string `json:"location" yaml:"location"`
Latitude float64 `json:"latitude" yaml:"latitude"`
Longitude float64 `json:"longitude" yaml:"longitude"`
Description string `json:"description" yaml:"description"`
DockerURL string `json:"dockerUrl" yaml:"dockerUrl"`
DiskLimit int64 `json:"diskLimit" yaml:"diskLimit"`
DiskDirectory string `json:"diskDirectory" yaml:"diskDirectory"`
MemoryLimit int64 `json:"memoryLimit" yaml:"memoryLimit"`
CPULimit int64 `json:"cpuLimit" yaml:"cpuLimit"`
LogLimit int64 `json:"logLimit" yaml:"logLimit"`
LogDirectory string `json:"logDirectory" yaml:"logDirectory"`
LogFileCount int64 `json:"logFileCount" yaml:"logFileCount"`
StatusFrequency float64 `json:"statusFrequency" yaml:"statusFrequency"`
ChangeFrequency float64 `json:"changeFrequency" yaml:"changeFrequency"`
DeviceScanFrequency float64 `json:"deviceScanFrequency" yaml:"deviceScanFrequency"`
BluetoothEnabled bool `json:"bluetoothEnabled" yaml:"bluetoothEnabled"`
WatchdogEnabled bool `json:"watchdogEnabled" yaml:"watchdogEnabled"`
AbstractedHardwareEnabled bool `json:"abstractedHardwareEnabled" yaml:"abstractedHardwareEnabled"`
CreatedTimeRFC3339 string `json:"createdAt" yaml:"created"`
UpdatedTimeRFC3339 string `json:"updatedAt" yaml:"updated"`
LastActive int64 `json:"lastActive" yaml:"lastActive"`
DaemonStatus string `json:"daemonStatus" yaml:"daemonStatus"`
UptimeMs int64 `json:"daemonOperatingDuration" yaml:"uptime"`
MemoryUsage float64 `json:"memoryUsage" yaml:"memoryUsage"`
DiskUsage float64 `json:"diskUsage" yaml:"diskUsage"`
CPUUsage float64 `json:"cpuUsage" yaml:"cpuUsage"`
SystemAvailableMemory float64 `json:"systemAvailableMemory" yaml:"systemAvailableMemory"`
SystemAvailableDisk float64 `json:"systemAvailableDisk" yaml:"systemAvailableDisk"`
MemoryViolation string `json:"memoryViolation" yaml:"memoryViolation"`
DiskViolation string `json:"diskViolation" yaml:"diskViolation"`
CPUViolation string `json:"cpuViolation" yaml:"cpuViolation"`
MicroserviceStatus string `json:"microserviceStatus" yaml:"microserviceStatus"`
RepositoryCount int64 `json:"repositoryCount" yaml:"repositoryCount"`
RepositoryStatus string `json:"repositoryStatus" yaml:"repositoryStatus"`
LastStatusTimeMsUTC int64 `json:"lastStatusTime" yaml:"lastStatusTime"`
IPAddress string `json:"ipAddress" yaml:"ipAddress"`
IPAddressExternal string `json:"ipAddressExternal" yaml:"ipAddressExternal"`
ProcessedMessaged int64 `json:"processedMessages" yaml:"ProcessedMessages"`
MicroserviceMessageCount int64 `json:"microserviceMessageCounts" yaml:"microserviceMessageCount"`
MessageSpeed float64 `json:"messageSpeed" yaml:"messageSpeed"`
LastCommandTimeMsUTC int64 `json:"lastCommandTime" yaml:"lastCommandTime"`
NetworkInterface string `json:"networkInterface" yaml:"networkInterface"`
Version string `json:"version" yaml:"version"`
IsReadyToUpgrade bool `json:"isReadyToUpgrade" yaml:"isReadyToUpgrade"`
IsReadyToRollback bool `json:"isReadyToRollback" yaml:"isReadyToRollback"`
Tunnel string `json:"tunnel" yaml:"tunnel"`
FogType int `json:"fogTypeId" yaml:"fogTypeId"`
RouterMode string `json:"routerMode" yaml:"routerMode"`
NetworkRouter *string `json:"networkRouter,omitempty" yaml:"networkRouter,omitempty"`
UpstreamRouters *[]string `json:"upstreamRouters,omitempty" yaml:"upstreamRouters,omitempty"`
MessagingPort *int `json:"messagingPort,omitempty" yaml:"messagingPort,omitempty"`
EdgeRouterPort *int `json:"edgeRouterPort,omitempty" yaml:"edgeRouterPort,omitempty"`
InterRouterPort *int `json:"interRouterPort,omitempty" yaml:"interRouterPort,omitempty"`
LogLevel *string `json:"logLevel" yaml:"logLevel"`
DockerPruningFrequency *float64 `json:"dockerPruningFrequency" yaml:"dockerPruningFrequency"`
AvailableDiskThreshold *float64 `json:"availableDiskThreshold" yaml:"availableDiskThreshold"`
Tags *[]string `json:"tags,omitempty" yaml:"tags,omitempty"`
TimeZone string `json:"timeZone" yaml:"timeZone"`
}
type RouterConfig struct {
RouterMode *string `json:"routerMode,omitempty" yaml:"routerMode,omitempty"`
MessagingPort *int `json:"messagingPort,omitempty" yaml:"messagingPort,omitempty"`
EdgeRouterPort *int `json:"edgeRouterPort,omitempty" yaml:"edgeRouterPort,omitempty"`
InterRouterPort *int `json:"interRouterPort,omitempty" yaml:"interRouterPort,omitempty"`
}
type AgentConfiguration struct {
DockerURL *string `json:"dockerUrl,omitempty" yaml:"dockerUrl"`
DiskLimit *int64 `json:"diskLimit,omitempty" yaml:"diskLimit"`
DiskDirectory *string `json:"diskDirectory,omitempty" yaml:"diskDirectory"`
MemoryLimit *int64 `json:"memoryLimit,omitempty" yaml:"memoryLimit"`
CPULimit *int64 `json:"cpuLimit,omitempty" yaml:"cpuLimit"`
LogLimit *int64 `json:"logLimit,omitempty" yaml:"logLimit"`
LogDirectory *string `json:"logDirectory,omitempty" yaml:"logDirectory"`
LogFileCount *int64 `json:"logFileCount,omitempty" yaml:"logFileCount"`
StatusFrequency *float64 `json:"statusFrequency,omitempty" yaml:"statusFrequency"`
ChangeFrequency *float64 `json:"changeFrequency,omitempty" yaml:"changeFrequency"`
DeviceScanFrequency *float64 `json:"deviceScanFrequency,omitempty" yaml:"deviceScanFrequency"`
BluetoothEnabled *bool `json:"bluetoothEnabled,omitempty" yaml:"bluetoothEnabled"`
WatchdogEnabled *bool `json:"watchdogEnabled,omitempty" yaml:"watchdogEnabled"`
AbstractedHardwareEnabled *bool `json:"abstractedHardwareEnabled,omitempty" yaml:"abstractedHardwareEnabled"`
IsSystem *bool `json:"isSystem,omitempty" yaml:"-"` // Can't specify system agent using yaml file.
UpstreamRouters *[]string `json:"upstreamRouters,omitempty" yaml:"upstreamRouters,omitempty"`
NetworkRouter *string `json:"networkRouter,omitempty" yaml:"networkRouter,omitempty"`
Host *string `json:"host,omitempty" yaml:"host,omitempty"`
RouterConfig `json:",omitempty" yaml:"routerConfig,omitempty"`
LogLevel *string `json:"logLevel,omitempty" yaml:"logLevel"`
DockerPruningFrequency *float64 `json:"dockerPruningFrequency,omitempty" yaml:"dockerPruningFrequency"`
AvailableDiskThreshold *float64 `json:"availableDiskThreshold,omitempty" yaml:"availableDiskThreshold"`
TimeZone string `json:"timeZone,omitempty" yaml:"timeZone"`
}
type AgentUpdateRequest struct {
UUID string `json:"-"`
Name string `json:"name,omitempty" yaml:"name"`
Location string `json:"location,omitempty" yaml:"location"`
Latitude float64 `json:"latitude,omitempty" yaml:"latitude"`
Longitude float64 `json:"longitude,omitempty" yaml:"longitude"`
Description string `json:"description,omitempty" yaml:"description"`
FogType *int64 `json:"fogType,omitempty" yaml:"agentType"`
Tags *[]string `json:"tags,omitempty" yaml:"tags"`
AgentConfiguration
}
type ListAgentsResponse struct {
Agents []AgentInfo `json:"fogs"`
}
type AgentListFilter struct {
Key string `json:"key"`
Value string `json:"value"`
Condition string `json:"condition"`
}
type Router struct {
RouterConfig
Host string `json:"host"`
}
type UpdateConfigRequest struct {
Key string `json:"key"`
Value string `json:"value"`
}
func newDefaultProxyRequest(address string) *UpdateConfigRequest {
return &UpdateConfigRequest{
Key: "default-proxy-host",
Value: address,
}
}
func newPublicPortHostRequest(protocol Protocol, host string) *UpdateConfigRequest {
return &UpdateConfigRequest{
Key: protocol + "-public-port-host",
Value: host,
}
}
type RouteListResponse struct {
Routes []Route `json:"routes"`
}
// Route still has deprecated Dest/SourceUUID for retro compatibility
// Prefer From and To
type Route struct {
Name string `json:"name"`
Application string `json:"application"`
SourceMicroserviceUUID string `json:"sourceMicroserviceUuid,omitempty"`
DestMicroserviceUUID string `json:"destMicroserviceUuid,omitempty"`
From string `json:"from"`
To string `json:"to"`
}
type ApplicationRouteCreateRequest struct {
Name string `json:"name"`
From string `json:"from"`
To string `json:"to"`
}
type EdgeResourceDisplay struct {
Name string `json:"name,omitempty"`
Icon string `json:"icon,omitempty"`
Color string `json:"color,omitempty"`
}
type EdgeResourceMetadata struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
InterfaceProtocol string `json:"interfaceProtocol,omitempty"`
Display *EdgeResourceDisplay `json:"display,omitempty"`
Interface HTTPEdgeResource `json:"interface,omitempty"` // TODO: Make this generic
OrchestrationTags []string `json:"orchestrationTags,omitempty"`
Custom map[string]interface{} `json:"custom,omitempty"`
}
type HTTPEdgeResource struct {
Endpoints []HTTPEndpoint `json:"endpoints,omitempty"`
}
type HTTPEndpoint struct {
Name string `json:"name,omitempty"`
Method string `json:"method,omitempty"`
URL string `json:"url,omitempty"`
}
type LinkEdgeResourceRequest struct {
AgentUUID string `json:"uuid"`
EdgeResourceName string `json:"-"`
EdgeResourceVersion string `json:"-"`
}
type ListEdgeResourceResponse struct {
EdgeResources []EdgeResourceMetadata `json:"edgeResources"`
}