Updated on 2023-11-08 GMT+08:00

Importing Configurations

Function

This API is used to import configurations to the configuration management center.

This API applies to ServiceComb engine 2.x.

URL

POST /v1/{project_id}/kie/file

Table 1 Path parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Tenant sub-project ID, which must be unique. The value contains 1 to 64 characters. See Obtaining a Project ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

override

Yes

String

force: Forcible import will overwrite duplicate items.

skip: Duplicate items will be skipped.

abort: If duplicate items are found, the import stops.

label

No

String

To import a specified label, enter a value in the format of {Label key}:{Label value}. If this parameter is empty, the label of the body is imported.

Request

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

x-engine-id

Yes

String

ID of the engine whose configuration is to be uploaded. See Querying the Microservice Engine List.

X-Enterprise-Project-ID

No

String

Enterprise project ID.

If this parameter is not set, the default enterprise project is default and the ID is 0.

Table 4 Request body parameter

Parameter

Mandatory

Type

Description

upload_file

Yes

File

File to be imported. The file name format is fileName.json.

File format:

{
    "data": [
        {
            "key": "keyItem1",
            "value": "valueItem1",
            "labels":{
                "1": "1"
            },
            "status": "enabled",
            "value_type": "text"
        }
    ]
}

Response

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

success

List<KVDoc>

List of configuration items that are successfully imported.

failure

List<DocFailedOfUpload>

List of configuration items that fail to be imported.

Table 6 KVDoc

Parameter

Type

Description

id

String

Configuration ID.

key

String

Configuration key.

value

String

Configuration value.

value_type

String

Type of the configuration value.

status

String

Configuration status.

create_time

Integer

Time when the configuration is created.

update_time

Integer

Time when the configuration is updated.

create_revision

Integer

Version number of the created configuration.

update_revision

Integer

Version number of the updated configuration.

labels

Map<String,String>

Configuration labels.

Table 7 DocFailedOfUpload

Parameter

Type

Description

key

String

Key of the configuration item that fails to be imported.

labels

Map<String,String>

Labels of the configuration item that fails to be imported.

error_code

String

Error code.

error_message

String

Error message.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_message

String

Error message.

detail

String

Location details.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_message

String

Error message.

detail

String

Location details.

Example Request

Import a configuration file. If the same configurations exist, these configurations will be overwritten based on the body label.

POST https://{endpoint}/v1/{project_id}/kie/file/override=force

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="upload_file"; filename="custom_1663124521493.json"
Content-Type: application/json
----WebKitFormBoundary7MA4YWxkTrZu0gW

Example Response

Successfully queried.

{
    "success": [
        {
            "id": "7e2d346e-d907-4871-bf51-a17fc7e52ad4",
            "key": "2",
            "value": "2",
            "value_type": "text",
            "create_revision": 3,
            "update_revision": 3,
            "status": "enabled",
            "create_time": 1636374809,
            "update_time": 1636374809,
            "labels": {
                "2": "2",
                "environment": "production"
            }
        },
        {
            "id": "907b3891-c691-4ae0-816f-e91eba705e28",
            "key": "1",
            "value": "1",
            "value_type": "text",
            "create_revision": 4,
            "update_revision": 4,
            "status": "enabled",
            "create_time": 1636374809,
            "update_time": 1636374809,
            "labels": {
                "1": "1",
                "environment": "production"
            }
        }
    ],
    "failure": []
}

Status Code

Status Code

Description

200

OK

400

Bad Request

500

Internal Server Error

Error Code

See CSE Error Codes.