User Tools


Create and Update Project

Back to JEA API docs


The Create Project and the Update Project commands are a little more complex than other commands, as they are all you need to set up, configure, and re-configure your JEA projects.

Create lets you send a comprehensive set of project data (the Command Object) to the JEA service. These data include the problem definition, the exploration strategy configuration, and the model information, so that a new project can be created. Update, on the other hand, allows you to send parts of the command object to modify an existing project. The details of the data objects are covered here.

A valid JWT token must be included in the header, or the transaction will be rejected with an HTTP 401 Unauthorized error code. The result of the operation will be reported in an Engine Response object.

Synopsis

The Command Object

A Create command has the “Create” command code in the data object, and must provide both the Problem Definition and Algorithm Configuration fields.

An Update command has the “Update” command code. It can contain either the Problem Definition or the Algorithm Configuration field, or both.

More details of the members of the command object are provided here.

Engine Response

Result of the operation is returned as an engine response object as seen in the example here:

{
  "description": "EA Engine of project circle has been created.",
  "ok": true
}

If the project already exists, the response may be:

{
  "description": "Failed to create EA engine: project name circle is already in use.",
  "ok": false
}

Example using curl://

To send the Create/Update Project command using curl:

curl http://jea.ensims.com/jea_web/api/command \
    -H "Authorization:Bearer eyJraWQiOiIxNT...9gjFXUrpQ" \
    -H "Content-Type:application/json" \
    -X POST \
    -d '{"command": "Create", "projectID": "circle", "problem": { ... }, "config": { ... }, "smData": { ... }}'
    

On successful operation, an engine response object is returned. If the existing JWT is invalid, an HTTP 401 Unauthorized code will be returned.

Example using Python Requests

Make sure Requests is correctly installed in your Python environment, and run the following the lines:

import requests

jwt = 'eyJraWQiOiIxNTAy...yBqDDTkfjmsQons9gjFXUrpQ'
headers = {
	'Authorization': 'Bearer ' + jwt, 
	'Content-Type': 'application/json'
	}
body = {
	"command": "Create", 
	"projectID": "circle", 
	"problem": { ... }, 
	"config": { ... }, 
	"smData": { ... }
	}

# Create/Update 'circle' project 
r = requests.post('http://jea.ensims.com/jea_web/api/command', headers=headers, json=body)
  
r.json()


Site Tools