dev.azure.com/aidainnovazione0090/DeviceManager/_git/go-mod-core-contracts@v1.0.2/common/constants.go (about) 1 // 2 // Copyright (C) 2020-2023 IOTech Ltd 3 // Copyright (C) 2023 Intel Corporation 4 // 5 // SPDX-License-Identifier: Apache-2.0 6 7 package common 8 9 // Constants related to defined routes in the v3 service APIs 10 const ( 11 ApiVersion = "v3" 12 ApiBase = "/api/v3" 13 14 ApiEventRoute = ApiBase + "/event" 15 ApiEventServiceNameProfileNameDeviceNameSourceNameRoute = ApiEventRoute + "/:" + ServiceName + "/:" + ProfileName + "/:" + DeviceName + "/:" + SourceName 16 ApiAllEventRoute = ApiEventRoute + "/" + All 17 ApiEventIdRoute = ApiEventRoute + "/" + Id + "/:" + Id 18 ApiEventCountRoute = ApiEventRoute + "/" + Count 19 ApiEventCountByDeviceNameRoute = ApiEventCountRoute + "/" + Device + "/" + Name + "/:" + Name 20 ApiEventByDeviceNameRoute = ApiEventRoute + "/" + Device + "/" + Name + "/:" + Name 21 ApiEventByTimeRangeRoute = ApiEventRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 22 ApiEventByAgeRoute = ApiEventRoute + "/" + Age + "/:" + Age 23 24 ApiReadingRoute = ApiBase + "/reading" 25 ApiAllReadingRoute = ApiReadingRoute + "/" + All 26 ApiReadingCountRoute = ApiReadingRoute + "/" + Count 27 ApiReadingCountByDeviceNameRoute = ApiReadingCountRoute + "/" + Device + "/" + Name + "/:" + Name 28 ApiReadingByDeviceNameRoute = ApiReadingRoute + "/" + Device + "/" + Name + "/:" + Name 29 ApiReadingByResourceNameRoute = ApiReadingRoute + "/" + ResourceName + "/:" + ResourceName 30 ApiReadingByTimeRangeRoute = ApiReadingRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 31 ApiReadingByResourceNameAndTimeRangeRoute = ApiReadingByResourceNameRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 32 ApiReadingByDeviceNameAndResourceNameRoute = ApiReadingRoute + "/" + Device + "/" + Name + "/:" + Name + "/" + ResourceName + "/:" + ResourceName 33 ApiReadingByDeviceNameAndResourceNameAndTimeRangeRoute = ApiReadingByDeviceNameAndResourceNameRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 34 ApiReadingByDeviceNameAndTimeRangeRoute = ApiReadingByDeviceNameRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 35 36 ApiDeviceStatusRoute = ApiBase + "/devicestatus" 37 ApiAllDeviceStatus = ApiDeviceStatusRoute + "/" + All 38 ApiDeviceStatusByIdRoute = ApiDeviceStatusRoute + "/" + Name + "/:" + Name 39 40 ApiDeviceStatusHistoryRoute = ApiBase + "/devicestatushistory" 41 ApiAllDeviceStatusHistory = ApiDeviceStatusHistoryRoute + "/" + All 42 ApiDeviceStatusHistoryByDeviceNameRoute = ApiDeviceStatusHistoryRoute + "/" + Name + "/:" + Name 43 ApiDeviceStatusHistoryByTimeRangeRoute = ApiDeviceStatusHistoryRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 44 ApiDeviceStatusHistoryByDeviceNameAndTimeRangeRoute = ApiDeviceStatusHistoryByDeviceNameRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 45 46 ApiDeviceProfileRoute = ApiBase + "/deviceprofile" 47 ApiDeviceProfileBasicInfoRoute = ApiDeviceProfileRoute + "/basicinfo" 48 ApiDeviceProfileDeviceCommandRoute = ApiDeviceProfileRoute + "/" + DeviceCommand 49 ApiDeviceProfileResourceRoute = ApiDeviceProfileRoute + "/" + Resource 50 ApiDeviceProfileUploadFileRoute = ApiDeviceProfileRoute + "/uploadfile" 51 ApiDeviceProfileByNameRoute = ApiDeviceProfileRoute + "/" + Name + "/:" + Name 52 ApiDeviceProfileDeviceCommandByNameRoute = ApiDeviceProfileByNameRoute + "/" + DeviceCommand + "/:" + CommandName 53 ApiDeviceProfileResourceByNameRoute = ApiDeviceProfileByNameRoute + "/" + Resource + "/:" + ResourceName 54 ApiDeviceProfileByIdRoute = ApiDeviceProfileRoute + "/" + Id + "/:" + Id 55 ApiAllDeviceProfileRoute = ApiDeviceProfileRoute + "/" + All 56 ApiDeviceProfileByManufacturerRoute = ApiDeviceProfileRoute + "/" + Manufacturer + "/:" + Manufacturer 57 ApiDeviceProfileByModelRoute = ApiDeviceProfileRoute + "/" + Model + "/:" + Model 58 ApiDeviceProfileByManufacturerAndModelRoute = ApiDeviceProfileRoute + "/" + Manufacturer + "/:" + Manufacturer + "/" + Model + "/:" + Model 59 ApiDeviceProfileNameListRoute = ApiDeviceProfileRoute + "/" + List + "/" + Name 60 ApiDeviceProfileManufacturerListRoute = ApiDeviceProfileRoute + "/" + List + "/" + Manufacturer 61 ApiDeviceProfileModelListRoute = ApiDeviceProfileRoute + "/" + List + "/" + Model 62 63 ApiDeviceResourceRoute = ApiBase + "/deviceresource" 64 ApiDeviceResourceByProfileAndResourceRoute = ApiDeviceResourceRoute + "/" + Profile + "/:" + ProfileName + "/" + Resource + "/:" + ResourceName 65 66 ApiDeviceServiceRoute = ApiBase + "/deviceservice" 67 ApiAllDeviceServiceRoute = ApiDeviceServiceRoute + "/" + All 68 ApiDeviceServiceByNameRoute = ApiDeviceServiceRoute + "/" + Name + "/:" + Name 69 ApiDeviceServiceByIdRoute = ApiDeviceServiceRoute + "/" + Id + "/:" + Id 70 71 ApiDeviceRoute = ApiBase + "/device" 72 ApiAllDeviceRoute = ApiDeviceRoute + "/" + All 73 ApiDeviceIdExistsRoute = ApiDeviceRoute + "/" + Check + "/" + Id + "/:" + Id 74 ApiDeviceNameExistsRoute = ApiDeviceRoute + "/" + Check + "/" + Name + "/:" + Name 75 ApiDeviceByIdRoute = ApiDeviceRoute + "/" + Id + "/:" + Id 76 ApiDeviceByNameRoute = ApiDeviceRoute + "/" + Name + "/:" + Name 77 ApiDeviceByNameLogicalRoute = ApiDeviceRoute + "/" + Logical + "/" + Name + "/:" + Name 78 ApiDeviceByProfileIdRoute = ApiDeviceRoute + "/" + Profile + "/" + Id + "/:" + Id 79 ApiDeviceByProfileNameRoute = ApiDeviceRoute + "/" + Profile + "/" + Name + "/:" + Name 80 ApiDeviceByServiceIdRoute = ApiDeviceRoute + "/" + Service + "/" + Id + "/:" + Id 81 ApiDeviceByServiceNameRoute = ApiDeviceRoute + "/" + Service + "/" + Name + "/:" + Name 82 ApiDeviceNameCommandNameRoute = ApiDeviceByNameRoute + "/:" + Command 83 84 ApiApplicationRoute = ApiBase + "/application" 85 ApiAllApplicationRoute = ApiApplicationRoute + "/" + All 86 87 ApiProvisionWatcherRoute = ApiBase + "/provisionwatcher" 88 ApiAllProvisionWatcherRoute = ApiProvisionWatcherRoute + "/" + All 89 ApiProvisionWatcherByIdRoute = ApiProvisionWatcherRoute + "/" + Id + "/:" + Id 90 ApiProvisionWatcherByNameRoute = ApiProvisionWatcherRoute + "/" + Name + "/:" + Name 91 ApiProvisionWatcherByProfileNameRoute = ApiProvisionWatcherRoute + "/" + Profile + "/" + Name + "/:" + Name 92 ApiProvisionWatcherByServiceNameRoute = ApiProvisionWatcherRoute + "/" + Service + "/" + Name + "/:" + Name 93 94 ApiSubscriptionRoute = ApiBase + "/subscription" 95 ApiAllSubscriptionRoute = ApiSubscriptionRoute + "/" + All 96 ApiSubscriptionByNameRoute = ApiSubscriptionRoute + "/" + Name + "/:" + Name 97 ApiSubscriptionByCategoryRoute = ApiSubscriptionRoute + "/" + Category + "/:" + Category 98 ApiSubscriptionByLabelRoute = ApiSubscriptionRoute + "/" + Label + "/:" + Label 99 ApiSubscriptionByReceiverRoute = ApiSubscriptionRoute + "/" + Receiver + "/:" + Receiver 100 101 ApiNotificationCleanupRoute = ApiBase + "/cleanup" 102 ApiNotificationCleanupByAgeRoute = ApiBase + "/" + Cleanup + "/" + Age + "/:" + Age 103 ApiNotificationRoute = ApiBase + "/notification" 104 ApiNotificationByTimeRangeRoute = ApiNotificationRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 105 ApiNotificationByAgeRoute = ApiNotificationRoute + "/" + Age + "/:" + Age 106 ApiNotificationByCategoryRoute = ApiNotificationRoute + "/" + Category + "/:" + Category 107 ApiNotificationByLabelRoute = ApiNotificationRoute + "/" + Label + "/:" + Label 108 ApiNotificationByIdRoute = ApiNotificationRoute + "/" + Id + "/:" + Id 109 ApiNotificationByStatusRoute = ApiNotificationRoute + "/" + Status + "/:" + Status 110 ApiNotificationBySubscriptionNameRoute = ApiNotificationRoute + "/" + Subscription + "/" + Name + "/:" + Name 111 112 ApiTransmissionRoute = ApiBase + "/transmission" 113 ApiTransmissionByIdRoute = ApiTransmissionRoute + "/" + Id + "/:" + Id 114 ApiTransmissionByAgeRoute = ApiTransmissionRoute + "/" + Age + "/:" + Age 115 ApiAllTransmissionRoute = ApiTransmissionRoute + "/" + All 116 ApiTransmissionBySubscriptionNameRoute = ApiTransmissionRoute + "/" + Subscription + "/" + Name + "/:" + Name 117 ApiTransmissionByTimeRangeRoute = ApiTransmissionRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 118 ApiTransmissionByStatusRoute = ApiTransmissionRoute + "/" + Status + "/:" + Status 119 ApiTransmissionByNotificationIdRoute = ApiTransmissionRoute + "/" + Notification + "/" + Id + "/:" + Id 120 121 ApiConfigRoute = ApiBase + "/config" 122 ApiPingRoute = ApiBase + "/ping" 123 ApiVersionRoute = ApiBase + "/version" 124 ApiSecretRoute = ApiBase + "/secret" 125 ApiUnitsOfMeasureRoute = ApiBase + "/uom" 126 127 ApiDeviceCallbackRoute = ApiBase + "/callback/device" 128 ApiDeviceCallbackNameRoute = ApiBase + "/callback/device/name/:name}" 129 ApiProfileCallbackRoute = ApiBase + "/callback/profile" 130 ApiProfileCallbackNameRoute = ApiBase + "/callback/profile/name/:name}" 131 ApiWatcherCallbackRoute = ApiBase + "/callback/watcher" 132 ApiWatcherCallbackNameRoute = ApiBase + "/callback/watcher/name/:name}" 133 ApiServiceCallbackRoute = ApiBase + "/callback/service" 134 ApiDiscoveryRoute = ApiBase + "/discovery" 135 ApiDeviceValidationRoute = ApiBase + "/validate/device" 136 137 ApiIntervalRoute = ApiBase + "/interval" 138 ApiAllIntervalRoute = ApiIntervalRoute + "/" + All 139 ApiIntervalByNameRoute = ApiIntervalRoute + "/" + Name + "/:" + Name 140 ApiIntervalActionRoute = ApiBase + "/intervalaction" 141 ApiAllIntervalActionRoute = ApiIntervalActionRoute + "/" + All 142 ApiIntervalActionByNameRoute = ApiIntervalActionRoute + "/" + Name + "/:" + Name 143 ApiIntervalActionByTargetRoute = ApiIntervalActionRoute + "/" + Target + "/:" + Target 144 145 ApiSystemRoute = ApiBase + "/system" 146 ApiOperationRoute = ApiSystemRoute + "/operation" 147 ApiHealthRoute = ApiSystemRoute + "/health" 148 ApiMultiConfigRoute = ApiSystemRoute + "/config" 149 150 ApiDeviceHistoryRoute = ApiBase + "/devicehistory" 151 ApiAllDeviceHistoryRoute = ApiDeviceHistoryRoute + "/" + All 152 ApiDeviceHistoryByNameRoute = ApiDeviceHistoryRoute + "/" + Name + "/:" + Name 153 ApiDeviceHistoryByNameVersionRoute = ApiDeviceHistoryByNameRoute + "/" + Version + "/:" + Version 154 ApiDeviceHistoryByDate = ApiDeviceHistoryRoute + "/" + Date + "/:" + Date 155 ApiDeviceHistoryByNameTimeRangeRoute = ApiDeviceHistoryByNameRoute + "/" + Start + "/:" + Start + "/" + End + "/:" + End 156 ) 157 158 // Constants related to defined url path names and parameters in the v3 service APIs 159 const ( 160 All = "all" 161 Id = "id" 162 Created = "created" 163 Modified = "modified" 164 Pushed = "pushed" 165 Origin = "origin" 166 Count = "count" 167 Device = "device" 168 DeviceId = "deviceId" 169 DeviceName = "deviceName" 170 DeviceCommand = "deviceCommand" 171 Check = "check" 172 Profile = "profile" 173 Resource = "resource" 174 Service = "service" 175 Services = "services" 176 Command = "command" 177 ProfileName = "profileName" 178 SourceName = "sourceName" 179 ServiceName = "serviceName" 180 ResourceName = "resourceName" 181 ResourceNames = "resourceNames" 182 CommandName = "commandName" 183 Start = "start" 184 End = "end" 185 Age = "age" 186 Scrub = "scrub" 187 Type = "type" 188 Name = "name" 189 Label = "label" 190 Manufacturer = "manufacturer" 191 Model = "model" 192 ValueType = "valueType" 193 Category = "category" 194 Receiver = "receiver" 195 Subscription = "subscription" 196 Notification = "notification" 197 Target = "target" 198 Status = "status" 199 Cleanup = "cleanup" 200 Sender = "sender" 201 Severity = "severity" 202 Interval = "interval" 203 Date = "date" 204 Logical = "logical" 205 Alarm = "alarm" 206 StatusHistory = "statusHistory" 207 Version = "version" 208 Alarms = "alarms" 209 List = "list" 210 211 Offset = "offset" //query string to specify the number of items to skip before starting to collect the result set. 212 Limit = "limit" //query string to specify the numbers of items to return 213 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 214 PushEvent = "ds-pushevent" //query string to specify if an event should be pushed to the EdgeX system 215 ReturnEvent = "ds-returnevent" //query string to specify if an event should be returned from device service 216 RegexCommand = "ds-regexcmd" //query string to specify if the command name is in regular expression format 217 ) 218 219 // Constants related to the default value of query strings in the v3 service APIs 220 const ( 221 DefaultOffset = 0 222 DefaultLimit = 20 223 CommaSeparator = "," 224 ValueTrue = "true" 225 ValueFalse = "false" 226 ) 227 228 // Constants related to Reading ValueTypes 229 const ( 230 ValueTypeBool = "Bool" 231 ValueTypeString = "String" 232 ValueTypeUint8 = "Uint8" 233 ValueTypeUint16 = "Uint16" 234 ValueTypeUint32 = "Uint32" 235 ValueTypeUint64 = "Uint64" 236 ValueTypeInt8 = "Int8" 237 ValueTypeInt16 = "Int16" 238 ValueTypeInt32 = "Int32" 239 ValueTypeInt64 = "Int64" 240 ValueTypeFloat32 = "Float32" 241 ValueTypeFloat64 = "Float64" 242 ValueTypeBinary = "Binary" 243 ValueTypeBoolArray = "BoolArray" 244 ValueTypeStringArray = "StringArray" 245 ValueTypeUint8Array = "Uint8Array" 246 ValueTypeUint16Array = "Uint16Array" 247 ValueTypeUint32Array = "Uint32Array" 248 ValueTypeUint64Array = "Uint64Array" 249 ValueTypeInt8Array = "Int8Array" 250 ValueTypeInt16Array = "Int16Array" 251 ValueTypeInt32Array = "Int32Array" 252 ValueTypeInt64Array = "Int64Array" 253 ValueTypeFloat32Array = "Float32Array" 254 ValueTypeFloat64Array = "Float64Array" 255 ValueTypeObject = "Object" 256 ) 257 258 // Constants related to configuration file's map key 259 const ( 260 Primary = "Primary" 261 Password = "Password" 262 ) 263 264 // Constants for Address 265 const ( 266 // Type 267 REST = "REST" 268 MQTT = "MQTT" 269 EMAIL = "EMAIL" 270 ) 271 272 // Constants for SMA Operation Action 273 const ( 274 ActionStart = "start" 275 ActionRestart = "restart" 276 ActionStop = "stop" 277 ) 278 279 // Constants for DeviceProfile 280 const ( 281 ReadWrite_R = "R" 282 ReadWrite_W = "W" 283 ReadWrite_RW = "RW" 284 ReadWrite_WR = "WR" 285 ) 286 287 // Constants for Edgex Environment variable 288 const ( 289 EnvEncodeAllEvents = "EDGEX_ENCODE_ALL_EVENTS_CBOR" 290 ) 291 292 type UsernameType string 293 294 // Miscellaneous constants 295 const ( 296 ClientMonitorDefault = 15000 // Defaults the interval at which a given service client will refresh its endpoint from the Registry, if used 297 CorrelationHeader = "X-Correlation-ID" // Sets the key of the Correlation ID HTTP header 298 Username UsernameType = "username" 299 ) 300 301 // Constants related to how services identify themselves in the Service Registry 302 const ( 303 CoreCommandServiceKey = "core-command" 304 CoreDataServiceKey = "core-data" 305 CoreMetaDataServiceKey = "core-metadata" 306 CoreCommonConfigServiceKey = "core-common-config-bootstrapper" 307 SupportLoggingServiceKey = "support-logging" 308 SupportNotificationsServiceKey = "support-notifications" 309 SystemManagementAgentServiceKey = "sys-mgmt-agent" 310 SupportSchedulerServiceKey = "support-scheduler" 311 SecuritySecretStoreSetupServiceKey = "security-secretstore-setup" 312 SecurityProxyAuthServiceKey = "security-proxy-auth" 313 SecurityProxySetupServiceKey = "security-proxy-setup" 314 SecurityFileTokenProviderServiceKey = "security-file-token-provider" 315 SecurityBootstrapperKey = "security-bootstrapper" 316 SecurityBootstrapperRedisKey = "security-bootstrapper-redis" 317 SecuritySpiffeTokenProviderKey = "security-spiffe-token-provider" // nolint:gosec 318 ) 319 320 // Constants related to the possible content types supported by the APIs 321 const ( 322 Accept = "Accept" 323 ContentType = "Content-Type" 324 ContentLength = "Content-Length" 325 ContentTypeCBOR = "application/cbor" 326 ContentTypeJSON = "application/json" 327 ContentTypeTOML = "application/toml" 328 ContentTypeYAML = "application/x-yaml" 329 ContentTypeText = "text/plain" 330 ContentTypeXML = "application/xml" 331 ) 332 333 // Constants related to System Events 334 const ( 335 DeviceSystemEventType = "device" 336 DeviceProfileSystemEventType = "deviceprofile" 337 DeviceServiceSystemEventType = "deviceservice" 338 ProvisionWatcherSystemEventType = "provisionwatcher" 339 SystemEventActionAdd = "add" 340 SystemEventActionUpdate = "update" 341 SystemEventActionDelete = "delete" 342 ) 343 344 const ( 345 ConfigStemAll = "edgex/v3" // Version never changes during minor releases so v3 is more appropriate than 3.0 346 ConfigStemApp = ConfigStemAll 347 ConfigStemCore = ConfigStemAll 348 ConfigStemDevice = ConfigStemAll 349 ConfigStemSecurity = ConfigStemAll 350 ) 351 352 const ( 353 CommandQueryRequestTopicKey = "CommandQueryRequestTopic" // #nosec G101 354 CommandQueryResponseTopicKey = "CommandQueryResponseTopic" 355 CommandRequestTopicKey = "CommandRequestTopic" 356 CommandResponseTopicPrefixKey = "CommandResponseTopicPrefix" 357 ) 358 359 // MessageBus Topics 360 const ( 361 362 // Common Topics 363 DefaultBaseTopic = "" // Used if the base topic is not specified in MessageBus configuration 364 EventsPublishTopic = "events" // <ServiceType>/<DeviceServiceName>/<ProfileName>/<DeviceName>/<SourceName> are appended 365 ResponseTopic = "response" // <ServiceName>/<RequestId> are prepended 366 MetricsPublishTopic = "telemetry" // <ServiceName>/<MetricName> are prepended 367 SystemEventPublishTopic = "system-events" // <SourceServiceName>/<SystemEventType>/<SystemEventAction><OwnerServiceName>/<ProfileName> 368 369 // Core Data Topics 370 CoreDataEventSubscribeTopic = "events/device/#" 371 CoreDataDeviceStatusPublishTopic = "edgex/status/device" //<deviceName> is appended 372 CoreDataDeviceStatusEventSubscribeTopic = "edgex/status/events/device/#" //<deviceName> is appended 373 CoreDataDeviceAlarmEventSubscribeTopic = "edgex/alarm/device/#" 374 // Core Command Topics 375 CoreCommandDeviceRequestPublishTopic = "device/command/request" // <DeviceServiceName>/<DeviceName>/<CommandName>/<CommandMethod> are appended 376 CoreCommandRequestSubscribeTopic = "core/command/request/#" 377 CoreCommandQueryRequestSubscribeTopic = "core/commandquery/request/#" 378 379 // Command Client Topics 380 CoreCommandQueryRequestPublishTopic = "core/commandquery/request" // <deviceName>|all is prepended 381 CoreCommandRequestPublishTopic = "core/command/request" // <DeviceName>/<CommandName>/<CommandMethod> are appended 382 383 // Support Notifications 384 // No Topics Yet 385 386 // Support Scheduler 387 // No Topics Yet 388 389 // Device Services Topics 390 CommandRequestSubscribeTopic = "device/command/request" // <DeviceServiceName>/# is appended < 391 MetadataSystemEventSubscribeTopic = "system-events/core-metadata/+/+" // <DeviceServiceName>/# is appended 392 ValidateDeviceSubscribeTopic = "validate/device" // <DeviceServiceName> is pre-pended 393 394 DeviceStatusEventPublishTopic = "edgex/status/events/device" //<deviceName> is appended 395 DeviceAlarmEventPublishTopic = "edgex/alarm/device" //<deviceName> is appended 396 // App Service Topics 397 // App Service topics remain configurable inorder to filter by subscription. 398 )