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
|
# REST API Reference
## Collection type API
### Create collection type entities
You can create a new collection type entities. If the collection does not exist, it will automatically be created.
The following call to `POST /api/rest/collection/entity` creates a new entity with fields `name` and `description`.
```console
curl -X POST http://localhost:8081/api/rest/collection/entity --data @- <<'EOF' | jq .
{
"name": "Entity 1",
"description": "Description of entity 1"
}
EOF
```
Note that the created entity is returned, including the meta field `$fileName`.
```json
{
"$fileName": "9474f0eb-06d7-4fd8-b89e-0ce996962508.json",
"description": "Description of entity 1",
"name": "Entity 1"
}
```
To demonstrate other API capabilities, go ahead and create a second entity.
```console
curl -X POST http://localhost:8081/api/rest/collection/entity --data @- <<'EOF' | jq .
{
"name": "Entity 2",
"description": "Description of entity 2"
}
EOF
```
```json
{
"$fileName": "ccccc18c-f3dc-4f98-b4d2-290ef76adb6b.json",
"description": "Description of entity 2",
"name": "Entity 2"
}
```
### Retrieving a collection type's schema
With having entities, a collection schema is automatically inferred, and can be queried.
```console
curl http://localhost:8081/api/rest/collection/entity/schema | jq .
```
As one would expect, the schema lists the fields `name`, `description` as required fields of type `string`.
```json
{
"$id": "entity.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"$fileName": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"$fileName",
"description",
"name"
],
"title": "entity",
"type": "object"
}
```
### Retrieving a single collection entity
Single collection entities can be retrieved using their unique `$fileName` identifier.
```console
curl http://localhost:8081/api/rest/collection/entity/9474f0eb-06d7-4fd8-b89e-0ce996962508.json | jq .
```
TODO do not return list
```json
[
{
"$fileName": "9474f0eb-06d7-4fd8-b89e-0ce996962508.json",
"description": "Description of entity 1",
"name": "Entity 1"
}
]
```
### Retrieving all collection entities
All collection entities can be requested as well.
```console
curl http://localhost:8081/api/rest/collection/entity | jq .
```
```json
[
{
"$fileName": "9474f0eb-06d7-4fd8-b89e-0ce996962508.json",
"description": "Description of entity 1",
"name": "Entity 1"
},
{
"$fileName": "ccccc18c-f3dc-4f98-b4d2-290ef76adb6b.json",
"description": "Description of entity 2",
"name": "Entity 2"
}
]
```
### Updating a collection entity
Updating a collection entity is possible by send only select fields.
```console
curl -X PUT http://localhost:8081/api/rest/collection/entity/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b.json --data @- <<'EOF' | jq .
{
"description": "Entity 2's description"
}
EOF
```
The endpoint returns the full, updated entity.
TODO return full, updated entity, return single entity
```json
[]
```
Fields can be deleted setting them their values to `null`.
```console
curl -X PUT http://localhost:8081/api/rest/collection/entity/ccccc18c-f3dc-4f98-b4d2-290ef76adb6b.json --data @- <<'EOF' | jq .
{
"description": null
}
EOF
```
Again, the response contains the full entity after the update.
TODO return full, updated entity, return single entity
```json
[]
```
## Retrieving the global schema version
Because we have deleted a required field, we have changed the `entity` collectiontype's schema.
The collection type's schema endpoint reflects that change.
```console
curl http://localhost:8081/api/rest/collection/entity/schema | jq .
```
```json
{
"$id": "entity.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"$fileName": {
"type": "string"
},
"description": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"$fileName",
"name"
],
"title": "entity",
"type": "object"
}
```
What's more, the global schema version records this backwards-incompatible (breaking) change.
```console
curl http://localhost:8081/api/rest/schemaVersion | jq .
```
```json
"1.2.0"
```
### Deleting collection entities
```console
curl -X DELETE http://localhost:8081/api/rest/collection/entity/9474f0eb-06d7-4fd8-b89e-0ce996962508.json | jq .
```
TODO return deleted entity, only one entity
```json
[]
```
|