Configuration Export

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 #

ParameterRemarks
entityQNamesThis 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.
startDateThe date since when the entities have been changedOptional
endDateThe entities that have been created to dateOptional

Request Headers #

ParameterAccepted valuesRemarks
AuthorizationStringBase64 encoded userName:password with “Basic”Ex: Basic aW5zdGFsbDppbnN0YWxs
Content-Typeapplication/jsonSending 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 #

ParameterAccepted valuesRemarks
Content-Typeapplication/zipThe content type of the zip file
Content-LengthNumberThe size of the zip file in bytes
Content-MD5StringMD5 checksum value of the zip file
x-enactor-entity-countNumberThe total entity counts that is included in the zip file

Response Codes #

Status CodeStatus DescriptionDescription
200SuccessThe request is successful and will send the zip fie as a byte stream
400Bad RequestThe request has incorrect request parameters which are not acceptable
500Server ErrorUnexpected 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))
Go to Top