REST API: Importing & Exporting Cluster Templates

REST Overview | Tenants | Provisioners | Providers | Hardware Types | Image Types | Services | Cluster Template | Importing & Exporting | Clusters | Plugins | Metrics

The REST APIs allow you to export all Providers, Hardware Types, Image Types, Services, and Cluster Templates created into a JSON Object that can then be imported into another Coopr server.

Export Template Metadata

To export all entities, make a HTTP GET request to URI:

/export

The response is a JSON Object with keys for providers, hardwaretypes, imagetypes, services, and clustertemplates. Each key has a JSON array as its value, with each element in the array as the json representation as described in the corresponding sections for providers, hardware types, image types, services, and cluster templates.

HTTP Responses

Status Code Description
200 (OK) Successfully created
401 (UNAUTHORIZED) The user is unauthorized and cannot perform an export.

Example

$ curl -H 'Coopr-UserID:admin'
       -H 'Coopr-TenantID:<tenantid>'
       -H 'Coopr-ApiKey:<apikey>'
       http://<server>:<port>/<version>/export
  {
    "providers":[ ... ],
    "hardwaretypes":[ ... ],
    "imagetypes":[ ... ],
    "services":[ ... ],
    "clustertemplates":[ ... ]
  }

Import Template Metadata

To import entities, make a POST HTTP request to URI:

/import

The post body must be a JSON object of the same format as the export result. It has a key for providers, hardwaretypes, imagetypes, services, and clustertemplates. The value for each key is a JSON array, with each element in the array as a JSON object representation of the corresponding entity.

Note

Imports will wipe out all existing entities, replacing everything with the entities given in the post body.

HTTP Responses

Status Code Description
200 (OK) Successful
403 (FORBIDDEN) If a non-admin user tries to import entities into the server.

Example

$ curl -X POST
       -H 'Coopr-UserID:admin'
       -H 'Coopr-TenantID:<tenantid>'
       -H 'Coopr-ApiKey:<apikey>'
       -d '{
             "providers":[...],
             "imagetypes":[...],
             "hardwaretypes":[...],
             "services":[...],
             "clustertemplates":[...]
           }' http://<server>:<port>/<version>/import