Skip to content

Commit 53ad312

Browse files
Merge pull request #3609 from aleksandrychev/ENT-12095_3.27
ENT-12905: Added Autocomplete API documentation (3.27)
2 parents 74872dc + 03938a0 commit 53ad312

1 file changed

Lines changed: 202 additions & 0 deletions

File tree

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
---
2+
layout: default
3+
title: Autocomplete API
4+
---
5+
6+
The Autocomplete API provides search functionality for CFEngine classes and variables.
7+
8+
## Search classes
9+
10+
Searches for CFEngine classes by name using case-insensitive pattern matching.
11+
12+
**URI:** https://hub.cfengine.com/api/autocomplete/classes
13+
14+
**Method:** GET
15+
16+
**RBAC permission:** `autocomplete.get.classes` (allowed by default)
17+
18+
**Parameters:**
19+
20+
- **query** _(string)_
21+
Search pattern for class names. Required. Must be 1-100 characters and containonly letters,
22+
numbers, dots, colons, or underscores.
23+
24+
**Example request (curl):**
25+
26+
```console
27+
curl --user <username>:<password> \
28+
https://hub.cfengine.com/api/autocomplete/classes?query=cfe
29+
```
30+
31+
**Example response:**
32+
33+
```
34+
HTTP 200 OK
35+
[
36+
"cfengine",
37+
"cfengine_3",
38+
"cfengine_3_28",
39+
"cfengine_3_28_0a",
40+
"cfengine_3_28_0a_0a2e3af8b",
41+
"cfengine_reporting_hub"
42+
]
43+
```
44+
45+
**Output:**
46+
47+
Returns an array of class names matching the search pattern,
48+
sorted alphabetically.
49+
50+
**Responses:**
51+
52+
| HTTP response code | Description |
53+
| ------------------------ | ------------------- |
54+
| 200 OK | Successful response |
55+
| 422 Unprocessable Entity | Validation errors |
56+
57+
**Error response examples:**
58+
59+
Missing required field:
60+
61+
```
62+
HTTP 422 Unprocessable Entity
63+
{
64+
"success": false,
65+
"errors": [
66+
{
67+
"field": "[query]",
68+
"message": "This field is missing."
69+
}
70+
]
71+
}
72+
```
73+
74+
## Search variables
75+
76+
Searches for CFEngine variables by name using case-insensitive pattern matching.
77+
78+
**URI:** https://hub.cfengine.com/api/autocomplete/variables
79+
80+
**Method:** GET
81+
82+
**RBAC permission:** `autocomplete.get.variables` (allowed by default)
83+
84+
**Parameters:**
85+
86+
- **query** _(string)_
87+
Search pattern for variable names. Required. Must be 1-100 characters and contain only letters, numbers, dots, colons, or underscores.
88+
89+
**Example request (curl):**
90+
91+
```console
92+
curl --user <username>:<password> \
93+
https://hub.cfengine.com/api/autocomplete/variables?query=cf
94+
```
95+
96+
**Example response:**
97+
98+
```
99+
HTTP 200 OK
100+
{
101+
"default:sys.cfengine_roles": "cfengine_roles",
102+
"default:sys.cf_version": "cf_version",
103+
"default:def.mpf_admit_cf_runagent_shell_selected": "mpf_admit_cf_runagent_shell_selected",
104+
"default:sys.cf_edition": "cf_edition"
105+
}
106+
```
107+
108+
**Output:**
109+
110+
Returns an object where keys are fully qualified variable names (namespace:bundle.variablename)
111+
and values are the variable names, sorted alphabetically by variable name.
112+
113+
**Responses:**
114+
115+
| HTTP response code | Description |
116+
| ------------------------ | ------------------- |
117+
| 200 OK | Successful response |
118+
| 422 Unprocessable Entity | Validation errors |
119+
120+
**Error response examples:**
121+
122+
Missing required field:
123+
124+
```
125+
HTTP 422 Unprocessable Entity
126+
{
127+
"success": false,
128+
"errors": [
129+
{
130+
"field": "[query]",
131+
"message": "This field is missing."
132+
}
133+
]
134+
}
135+
```
136+
137+
## Search inventory attributes
138+
139+
Searches for inventory attribute names using case-insensitive pattern matching.
140+
141+
**URI:** https://hub.cfengine.com/api/autocomplete/inventory
142+
143+
**Method:** GET
144+
145+
**RBAC permission:** No RBAC restrictions (inventory attributes are publicly available)
146+
147+
**Parameters:**
148+
149+
- **query** _(string)_
150+
Search pattern for inventory attribute names. Required. Must be 1-100 characters and contain only letters, numbers, dots, colons, or underscores.
151+
152+
**Example request (curl):**
153+
154+
```console
155+
curl --user <username>:<password> \
156+
https://hub.cfengine.com/api/autocomplete/inventory?query=os
157+
```
158+
159+
**Example response:**
160+
161+
```
162+
HTTP 200 OK
163+
[
164+
"OS",
165+
"OS type",
166+
"OS kernel",
167+
"OS release"
168+
]
169+
```
170+
171+
**Output:**
172+
173+
Returns an array of inventory attribute names matching the search pattern,
174+
sorted alphabetically.
175+
176+
**Responses:**
177+
178+
| HTTP response code | Description |
179+
| ------------------------ | ------------------- |
180+
| 200 OK | Successful response |
181+
| 422 Unprocessable Entity | Validation errors |
182+
183+
**Error response examples:**
184+
185+
Missing required field:
186+
187+
```
188+
HTTP 422 Unprocessable Entity
189+
{
190+
"success": false,
191+
"errors": [
192+
{
193+
"field": "[query]",
194+
"message": "This field is missing."
195+
}
196+
]
197+
}
198+
```
199+
200+
## Security considerations
201+
202+
The Autocomplete API bypasses database RBAC restrictions and allows users to see any class or variable name in the system. Inventory attributes are available without any restrictions.

0 commit comments

Comments
 (0)