From 1152272ed6ef5530863dceda34952832cdd03414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Fri, 12 Mar 2021 19:08:18 +0100 Subject: [PATCH] chore: add docs for context api (#762) --- docs/api/admin/context.md | 89 +++++++++++++++++++++++++++++++++++++++ docs/api/admin/project.md | 78 ++++++++++++++++++++++++++++++++++ website/i18n/en.json | 10 ++++- website/sidebars.json | 4 +- 4 files changed, 178 insertions(+), 3 deletions(-) create mode 100644 docs/api/admin/context.md create mode 100644 docs/api/admin/project.md diff --git a/docs/api/admin/context.md b/docs/api/admin/context.md new file mode 100644 index 0000000000..52e7370fa2 --- /dev/null +++ b/docs/api/admin/context.md @@ -0,0 +1,89 @@ +--- +id: context +title: /api/admin/context +--- + +> The context feature is only available as part of Unleash Enterprise. In order to access the API programmatically you need to make sure you obtain a API token with admin permissions. + +### List context fields defined in Unleash + +`GET https://unleash.host.com/api/admin/context` + +Returns a list of context fields defined in Unleash. + +**Example response:** + +```json +[ + { + "name": "appName", + "description": "Allows you to constrain on application name", + "stickiness": false, + "sortOrder": 2, + "createdAt": "2020-03-05T19:33:19.784Z" + }, + { + "name": "environment", + "description": "Allows you to constrain on application environment", + "stickiness": false, + "sortOrder": 0, + "legalValues": ["qa", "dev", "prod"], + "createdAt": "2020-03-05T19:33:19.784Z" + }, + { + "name": "tenantId", + "description": "Control rollout to your tenants", + "stickiness": true, + "sortOrder": 10, + "legalValues": ["company-a, company-b"], + "createdAt": "2020-03-05T19:33:19.784Z" + }, + { + "name": "userId", + "description": "Allows you to constrain on userId", + "stickiness": false, + "sortOrder": 1, + "createdAt": "2020-03-05T19:33:19.784Z" + } +] +``` + +### Create a new context field + +`POST https://unleash.host.com/api/admin/context` + +Creates a new context field. + +**Body** + +```json +{ + "name": "region", + "description": "Control rollout based on region", + "legalValues": ["asia", "eu", "europe"], + "stickiness": true +} +``` + +### Update a context field + +`PUT https://unleash.host.com/api/context/:name` + +Updates a new context field + +**Body** + +```json +{ + "name": "region", + "description": "Control rollout based on region", + "legalValues": ["asia", "eu"], + "stickiness": true +} +``` + +### Delete a context field + +`DELETE https://unleash.host.com/api/admin/context/:name` + +Deletes the context field with name=`name`. diff --git a/docs/api/admin/project.md b/docs/api/admin/project.md new file mode 100644 index 0000000000..b69ccce4f7 --- /dev/null +++ b/docs/api/admin/project.md @@ -0,0 +1,78 @@ +--- +id: projects +title: /api/admin/projects +--- + +> The projects feature is only available as part of Unleash Enterprise. In order to access the API programmatically you need to make sure you obtain a API token with admin permissions. + +### List projects in Unleash + +`GET https://unleash.host.com/api/admin/projects` + +Returns a list of projects in Unleash. + +**Example response:** + +```json +{ + "version": 1, + "projects": [ + { + "id": "default", + "name": "Default", + "description": "Default project", + "createdAt": "2020-12-03T09:47:20.170Z" + }, + { + "id": "MyNewProject", + "name": "MyNewProject", + "description": "A test project", + "createdAt": "2020-12-03T09:47:20.170Z" + }, + { + "id": "test", + "name": "Test Project", + "description": "Collection of test toggles", + "createdAt": "2020-12-03T09:47:20.170Z" + } + ] +} +``` + +### Create a new project + +`POST https://unleash.host.com/api/admin/projects` + +Creates a new project. + +**Body** + +```json +{ + "id": "someId", + "name": "Test Project", + "description": "Some description" +} +``` + +### Update a projects field + +`PUT https://unleash.host.com/api/projects/:id` + +Updates a project with id=`id`. + +**Body** + +```json +{ + "id": "someId", + "name": "Test Project", + "description": "Some description" +} +``` + +### Delete a projects field + +`DELETE https://unleash.host.com/api/admin/projects/:id` + +Deletes the project with id=`id`. diff --git a/website/i18n/en.json b/website/i18n/en.json index b99a47c913..60e84afd4e 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -47,6 +47,9 @@ "api/admin/addons": { "title": "/api/admin/addons" }, + "api/admin/context": { + "title": "/api/admin/context" + }, "api/admin/events": { "title": "/api/admin/events" }, @@ -59,6 +62,9 @@ "api/admin/metrics": { "title": "/api/admin/metrics" }, + "api/admin/projects": { + "title": "/api/admin/projects" + }, "api/admin/state": { "title": "/api/admin/state" }, @@ -173,8 +179,8 @@ "user_guide/create_feature_toggle": { "title": "Create a feature toggle" }, - "user_guide/discover-unknown-toggles": { - "title": "user_guide/discover-unknown-toggles" + "user_guide/discover_unkonwn_toggles": { + "title": "Discover unknown toggles" }, "user_guide/index": { "title": "Introduction" diff --git a/website/sidebars.json b/website/sidebars.json index 6abfb18bc4..f0273e4b40 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -50,7 +50,9 @@ "api/admin/events", "api/admin/state", "api/admin/feature-types", - "api/admin/addons" + "api/admin/addons", + "api/admin/context", + "api/admin/projects" ], "Internal": ["api/internal/internal", "api/internal/health"], "Specification": ["api/open_api"]