Oms API POST copy model - openmpp/openmpp.github.io GitHub Wiki
POST a request to copy model from Models Library
Models Library is a shared read-only storage from where users can copy models into their own workspace.
Methods (NOT recommended in production, only for testing):
POST /api/admin/copy-model/:path
POST /api/admin/copy-model/:path/lang/:lang
Arguments:
:path - (required) model publish list file path
:lang - (optional) language code for log messages
If there any sub-folders in the path then / slashes must be replaced with * stars.
Examples:
curl -v -X POST http://localhost:4040/api/admin/copy-model/RiskPaths-3.0.0.0*RiskPaths.publish.lst
curl -v -X POST http://localhost:4040/api/admin/copy-model/RiskPaths-3.0.0.0*RiskPaths.publish.lst/lang/FR
Recommended Methods:
POST /api/admin/copy-model
POST /api/admin/copy-model/lang/:lang
Argument:
:lang - (optional) language code for log messages
JSON body examples:
{
"PublishLst": "RiskPaths.publish.lst",
"NameVersion": "RiskPaths"
}
Or if RiskPaths model files are located in sub-folders ../lib/models/bin/RiskPaths-3.0.0.0 and documentation at ../lib/models/doc/RiskPaths-3.0.0.0:
{
"PublishLst": "RiskPaths-3.0.0.0/RiskPaths.publish.lst",
"ModelDigest": "d976aa2fb999f097468bb2ea098c4daf",
"NameVersion": "RiskPaths",
"BinDir": "RiskPaths-3.0.0.0",
"DocDir": "RiskPaths-3.0.0.0",
"LogDir": ""
}
where:
-
PublishLst :(required) model publish list file path, relative toSrcRootdirectory -
NameVersion:(required) model name or name-version (version is optional) -
ModelDigest:(optional)but highly recommended model digest -
BinDir :(default:models/bin) directory where model.exe, model.sqlite and other files located -
DocDir :(default:models/doc) model documentation directory -
LogDir :(default:models/log) model logs files directory
How it works
For example, if we have models library lib web-service for two "regular" users alice and bob:
../bin/oms -l localhost:4048 -oms.Name lib -oms.RootDir lib -oms.HtmlDir ../html -oms.EtcDir ../etc -oms.AllowDownload -oms.Readonly
../bin/oms -l localhost:4040 -oms.Name alice -oms.RootDir alice -oms.HtmlDir ../html -oms.EtcDir ../etc -oms.AllowDownload -oms.AllowUpload
../bin/oms -l localhost:4044 -oms.Name bob -oms.RootDir bob -oms.HtmlDir ../html -oms.EtcDir ../etc -oms.AllowDownload -oms.AllowUpload
Models Library configuration defined in etc/disk.inias:
[ModelLib]
;
; URL of models library, usually read-only oms instance
;
Url = http://localhost:4048
;
; Source root of of models library, where models/bin models/log models/doc are located
;
SrcRoot = ../lib
;
; Model copy script:
; copy model files from models library $src_root ito the user $dst_root
; using model file list from ModelName.publish.lst
;
CopyCmd = ../etc/model-copy.sh
Step 1.
User Alice needs to knowPublishLst and other JSON body values.
She can get it from Models Libarary Url = http://localhost:4048
by using GET model list text:
Request example:
http://localhost:4048/api/model-list/text
Response example:
{
"Model": {
"Name": "RiskPaths",
"Digest": "d976aa2fb999f097468bb2ea098c4daf",
"Version": "3.0.0.0",
........
},
"Dir": "RiskPaths-3.0.0.0",
"PubLst": "RiskPaths-3.0.0.0/RiskPaths.publish.lst",
"DocDir": "RiskPaths-3.0.0.0",
........
}
Step 2.
To copy RiskPaths model from SrcRoot = ../lib location
into Alice own workspace folder ../alice
she should POST JSON to her own http://localhost:4040 /api/admin/copy-model:
{
"PublishLst": "RiskPaths-3.0.0.0/RiskPaths.publish.lst",
"ModelDigest": "d976aa2fb999f097468bb2ea098c4daf",
"NameVersion": "RiskPaths-3.0.0.0",
"BinDir": "RiskPaths-3.0.0.0",
"DocDir": "RiskPaths-3.0.0.0",
"LogDir": ""
}
As a result copy model script CopyCmd = ../etc/model-copy.sh would start as:
../etc/model-copy.sh models/bin/RiskPaths-3.0.0.0/RiskPaths.publish.lst ../lib /mirror/alice RiskPaths-3.0.0.0
You can find model copy scripts in openM++ release etc folder or on GitHub:
Example:
curl -v -X POST -H "Content-Type: application/json" http://localhost:4040/api/admin/copy-model -d @test.json
> POST /api/admin/copy-model HTTP/1.1
> Host: localhost:4040
> User-Agent: curl/8.21.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 255
>
* upload completely sent off: 255 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 29 Aug 2026 03:17:34 GMT
< Content-Length: 126
<
{
"LogFileName":"models/log/copy-model.2026_08_28_23_17_34_952.RiskPaths-3.0.0.0.console.txt",
"IsError":false,
"ErrorMsg":""
}
Check model copy result
Alice should periodically check log file copy-model.2026_08_28_23_17_34_952.RiskPaths-3.0.0.0.console.txt in order to find final results of ../etc/model-copy.sh.
It can be done by calling GET copy model log file method.