Skip to content

Commit 0a804be

Browse files
committed
docs: document the config MQTT channel and HTTP routes
Add the config channel to the MQTT topic reference (category table, telemetry data table, and a new Configuration section with a worked example), and the two GET /te/v1/entities/<service>/config[/<key>] routes to the entity HTTP API reference, cross-linked with each other. Signed-off-by: Albin Suresh <albin.suresh@cumulocity.com>
1 parent edc3b0b commit 0a804be

3 files changed

Lines changed: 96 additions & 2 deletions

File tree

docs/src/operate/entity-management/rest_api.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,69 @@ Remove all of the child device's twin data using a single request.
488488
curl -f -X DELETE http://localhost:8000/te/v1/entities/device/child01///twin
489489
```
490490

491+
## Get exposed configuration
492+
493+
Each entity that owns `tedge_config` settings (e.g. `tedge-agent`, or a cloud mapper such as
494+
`tedge-mapper-c8y`) publishes any setting explicitly marked exposable as a retained `config` MQTT
495+
message under its own service topic (see the [MQTT API reference](../../references/mqtt-api.md#configuration)).
496+
The agent collects these as an ordinary MQTT subscriber and serves them as a read-only view over HTTP.
497+
498+
This view is read-only: `PUT`, `PATCH`, and `DELETE` on a `config` resource path are rejected.
499+
Configuration can only be changed by its owning component, via `tedge config set` and a restart.
500+
501+
A configuration key that is not marked exposable and a key that does not exist at all are
502+
indistinguishable here: both return `404 Not Found`, so the response reveals nothing about which
503+
non-exposed settings exist.
504+
505+
### Get a single configuration value
506+
507+
**Endpoint**
508+
509+
```
510+
GET /te/v1/entities/{topic-id}/config/{key}
511+
```
512+
513+
**Response status codes**
514+
515+
* 200: OK
516+
* 404: Not Found (the key is not exposed, or does not exist)
517+
518+
#### Example: Get the agent's device.id setting
519+
520+
```sh
521+
curl http://localhost:8000/te/v1/entities/device/main/service/tedge-agent/config/device.id
522+
```
523+
524+
```text title="Response"
525+
my-device-01
526+
```
527+
528+
### Get all exposed configuration
529+
530+
**Endpoint**
531+
532+
```
533+
GET /te/v1/entities/{topic-id}/config
534+
```
535+
536+
**Response status codes**
537+
538+
* 200: OK
539+
* 404: Not Found
540+
541+
#### Example: Get all of a c8y mapper's exposed configuration
542+
543+
```sh
544+
curl http://localhost:8000/te/v1/entities/device/main/service/tedge-mapper-c8y/config
545+
```
546+
547+
```json title="Response"
548+
{
549+
"url": "example.cumulocity.com",
550+
"device.id": "my-device-01"
551+
}
552+
```
553+
491554
## Query entities
492555

493556
Get a list of entities which match given filter criteria.

docs/src/references/mqtt-api.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ The following is an overview of the channel categories which are available.
246246
| a | Alarms |
247247
| cmd | Commands |
248248
| twin | Entity twin metadata |
249+
| config | Exposed configuration values |
249250
| status | Service status |
250251
| signal | Signals |
251252

@@ -436,6 +437,7 @@ so that it can process them.
436437
| Events | `te/<identifier>/e/<event-type>` |
437438
| Alarms | `te/<identifier>/a/<alarm-type>` |
438439
| Twin | `te/<identifier>/twin/<data-type>` |
440+
| Configuration | `te/<identifier>/config/<key>` |
439441
| Status | `te/<identifier>/status/<target-type>` |
440442

441443
### Examples: With default device/service topic semantics
@@ -560,6 +562,35 @@ te/device/main///twin/device_OS
560562
}
561563
```
562564

565+
## Configuration
566+
567+
A service that owns a `tedge_config` setting (`tedge-agent` for core/device settings, each cloud
568+
mapper for its own cloud's settings) publishes any setting explicitly marked exposable as a retained
569+
`config` message under its own service topic, one message per value:
570+
571+
```text
572+
te/<service-identifier>/config/<key>
573+
```
574+
575+
`<key>` is the setting's `tedge config` key, kept as a single topic segment (not split on its `.`s), so
576+
it maps directly back to a `tedge config get <key>` invocation. A mapper strips its own cloud (and
577+
profile) qualifier from the key, since the service topic already scopes it: `c8y.url` is published as
578+
`url` under `.../service/tedge-mapper-c8y/config/url`.
579+
580+
```text title="Topic (retain=true)"
581+
te/device/main/service/tedge-agent/config/device.id
582+
```
583+
584+
```text title="Payload"
585+
my-device-01
586+
```
587+
588+
An empty payload means the value is unset, or was removed from configuration since the last time the
589+
owning service started. A setting is only published this way if it was explicitly marked exposable
590+
where it is defined; unmarked settings, including any secret (a private key, a PIN, a credential file
591+
path), are never published. See the [Entity Store REST API](../operate/entity-management/rest_api.md)
592+
for a read-only HTTP view of the same values.
593+
563594
## Commands
564595

565596
The topic scheme for commands can be visualized using the diagram below.

openspec/changes/expose-tedge-configs/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161

6262
## 10. Documentation
6363

64-
- [ ] 10.1 Document the `config` MQTT channel in the MQTT topic reference
65-
- [ ] 10.2 Document the two `config` HTTP routes in the entity HTTP API reference
64+
- [x] 10.1 Document the `config` MQTT channel in the MQTT topic reference
65+
- [x] 10.2 Document the two `config` HTTP routes in the entity HTTP API reference

0 commit comments

Comments
 (0)