1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

docs: update export/import examples (#2348)

## What

This change updates the availability notice and the code samples in the
import/export docs.

Specifically, the code samples have been moved to using the ApiRequest
component (and thus get examples in HTTP, cURL, and HTTPie), and the
import code sample now says which version it's using (version 3).

## Why

The import code sample didn't say which version of the data it used, so
Unleash would assume it was version 1 if you tried to run it. However,
the actual data was incompatible with the v1 data format, so you'd get
an error if you tried to actually import it.

While fixing this, I figured it'd also be alright to add some other
minor updates to bring the docs a bit more up to recent standards.
This commit is contained in:
Thomas Heartman 2022-11-08 14:42:06 +01:00 committed by GitHub
parent f5fb7b66d1
commit 75c3fcd170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,13 @@
id: import_export
title: Import & Export
---
import ApiRequest from '@site/src/components/ApiRequest'
_since v3.3.0_
:::info Availability
The import and export API first appeared in Unleash 3.3.0.
:::
Unleash supports import and export of feature toggles and strategies at startup and during runtime. The import mechanism guarantees that:
- all imported features will be non-archived
@ -54,17 +59,7 @@ You can customize the export with query parameters:
For example if you want to download just feature-toggles as yaml:
```
/api/admin/state/export?format=yaml&featureToggles=1&strategies=0&tags=0&projects=0&download=1
```
Example with curl:
```sh
curl -X GET -H "Content-Type: application/json" \
-H "Authorization: Basic YWRtaW46" \
https://unleash.example.com/api/admin/state/export?&featureToggles=1&strategies=0 > export.json
```
<ApiRequest verb="get" url="api/admin/state/export?format=yaml&featureToggles=1&strategies=0&tags=0&projects=0&download=1" title="Export features (and nothing else) as YAML."/>
### API Import {#api-import}
@ -84,28 +79,7 @@ If you want the database to be cleaned before import (**all strategies and featu
Example usage:
```
POST /api/admin/state/import
{
"features": [
{
"name": "a-feature-toggle",
"enabled": true,
"description": "#1 feature-toggle"
}
]
}
```
Example with curl:
```sh
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Basic YWRtaW46" -d @export.json \
http://localhost:4242/api/admin/state/import
```
\*) Remember to set correct token for Authorization.
<ApiRequest verb="post" url="api/admin/state/import" payload={{ "version": 3, "features": [{"name": "a-feature-toggle", "enabled": true, "description": "#1 feature-toggle"}] }} title="Import data into Unleash."/>
## Startup import {#startup-import}