AIM Command Line Interface (CLI)

AIM modeller provides a REST API that you can use to programmatically control AIM.

The API definition is AIM | 1.0.0-oas3 | architectureinmotion | SwaggerHub

The only requirement to call this API is that AIM modeller is running, and in FIle | Options you’ve set the AIM REST API HTTP endpoint to http://localhost:8080/api/ or similar.

Sample code to call the AIM REST API

This sample uses the aim_cli.rb Ruby file provided in the tech demo download .zip, and requires that AIM is running and you’ve opened the techdemo.json AIM model provided with the tech demo.

The script below loads the aim_cli.rb file into interactive Ruby (IRB), and then calls 3 commands – get_stories, get_story, and finally play_story, which animates a story playing in AIM.

This API will be expanded over the next few releases. If there’s a particular feature of AIM you’d like to control programmatically then email support.

In the sample below

  • red = command types in IRB by you
  • orange = HTTP command sent to local AIM modeller.exe running REST API
  • green = POST data (if the HTTP request was a post)
  • blue = response data

 

C:files/techdemo/script>irb -r ./aim_cli.rb
irb(main):001:0> get_stories
GET http://localhost:8080/api/stories

RESP 200
[
{
  "id": 1,
  "name": "Ordering",
  "desc": "Explains how ordering works"
}
]
=> [{"id"=>1, "name"=>"Ordering", "desc"=>"Explains how ordering works"}]
irb(main):002:0> get_story 1

GET http://localhost:8080/api/story/1

RESP 200
{
  "id": 1,
  "name": "Ordering",
  "desc": "Explains how ordering works"
}
=> #<Net::HTTPOK 200 OK readbody=true>
irb(main):003:0> play_story 1
cmd={:id=>1, :cmd=>"play"}

POST http://localhost:8080/api/story/1/commands

REQ
{"id":1,"cmd":"play"}
JSON={
"id": 1,
"cmd": "play"
}
RESP 200
{ "status" : "playing story 1"}
=> #<Net::HTTPOK 200 OK readbody=true>
irb(main):004:0>