This API provides the facility to export the Enactor configurations via REST. This will return a zip file as a byte stream. Since the zip file can be large it provides the facility of streaming the response. It will also make sure that the configuration file size is not more than 100 MB. If it exceeds 100 MB the request will fail.
Request URL #
1POST {Enactor Rest API Base URL}/rest/configuration/export
POST {Enactor Rest API Base URL}/rest/configuration/export
ex: Enactor Rest API Base URL – http://<Leader IP>:<EMS Port>/WebRestApi/
Request Body #
{
"entityQNames": [
"user"
],
"criteria": {
"filters" : [ {
"@type" : "TextValueFilter",
"id": "UserId",
"comparisonOperator" : "STARTS_WITH",
"supportValues" : [ {
"value" : "Uditha"
}]
} ]
},
"startDate": "2019-08-22",
"endDate": "2020-08-22"
}
Request Parameters #
Parameter | Remarks |
---|---|
entityQNames | This will be an entity qName array including localPart and namespaceURI.The localPart is the name of the entity that will be exported.The namespaceURI is the namespace for the entity. |
startDate | The date since when the entities have been changedOptional |
endDate | The entities that have been created to dateOptional |
Request Headers #
Parameter | Accepted values | Remarks |
---|---|---|
Authorization | String | Base64 encoded userName:password with “Basic”Ex: Basic aW5zdGFsbDppbnN0YWxs |
Content-Type | application/json | Sending the request body as JSON |
Response Body #
This API will send the byte stream of the zip file containing all the configuration files as per the given request.
Response Header #
Parameter | Accepted values | Remarks |
---|---|---|
Content-Type | application/zip | The content type of the zip file |
Content-Length | Number | The size of the zip file in bytes |
Content-MD5 | String | MD5 checksum value of the zip file |
x-enactor-entity-count | Number | The total entity counts that is included in the zip file |
Response Codes #
Status Code | Status Description | Description |
---|---|---|
200 | Success | The request is successful and will send the zip fie as a byte stream |
400 | Bad Request | The request has incorrect request parameters which are not acceptable |
500 | Server Error | Unexpected error occurred while processing the request |
Guide to Integrate #
Java Example #
package com.enactor.rest.api.config.service;
import java.util.HashMap;
import java.util.Map;
import com.enactor.core.webService.epr.IHttpServiceEndpointReference.HTTPMethod;
import com.enactor.core.webService.epr.IRestEndpoint;
import com.enactor.core.webService.epr.RestEndpoint;
import com.enactor.core.webService.rest.DefaultRestServiceInvoker;
import com.enactor.core.webService.rest.IRestServiceInvoker;
import com.enactor.core.webService.rest.RestRawMessageHandler;
import com.enactor.core.webService.rest.RestServiceInvocationException;
public class RestConfigServiceTest {
// The base URL of the configuration service
private static final String BASE_URL = "{Enactor Rest API Base URL}/rest/configuration";
public static void main(String[] args) throws RestServiceInvocationException {
// The request JSON as string
String request = "<request-body-as-above>";
// Initialize the REST service invoker
IRestServiceInvoker invoker = new DefaultRestServiceInvoker();
invoker.setMessageHandler(new RestRawMessageHandler());
// Create the REST endpoint
IRestEndpoint endpoint = new RestEndpoint();
// Assign the REST URL
endpoint.setUrl(BASE_URL + "/export");
// Define the HTTP method as POST
endpoint.setHttpMethod(HTTPMethod.POST);
// Set header parameters
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Basic aW5zdGFsbDppbnN0YWxs");
endpoint.setHeaders(headers);
Object responseObject = invoker.invoke(endpoint, request);
}
}
JavaScript (NodeJS) Example #
const fetch = require('node-fetch');
const fs = require('fs');
const assert = require('assert').strict;
const BASE_URL = "{Enactor Rest API Base URL}/rest/configuration";
fetch(BASE_URL + '/export', {
method: 'post',
headers: {
'Authorization': 'Basic aW5zdGFsbDppbnN0YWxs',
'Content-Type', 'application/json'
},
body: JSON.stringify({
entityQNames: [
"user"
]
})
}).then(res => assert.equal(res.status, 200))
.catch(err => console.log(err.message))