-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathconstants.go
408 lines (365 loc) · 20.4 KB
/
constants.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
//
// Copyright (C) 2020-2024 IOTech Ltd
// Copyright (C) 2023 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
package common
// Constants related to defined routes in the v3 service APIs
const (
ApiVersion = "v3"
ApiBase = "/api/v3"
ApiEventRoute = ApiBase + "/event"
ApiEventServiceNameProfileNameDeviceNameSourceNameRoute = ApiEventRoute + "/{" + ServiceName + "}" + "/{" + ProfileName + "}" + "/{" + DeviceName + "}" + "/{" + SourceName + "}"
ApiAllEventRoute = ApiEventRoute + "/" + All
ApiEventIdRoute = ApiEventRoute + "/" + Id + "/{" + Id + "}"
ApiEventCountRoute = ApiEventRoute + "/" + Count
ApiEventCountByDeviceNameRoute = ApiEventCountRoute + "/" + Device + "/" + Name + "/{" + Name + "}"
ApiEventByDeviceNameRoute = ApiEventRoute + "/" + Device + "/" + Name + "/{" + Name + "}"
ApiEventByTimeRangeRoute = ApiEventRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiEventByAgeRoute = ApiEventRoute + "/" + Age + "/{" + Age + "}"
ApiReadingRoute = ApiBase + "/reading"
ApiAllReadingRoute = ApiReadingRoute + "/" + All
ApiReadingCountRoute = ApiReadingRoute + "/" + Count
ApiReadingCountByDeviceNameRoute = ApiReadingCountRoute + "/" + Device + "/" + Name + "/{" + Name + "}"
ApiReadingByDeviceNameRoute = ApiReadingRoute + "/" + Device + "/" + Name + "/{" + Name + "}"
ApiReadingByResourceNameRoute = ApiReadingRoute + "/" + ResourceName + "/{" + ResourceName + "}"
ApiReadingByTimeRangeRoute = ApiReadingRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiReadingByResourceNameAndTimeRangeRoute = ApiReadingByResourceNameRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiReadingByDeviceNameAndResourceNameRoute = ApiReadingRoute + "/" + Device + "/" + Name + "/{" + Name + "}/" + ResourceName + "/{" + ResourceName + "}"
ApiReadingByDeviceNameAndResourceNameAndTimeRangeRoute = ApiReadingByDeviceNameAndResourceNameRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiReadingByDeviceNameAndTimeRangeRoute = ApiReadingByDeviceNameRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiDeviceProfileRoute = ApiBase + "/deviceprofile"
ApiDeviceProfileBasicInfoRoute = ApiDeviceProfileRoute + "/basicinfo"
ApiAllDeviceProfileBasicInfoRoute = ApiDeviceProfileBasicInfoRoute + "/" + All
ApiDeviceProfileDeviceCommandRoute = ApiDeviceProfileRoute + "/" + DeviceCommand
ApiDeviceProfileResourceRoute = ApiDeviceProfileRoute + "/" + Resource
ApiDeviceProfileUploadFileRoute = ApiDeviceProfileRoute + "/uploadfile"
ApiDeviceProfileByNameRoute = ApiDeviceProfileRoute + "/" + Name + "/{" + Name + "}"
ApiDeviceProfileDeviceCommandByNameRoute = ApiDeviceProfileByNameRoute + "/" + DeviceCommand + "/{" + CommandName + "}"
ApiDeviceProfileResourceByNameRoute = ApiDeviceProfileByNameRoute + "/" + Resource + "/{" + ResourceName + "}"
ApiDeviceProfileByIdRoute = ApiDeviceProfileRoute + "/" + Id + "/{" + Id + "}"
ApiAllDeviceProfileRoute = ApiDeviceProfileRoute + "/" + All
ApiDeviceProfileByManufacturerRoute = ApiDeviceProfileRoute + "/" + Manufacturer + "/{" + Manufacturer + "}"
ApiDeviceProfileByModelRoute = ApiDeviceProfileRoute + "/" + Model + "/{" + Model + "}"
ApiDeviceProfileByManufacturerAndModelRoute = ApiDeviceProfileRoute + "/" + Manufacturer + "/{" + Manufacturer + "}" + "/" + Model + "/{" + Model + "}"
ApiDeviceResourceRoute = ApiBase + "/deviceresource"
ApiDeviceResourceByProfileAndResourceRoute = ApiDeviceResourceRoute + "/" + Profile + "/{" + ProfileName + "}" + "/" + Resource + "/{" + ResourceName + "}"
ApiDeviceServiceRoute = ApiBase + "/deviceservice"
ApiAllDeviceServiceRoute = ApiDeviceServiceRoute + "/" + All
ApiDeviceServiceByNameRoute = ApiDeviceServiceRoute + "/" + Name + "/{" + Name + "}"
ApiDeviceServiceByIdRoute = ApiDeviceServiceRoute + "/" + Id + "/{" + Id + "}"
ApiDeviceRoute = ApiBase + "/device"
ApiAllDeviceRoute = ApiDeviceRoute + "/" + All
ApiDeviceIdExistsRoute = ApiDeviceRoute + "/" + Check + "/" + Id + "/{" + Id + "}"
ApiDeviceNameExistsRoute = ApiDeviceRoute + "/" + Check + "/" + Name + "/{" + Name + "}"
ApiDeviceByIdRoute = ApiDeviceRoute + "/" + Id + "/{" + Id + "}"
ApiDeviceByNameRoute = ApiDeviceRoute + "/" + Name + "/{" + Name + "}"
ApiDeviceByProfileIdRoute = ApiDeviceRoute + "/" + Profile + "/" + Id + "/{" + Id + "}"
ApiDeviceByProfileNameRoute = ApiDeviceRoute + "/" + Profile + "/" + Name + "/{" + Name + "}"
ApiDeviceByServiceIdRoute = ApiDeviceRoute + "/" + Service + "/" + Id + "/{" + Id + "}"
ApiDeviceByServiceNameRoute = ApiDeviceRoute + "/" + Service + "/" + Name + "/{" + Name + "}"
ApiDeviceNameCommandNameRoute = ApiDeviceByNameRoute + "/{" + Command + "}"
ApiProvisionWatcherRoute = ApiBase + "/provisionwatcher"
ApiAllProvisionWatcherRoute = ApiProvisionWatcherRoute + "/" + All
ApiProvisionWatcherByIdRoute = ApiProvisionWatcherRoute + "/" + Id + "/{" + Id + "}"
ApiProvisionWatcherByNameRoute = ApiProvisionWatcherRoute + "/" + Name + "/{" + Name + "}"
ApiProvisionWatcherByProfileNameRoute = ApiProvisionWatcherRoute + "/" + Profile + "/" + Name + "/{" + Name + "}"
ApiProvisionWatcherByServiceNameRoute = ApiProvisionWatcherRoute + "/" + Service + "/" + Name + "/{" + Name + "}"
ApiSubscriptionRoute = ApiBase + "/subscription"
ApiAllSubscriptionRoute = ApiSubscriptionRoute + "/" + All
ApiSubscriptionByNameRoute = ApiSubscriptionRoute + "/" + Name + "/{" + Name + "}"
ApiSubscriptionByCategoryRoute = ApiSubscriptionRoute + "/" + Category + "/{" + Category + "}"
ApiSubscriptionByLabelRoute = ApiSubscriptionRoute + "/" + Label + "/{" + Label + "}"
ApiSubscriptionByReceiverRoute = ApiSubscriptionRoute + "/" + Receiver + "/{" + Receiver + "}"
ApiNotificationCleanupRoute = ApiBase + "/cleanup"
ApiNotificationCleanupByAgeRoute = ApiBase + "/" + Cleanup + "/" + Age + "/{" + Age + "}"
ApiNotificationRoute = ApiBase + "/notification"
ApiNotificationByTimeRangeRoute = ApiNotificationRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiNotificationByAgeRoute = ApiNotificationRoute + "/" + Age + "/{" + Age + "}"
ApiNotificationByCategoryRoute = ApiNotificationRoute + "/" + Category + "/{" + Category + "}"
ApiNotificationByLabelRoute = ApiNotificationRoute + "/" + Label + "/{" + Label + "}"
ApiNotificationByIdRoute = ApiNotificationRoute + "/" + Id + "/{" + Id + "}"
ApiNotificationByStatusRoute = ApiNotificationRoute + "/" + Status + "/{" + Status + "}"
ApiNotificationBySubscriptionNameRoute = ApiNotificationRoute + "/" + Subscription + "/" + Name + "/{" + Name + "}"
ApiTransmissionRoute = ApiBase + "/transmission"
ApiTransmissionByIdRoute = ApiTransmissionRoute + "/" + Id + "/{" + Id + "}"
ApiTransmissionByAgeRoute = ApiTransmissionRoute + "/" + Age + "/{" + Age + "}"
ApiAllTransmissionRoute = ApiTransmissionRoute + "/" + All
ApiTransmissionBySubscriptionNameRoute = ApiTransmissionRoute + "/" + Subscription + "/" + Name + "/{" + Name + "}"
ApiTransmissionByTimeRangeRoute = ApiTransmissionRoute + "/" + Start + "/{" + Start + "}/" + End + "/{" + End + "}"
ApiTransmissionByStatusRoute = ApiTransmissionRoute + "/" + Status + "/{" + Status + "}"
ApiTransmissionByNotificationIdRoute = ApiTransmissionRoute + "/" + Notification + "/" + Id + "/{" + Id + "}"
ApiScheduleJobRoute = ApiBase + "/job"
ApiAllScheduleJobRoute = ApiScheduleJobRoute + "/" + All
ApiScheduleJobByNameRoute = ApiScheduleJobRoute + "/" + Name + "/{" + Name + "}"
ApiTriggerScheduleJobRoute = ApiScheduleJobRoute + "/" + Trigger
ApiTriggerScheduleJobByNameRoute = ApiScheduleJobRoute + "/" + Trigger + "/" + Name + "/{" + Name + "}"
ApiScheduleActionRecordRoute = ApiBase + "/scheduleactionrecord"
ApiAllScheduleActionRecordRoute = ApiScheduleActionRecordRoute + "/" + All
ApiLatestScheduleActionRecordByJobNameRoute = ApiScheduleActionRecordRoute + "/" + Latest + "/" + Job + "/" + Name + "/{" + Name + "}"
ApiScheduleActionRecordRouteByStatusRoute = ApiScheduleActionRecordRoute + "/" + Status + "/{" + Status + "}"
ApiScheduleActionRecordRouteByJobNameRoute = ApiScheduleActionRecordRoute + "/" + Job + "/" + Name + "/{" + Name + "}"
ApiScheduleActionRecordByJobNameAndStatusRoute = ApiScheduleActionRecordRoute + "/" + Job + "/" + Name + "/{" + Name + "}/" + Status + "/{" + Status + "}"
ApiConfigRoute = ApiBase + "/config"
ApiPingRoute = ApiBase + "/ping"
ApiVersionRoute = ApiBase + "/version"
ApiSecretRoute = ApiBase + "/secret"
ApiUnitsOfMeasureRoute = ApiBase + "/uom"
ApiDeviceCallbackRoute = ApiBase + "/callback/device"
ApiDeviceCallbackNameRoute = ApiBase + "/callback/device/name/{name}"
ApiProfileCallbackRoute = ApiBase + "/callback/profile"
ApiProfileCallbackNameRoute = ApiBase + "/callback/profile/name/{name}"
ApiWatcherCallbackRoute = ApiBase + "/callback/watcher"
ApiWatcherCallbackNameRoute = ApiBase + "/callback/watcher/name/{name}"
ApiServiceCallbackRoute = ApiBase + "/callback/service"
ApiDiscoveryRoute = ApiBase + "/discovery"
ApiDeviceValidationRoute = ApiBase + "/validate/device"
ApiProfileScanRoute = ApiBase + "/profilescan"
ApiDiscoveryByIdRoute = ApiDiscoveryRoute + "/" + RequestId + "/{" + RequestId + "}"
ApiProfileScanByDeviceNameRoute = ApiProfileScanRoute + "/" + Device + "/" + Name + "/{" + Name + "}"
ApiSystemRoute = ApiBase + "/system"
ApiOperationRoute = ApiSystemRoute + "/operation"
ApiHealthRoute = ApiSystemRoute + "/health"
ApiMultiConfigRoute = ApiSystemRoute + "/config"
ApiKVSRoute = ApiBase + "/kvs"
ApiKVSByKeyRoute = ApiKVSRoute + "/" + Key + "/{" + Key + "}"
ApiRegisterRoute = ApiBase + "/registry"
ApiAllRegistrationsRoute = ApiRegisterRoute + "/" + All
ApiRegistrationByServiceIdRoute = ApiRegisterRoute + "/" + ServiceId + "/{" + ServiceId + "}"
)
// Constants related to defined url path names and parameters in the v3 service APIs
const (
All = "all"
Id = "id"
Ids = "ids"
Created = "created"
Modified = "modified"
Pushed = "pushed"
Origin = "origin"
Count = "count"
Device = "device"
DeviceId = "deviceId"
DeviceName = "deviceName"
DeviceCommand = "deviceCommand"
Check = "check"
Profile = "profile"
Resource = "resource"
RequestId = "requestId"
Service = "service"
Services = "services"
Command = "command"
ProfileName = "profileName"
SourceName = "sourceName"
ServiceName = "serviceName"
ResourceName = "resourceName"
ResourceNames = "resourceNames"
CommandName = "commandName"
Start = "start"
End = "end"
Age = "age"
Scrub = "scrub"
Type = "type"
Name = "name"
Label = "label"
Manufacturer = "manufacturer"
Model = "model"
ValueType = "valueType"
Category = "category"
Receiver = "receiver"
Subscription = "subscription"
Notification = "notification"
Target = "target"
Status = "status"
Cleanup = "cleanup"
Sender = "sender"
Severity = "severity"
Interval = "interval"
Key = "key"
ServiceId = "serviceId"
Job = "job"
Trigger = "trigger"
Latest = "latest"
Ack = "ack"
Acknowledge = "acknowledge"
Unacknowledge = "unacknowledge"
Offset = "offset" //query string to specify the number of items to skip before starting to collect the result set.
Limit = "limit" //query string to specify the numbers of items to return
Labels = "labels" //query string to specify associated user-defined labels for querying a given object. More than one label may be specified via a comma-delimited list
PushEvent = "ds-pushevent" //query string to specify if an event should be pushed to the EdgeX system
ReturnEvent = "ds-returnevent" //query string to specify if an event should be returned from device service
RegexCommand = "ds-regexcmd" //query string to specify if the command name is in regular expression format
DescendantsOf = "descendantsOf" //Limit returned devices to those who have parent, grandparent, etc. of the given device name
MaxLevels = "maxLevels" //Limit returned devices to this many levels below 'descendantsOf' (0=unlimited)
Flatten = "flatten" //query string to specify if the request json payload should be flattened to update multiple keys with the same prefix
KeyOnly = "keyOnly" //query string to specify if the response will only return the keys of the specified query key prefix, without values and metadata
Plaintext = "plaintext" //query string to specify if the response will return the stored plain text value of the key(s) without any encoding
Deregistered = "deregistered" //query string to specify if the response will return the registries of deregistered services
)
// Constants related to the default value of query strings in the v3 service APIs
const (
DefaultOffset = 0
DefaultLimit = 20
CommaSeparator = ","
ValueTrue = "true"
ValueFalse = "false"
)
// Constants related to Reading ValueTypes
const (
ValueTypeBool = "Bool"
ValueTypeString = "String"
ValueTypeUint8 = "Uint8"
ValueTypeUint16 = "Uint16"
ValueTypeUint32 = "Uint32"
ValueTypeUint64 = "Uint64"
ValueTypeInt8 = "Int8"
ValueTypeInt16 = "Int16"
ValueTypeInt32 = "Int32"
ValueTypeInt64 = "Int64"
ValueTypeFloat32 = "Float32"
ValueTypeFloat64 = "Float64"
ValueTypeBinary = "Binary"
ValueTypeBoolArray = "BoolArray"
ValueTypeStringArray = "StringArray"
ValueTypeUint8Array = "Uint8Array"
ValueTypeUint16Array = "Uint16Array"
ValueTypeUint32Array = "Uint32Array"
ValueTypeUint64Array = "Uint64Array"
ValueTypeInt8Array = "Int8Array"
ValueTypeInt16Array = "Int16Array"
ValueTypeInt32Array = "Int32Array"
ValueTypeInt64Array = "Int64Array"
ValueTypeFloat32Array = "Float32Array"
ValueTypeFloat64Array = "Float64Array"
ValueTypeObject = "Object"
ValueTypeObjectArray = "ObjectArray"
)
// Constants related to configuration file's map key
const (
Primary = "Primary"
Password = "Password"
)
// Constants for Address
const (
// Type
REST = "REST"
MQTT = "MQTT"
EMAIL = "EMAIL"
ZeroMQ = "ZeroMQ"
HTTP = "http"
TCP = "tcp"
TCPS = "tcps"
)
// Constants for SMA Operation Action
const (
ActionStart = "start"
ActionRestart = "restart"
ActionStop = "stop"
)
// Constants for DeviceProfile
const (
ReadWrite_R = "R"
ReadWrite_W = "W"
ReadWrite_RW = "RW"
ReadWrite_WR = "WR"
)
// Constant for ScheduleJob
const (
DefInterval = "INTERVAL"
DefCron = "CRON"
ActionEdgeXMessageBus = "EDGEXMESSAGEBUS"
ActionREST = "REST"
ActionDeviceControl = "DEVICECONTROL"
)
// Constants for Edgex Environment variable
const (
EnvEncodeAllEvents = "EDGEX_ENCODE_ALL_EVENTS_CBOR"
)
// Miscellaneous constants
const (
ClientMonitorDefault = 15000 // Defaults the interval at which a given service client will refresh its endpoint from the Registry, if used
CorrelationHeader = "X-Correlation-ID" // Sets the key of the Correlation ID HTTP header
)
// Constants related to how services identify themselves in the Service Registry
const (
CoreCommandServiceKey = "core-command"
CoreDataServiceKey = "core-data"
CoreMetaDataServiceKey = "core-metadata"
CoreCommonConfigServiceKey = "core-common-config-bootstrapper"
CoreKeeperServiceKey = "core-keeper"
SupportLoggingServiceKey = "support-logging"
SupportNotificationsServiceKey = "support-notifications"
SupportSchedulerServiceKey = "support-scheduler"
SecuritySecretStoreSetupServiceKey = "security-secretstore-setup"
SecurityProxyAuthServiceKey = "security-proxy-auth"
SecurityProxySetupServiceKey = "security-proxy-setup"
SecurityFileTokenProviderServiceKey = "security-file-token-provider"
SecurityBootstrapperKey = "security-bootstrapper"
SecurityBootstrapperPostgresKey = "security-bootstrapper-postgres"
SecurityBootstrapperRedisKey = "security-bootstrapper-redis"
SecuritySpiffeTokenProviderKey = "security-spiffe-token-provider" // nolint:gosec
)
// Constants related to the possible content types supported by the APIs
const (
Accept = "Accept"
ContentType = "Content-Type"
ContentLength = "Content-Length"
ContentTypeCBOR = "application/cbor"
ContentTypeJSON = "application/json"
ContentTypeTOML = "application/toml"
ContentTypeYAML = "application/x-yaml"
ContentTypeText = "text/plain"
ContentTypeXML = "application/xml"
)
// Constants related to System Events
const (
DeviceSystemEventType = "device"
DeviceProfileSystemEventType = "deviceprofile"
DeviceServiceSystemEventType = "deviceservice"
ProvisionWatcherSystemEventType = "provisionwatcher"
SystemEventActionAdd = "add"
SystemEventActionUpdate = "update"
SystemEventActionDelete = "delete"
SystemEventActionDiscovery = "discovery"
SystemEventActionProfileScan = "profilescan"
)
const (
ConfigStemAll = "edgex/v4" // Version never changes during minor releases so v3 is more appropriate than 3.0
ConfigStemApp = ConfigStemAll
ConfigStemCore = ConfigStemAll
ConfigStemDevice = ConfigStemAll
ConfigStemSecurity = ConfigStemAll
)
const (
CommandQueryRequestTopicKey = "CommandQueryRequestTopic" // #nosec G101
CommandQueryResponseTopicKey = "CommandQueryResponseTopic"
CommandRequestTopicKey = "CommandRequestTopic"
CommandResponseTopicPrefixKey = "CommandResponseTopicPrefix"
)
// MessageBus Topics
const (
// Common Topics
DefaultBaseTopic = "edgex" // Used if the base topic is not specified in MessageBus configuration
EventsPublishTopic = "events" // <ServiceType>/<DeviceServiceName>/<ProfileName>/<DeviceName>/<SourceName> are appended
ResponseTopic = "response" // <ServiceName>/<RequestId> are prepended
MetricsPublishTopic = "telemetry" // <ServiceName>/<MetricName> are prepended
SystemEventPublishTopic = "system-events" // <SourceServiceName>/<SystemEventType>/<SystemEventAction><OwnerServiceName>/<ProfileName>
// Core Data Topics
CoreDataEventSubscribeTopic = "events/device/#"
// Core Command Topics
CoreCommandDeviceRequestPublishTopic = "device/command/request" // <DeviceServiceName>/<DeviceName>/<CommandName>/<CommandMethod> are appended
CoreCommandRequestSubscribeTopic = "core/command/request/#"
CoreCommandQueryRequestSubscribeTopic = "core/commandquery/request/#"
// Command Client Topics
CoreCommandQueryRequestPublishTopic = "core/commandquery/request" // <deviceName>|all is prepended
CoreCommandRequestPublishTopic = "core/command/request" // <DeviceName>/<CommandName>/<CommandMethod> are appended
// Support Notifications
// No Topics Yet
// Support Scheduler
// No Topics Yet
// Device Services Topics
CommandRequestSubscribeTopic = "device/command/request" // <DeviceServiceName>/# is appended <
MetadataSystemEventSubscribeTopic = "system-events/core-metadata/+/+" // <DeviceServiceName>/# is appended
ValidateDeviceSubscribeTopic = "validate/device" // <DeviceServiceName> is pre-pended
// App Service Topics
// App Service topics remain configurable inorder to filter by subscription.
)