CDRouter Support

Imports

cdrouter-web-api version 12.7

List staged imports

Get a list of staged (in-progress) imports.

GET /api/v1/imports/
Response 200 OK
{
    "timestamp": "2016-04-18T11:39:04.368857076-04:00",
    "data": [
        {
            "id": "1",
            "user_id": "1",
            "created": "2016-04-18T11:39:00.267967449-04:00",
            "updated": "2016-04-18T11:39:00.267967449-04:00",
            "archive": "20160415113526.gz",
            "path": "",
            "url": "",
            "insecure": false,
            "size": 45594
        }
    ]
}

Stage an import from a file upload

Stage an import from a file upload.

POST /api/v1/imports/

Example

Request must have a Content-Type header of multipart/form-data. The request body must have a form key named file whose contents is the file upload.

POST /api/v1/imports/
Content-Type: multipart/form-data; boundary=----CBacgHmUVPwTniJL

----CBacgHmUVPwTniJL
Content-Disposition: form-data; name="file"; filename="20160415113526.gz"
Content-Type: application/x-gzip


<file upload contents...>
----CBacgHmUVPwTniJL--

Response 200 OK
{
    "timestamp": "2016-04-18T11:43:49.684797726-04:00",
    "data": {
        "id": "1",
        "user_id": "1",
        "created": "2016-04-18T11:39:00.267967449-04:00",
        "updated": "2016-04-18T11:39:00.267967449-04:00",
        "archive": "20160415113526.gz",
        "path": "",
        "url": "",
        "insecure": false,
        "size": 45594
    }
}

Stage an import from a filesystem path

Stage an import from a filesystem path.

POST /api/v1/imports/?path

URL Parameters

Name Description
path string (required) Filesystem path on CDRouter system

Example

The path URL parameter must be a filesystem path on the CDRouter system to an export archive.

POST /api/v1/imports/?path=/tmp/upload.gz
Response 200 OK
{
    "timestamp": "2016-04-18T11:43:49.684797726-04:00",
    "data": {
        "id": "1",
        "user_id": "1",
        "created": "2016-04-18T11:39:00.267967449-04:00",
        "updated": "2016-04-18T11:39:00.267967449-04:00",
        "archive": "upload.gz",
        "path": "",
        "url": "",
        "insecure": false,
        "size": 45594
    }
}

Stage an import from a URL

Stage an import from a URL to another CDRouter system.

POST /api/v1/imports/?url

URL Parameters

Name Description
url string (required) URL to config, package or result on another CDRouter system
token string (optional) If transfering from a CDRouter 10.0 or higher system, this must be a valid API token on the other system
username string (optional) If transfering from a CDRouter 10.0 or higher system, this must be a valid API username on the other system
password string (optional) If transfering from a CDRouter 10.0 or higher system, this must be a valid API password on the other system
insecure boolean (optional) If true, allow connections to other CDRouter systems without valid certs, Default: false

Example

The url URL parameter must be a URL to a config, package or result on another CDRouter system and must take the form http[s]://host/resource/id. A token URL parameter or username and password URL parameters is required if the other CDRouter system is running CDRouter 10.0 or higher and does not have Automatic Login enabled.

Import config 123 from https://other.cdrouter.system using API token deadbeef.

POST /api/v1/imports/?url=https://other.cdrouter.system/configs/123&token=deadbeef

Import package 456 from https://other.cdrouter.system using API token deadbeef.

POST /api/v1/imports/?url=https://other.cdrouter.system/packages/456&token=deadbeef

Import result 20160329111012 from https://other.cdrouter.system using API token deadbeef.

POST /api/v1/imports/?url=https://other.cdrouter.system/results/20160329111012&token=deadbeef

Response 200 OK

{
    "timestamp": "2016-04-18T11:43:49.684797726-04:00",
    "data": {
        "id": "1",
        "user_id": "1",
        "created": "2016-04-18T11:39:00.267967449-04:00",
        "updated": "2016-04-18T11:39:00.267967449-04:00",
        "archive": "",
        "path": "",
        "url": "https://other.cdrouter.system/configs/123",
        "insecure": false,
        "size": 45
    }
}

Get a staged import

Get a staged import.

GET /api/v1/imports/{id}/
Response 200 OK
{
    "timestamp": "2016-04-18T11:43:49.684797726-04:00",
    "data": {
        "id": "1",
        "user_id": "1",
        "created": "2016-04-18T11:39:00.267967449-04:00",
        "updated": "2016-04-18T11:39:00.267967449-04:00",
        "archive": "20160415113526.gz",
        "path": "",
        "url": "",
        "insecure": false,
        "size": 45594
    }
}
Response 404 Not Found
{
    "error": "no such staged import"
}

Get a staged import’s commit request

Get a commit request for a staged import.

GET /api/v1/imports/{id}/request
Response 200 OK

For each resource, import is set to true if the resource does not already exist as indicated by the presence of the existing_id field.

{
    "timestamp": "2016-04-18T11:43:49.684797726-04:00",
    "data": {
        "replace_existing": false,
        "configs": {
            "default.conf": {
                "name": "",
                "import": true
            }
        },
        "packages": {
            "one": {
                "name": "",
                "import": false,
                "existing_id": "1027"
            }
        },
        "results": {
            "20160415113526": {
                "import": false,
                "existing_id": "20160415113526"
            }
        },
        "tags": null
    }
}
Response 404 Not Found
{
    "error": "no such staged import"
}

Commit a staged import

Commit a staged import.

POST /api/v1/imports/{id}/

Example

The request body must be the staged import’s commit request. Import a resource from the staged import by setting its import field to true. Configs and packages can be renamed on import by setting their name field to a non-empty string. Setting the top-level replace_existing to true will import all resources regardless of whether they already exist or not (as indicated by the presence of the existing_id field).

Additional tags can be added to imported resources by setting the top-level tags field to an array of tag names.

POST /api/v1/imports/1/
{
    "replace_existing": false,
    "configs": {
        "default.conf": {
            "name": "",
            "import": false
        }
    },
    "packages": {
        "one": {
            "name": "",
            "import": false,
            "existing_id": "1027"
        }
    },
    "results": {
        "20160415113526": {
            "import": false,
            "existing_id": "20160415113526"
        }
    },
    "tags": [
        "one",
        "two",
        "three"
    ]
}
Response 200 OK

For each resource that was marked for import, the response field indicates the result. For a successful import, imported will be true, id will be the imported resource’s ID and name will be the imported resource’s name. If a resource was not marked for import, imported will be false and message will be skipped. Otherwise, there was an error importing the resource. If the user did not have sufficient privileges to import the resource, message will be privileges, otherwise the message will contain further information about the import error.

{
    "timestamp": "2016-04-18T12:00:24.760548198-04:00",
    "data": {
        "replace_existing": false,
        "configs": {
            "default.conf": {
                "name": "default.conf",
                "import": false,
                "response": {
                    "imported": false,
                    "message": "skipped"
                }
            }
        },
        "packages": {
            "one": {
                "name": "one",
                "import": true,
                "existing_id": "1027",
                "response": {
                    "imported": true,
                    "id": "1027",
                    "name": "one"
                }
            }
        },
        "results": {
            "20160415113526": {
                "import": true,
                "existing_id": "20160415113526",
                "response": {
                    "imported": true,
                    "id": "20160415113526",
                    "name": "20160415113526"
                }
            }
        },
        "tags": [
            "one",
            "two",
            "three"
        ]
    }
}

Response 404 Not Found

{
    "error": "no such staged import"
}

Delete a staged import

Delete a staged import.

DELETE /api/v1/imports/{id}/
Response 204 No Content

Contents

×

About CDRouter

CDRouter is made by QA Cafe, a technology company based in Portsmouth, NH.

Get in touch via our Contact page or by following us on your favorite service: