Skip to content

Commit 3df11c6

Browse files
committed
docs(api-gateway): Update information for endpoints.
1 parent ca4848b commit 3df11c6

File tree

4 files changed

+144
-11
lines changed

4 files changed

+144
-11
lines changed

docs/pages/product/apis-integrations/rest-api.mdx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ by making them accessible to specific users only or disallowing access for
124124
everyone. By default, API endpoints in all scopes, except for `jobs`, are
125125
accessible for everyone.
126126

127-
| API scope | REST API endpoints | Accessible by default? |
128-
| --------- | ----------------------------------------------------------------------------------------- | ---------------------- |
129-
| `meta` | [`/v1/meta`][ref-ref-meta] | ✅ Yes |
130-
| `data` | [`/v1/load`][ref-ref-load], [`/v1/sql`][ref-ref-sql] | ✅ Yes |
131-
| `graphql` | `/graphql` | ✅ Yes |
132-
| `jobs` | [`/v1/pre-aggregations/jobs`][ref-ref-paj] | ❌ No |
133-
| No scope | `/livez`, `/readyz` | ✅ Yes, always |
127+
| API scope | REST API endpoints | Accessible by default? |
128+
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
129+
| `meta` | [`/v1/meta`][ref-ref-meta], [`/v1/meta/namesModel`][ref-ref-meta-names-model], [`/v1/meta/:nameModel`][ref-ref-meta-name-model], [`/v1/meta/:nameModel/:field`][ref-ref-meta-name-model-field] | ✅ Yes |
130+
| `data` | [`/v1/load`][ref-ref-load], [`/v1/sql`][ref-ref-sql] | ✅ Yes |
131+
| `graphql` | `/graphql` | ✅ Yes |
132+
| `jobs` | [`/v1/pre-aggregations/jobs`][ref-ref-paj] | ❌ No |
133+
| No scope | `/livez`, `/readyz` | ✅ Yes, always |
134134

135135
You can set accessible API scopes _for all requests_ using the
136136
`CUBEJS_DEFAULT_API_SCOPES` environment variable. For example, to disallow
@@ -278,6 +278,9 @@ example, the following query will retrieve rows 101-200 from the `Orders` cube:
278278
/reference/configuration/config#contexttoapiscopes
279279
[ref-ref-load]: /product/apis-integrations/rest-api/reference#base_pathv1load
280280
[ref-ref-meta]: /product/apis-integrations/rest-api/reference#base_pathv1meta
281+
[ref-ref-meta-names-model]: /product/apis-integrations/rest-api/reference#base_pathv1metanamesmodel
282+
[ref-ref-meta-name-model]: /product/apis-integrations/rest-api/reference#base_pathv1metanamemodel
283+
[ref-ref-meta-name-model-field]: /product/apis-integrations/rest-api/reference#base_pathv1metanamemodelfield
281284
[ref-ref-sql]: /product/apis-integrations/rest-api/reference#base_pathv1sql
282285
[ref-ref-paj]: /product/apis-integrations/rest-api/reference#base_pathv1pre-aggregationsjobs
283286
[ref-security-context]: /product/auth/context
@@ -290,4 +293,4 @@ example, the following query will retrieve rows 101-200 from the `Orders` cube:
290293
[self-cors]: #configuration-cors
291294
[ref-ref-rest-api]: /product/apis-integrations/rest-api/reference
292295
[link-jq-utility]: https://jqlang.github.io/jq/
293-
[gh-cube-openspec]: https://github.com/cube-js/cube/blob/master/packages/cubejs-api-gateway/openspec.yml
296+
[gh-cube-openspec]: https://github.com/cube-js/cube/blob/master/packages/cubejs-api-gateway/openspec.yml

docs/pages/product/apis-integrations/rest-api/reference.mdx

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,136 @@ Example response:
265265
}
266266
```
267267

268+
## `{base_path}/v1/meta/namesModel`
269+
270+
Get names for cubes and views defined in the data model.
271+
272+
Response
273+
274+
- `cubes` - Array of cubes and views
275+
- `name` - Codename of the cube/view
276+
277+
Example request:
278+
279+
```bash{outputLines: 2-4}
280+
curl \
281+
-H "Authorization: EXAMPLE-API-TOKEN" \
282+
-G \
283+
http://localhost:4000/cubejs-api/v1/meta/namesModel
284+
```
285+
286+
Example response:
287+
288+
```json
289+
{
290+
"cubes": [
291+
{
292+
"name": "Users"
293+
}
294+
]
295+
}
296+
```
297+
298+
## `{base_path}/v1/meta/:nameModel`
299+
300+
Get all the information about cubes or views by knowing the name that is passed to :nameModel.
301+
302+
Response
303+
304+
- `cubes` - Array of cubes and views
305+
- `name` - Codename of the cube/view
306+
- `type` - Type can be "cube" or "view"
307+
- `title` - Human-readable cube/view name
308+
- `meta` - Custom metadata
309+
- `measures` - Array of measures in this cube/view
310+
- `dimensions` - Array of dimensions in this cube/view
311+
- `hierarchies` - Array of hierarchies in this cube
312+
- `segments` - Array of segments in this cube/view
313+
- `folders` - Array of folders in this view
314+
- `connectedComponent` - An integer representing a join relationship. If the same value is returned for two cubes, then there is
315+
at least one join path between them.
316+
317+
Example request:
318+
319+
```bash{outputLines: 2-4}
320+
curl \
321+
-H "Authorization: EXAMPLE-API-TOKEN" \
322+
-G \
323+
http://localhost:4000/cubejs-api/v1/meta/Users
324+
```
325+
326+
Example response:
327+
328+
```json
329+
{
330+
"cubes": [
331+
{
332+
"name": "Users",
333+
"title": "Users",
334+
"meta": {
335+
"someKey": "someValue",
336+
"nested": {
337+
"someKey": "someValue"
338+
}
339+
},
340+
"connectedComponent": 1,
341+
"measures": [
342+
{
343+
"name": "users.count",
344+
"title": "Users Count",
345+
"shortTitle": "Count",
346+
"aliasName": "users.count",
347+
"type": "number",
348+
"aggType": "count",
349+
"drillMembers": ["users.id", "users.city", "users.createdAt"]
350+
}
351+
],
352+
"dimensions": [
353+
{
354+
"name": "users.city",
355+
"title": "Users City",
356+
"type": "string",
357+
"aliasName": "users.city",
358+
"shortTitle": "City",
359+
"suggestFilterValues": true
360+
}
361+
],
362+
"segments": []
363+
}
364+
]
365+
}
366+
```
367+
368+
## `{base_path}/v1/meta/:nameModel/:field`
369+
370+
Get information :field about cubes or views, knowing the name that is passed to :nameModel.
371+
372+
Response
373+
374+
- `value` - Value from the field by cubes or views
375+
376+
Example request:
377+
378+
```bash{outputLines: 2-4}
379+
curl \
380+
-H "Authorization: EXAMPLE-API-TOKEN" \
381+
-G \
382+
http://localhost:4000/cubejs-api/v1/meta/Users/meta
383+
```
384+
385+
Example response:
386+
387+
```json
388+
{
389+
"value": {
390+
"someKey": "someValue",
391+
"nested": {
392+
"someKey": "someValue"
393+
}
394+
}
395+
}
396+
```
397+
268398
## `{base_path}/v1/pre-aggregations/jobs`
269399

270400
Trigger pre-aggregation build jobs or retrieve statuses of such jobs.

packages/cubejs-api-gateway/src/gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class ApiGateway {
401401
);
402402

403403
app.get(
404-
`${this.basePath}/v1/meta/model_name`,
404+
`${this.basePath}/v1/meta/namesModel`,
405405
userMiddlewares,
406406
userAsyncHandler(async (req, res) => {
407407
await this.metaModelName({

packages/cubejs-api-gateway/test/permissions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ describe('Gateway Api Scopes', () => {
9191
apiGateway.release();
9292
});
9393

94-
test('GET /v1/meta/model_name should return model names', async () => {
94+
test('GET /v1/meta/namesModel should return model names', async () => {
9595
const { app, apiGateway } = createApiGateway({
9696
contextToApiScopes: async () => ['graphql', 'meta', 'data', 'jobs'],
9797
});
9898

9999
const response = await request(app)
100-
.get('/cubejs-api/v1/meta/model_name')
100+
.get('/cubejs-api/v1/meta/namesModel')
101101
.set('Authorization', AUTH_TOKEN)
102102
.expect(200);
103103

0 commit comments

Comments
 (0)