This doc provides a quick and dirty review of how to use the Orchestration API. Note that this process was unblocked by EDGECLOUD-2379, at least in terms of my testing.
In order to authorize against the API, you need to pass your credentials through and receive a JWT (JSON Web Token). The JWT will be used to authenticate subsequent calls to the API.
The following example illustrate
curl -s -XPOST https://console.mobiledgex.net/api/v1/login \
-H "Content-Type: application/json" \
-d '{ "password": "YOURPASSWORD", "username": "YOURUSER" }'
For example, for an account named “demo” with a password of “somepass” the following call will work:
$ curl -s -XPOST https://console.mobiledgex.net/api/v1/login \
-H "Content-Type: application/json" \
-d '{ "password": "somepass", "username": "demo" }'
{"token":"jayhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.jayleHAiOjE1ODYwMjY3MzYsImlhdCI6MTU4NTk0MDMzNiwidXNlcm5hbWUiOiJkZW1vIiwiZW1haWwiOiJkZW1vQG1vYmlsZWRnZXguY29tIiwia2lkIjoyfQ.-Lu0iFOl_3O9FnGLMCcIVWoaDqe_9Jte9zOYcU7WZf4fC6QsHv-OZBGdur7JW6szG72_rDq332Aj0dmnDZbEaQ"}
The JWT is returned in a json blob; if you have either the jq
or jsontool
commands installed you can pull the token out into a file:
$ curl -s -XPOST https://console.mobiledgex.net/api/v1/login \
-H "Content-Type: application/json" \
-d '{ "password": "somepass", "username": "demo" }' | json token > auth-token
$ cat auth-token
jayhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.jayleHAiOjE1ODYwMjY5NDgsImlhdCI6MTU4NTk0MDU0OCwidXNlcm5hbWUiOiJkZW1vIiwiZW1haWwiOiJkZW1vQG1vYmlsZWRnZXguY29tIiwia2lkIjoyfQ.gls1Edr3FhEDIm2kEYkHrBRAhE7rTJbLLLxNC7_uonXTmGWOdz8NSYU784e9jXC3YHXcgKnaT8hcxV20c7vK3g
You can then take the token and use it to authenticate requests against the API:
$ curl -s -XPOST https://console.mobiledgex.net/api/v1/auth/user/show \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(cat auth-token)" \
-d '{"name": "demoorg"}' | json
[
{
"Name": "demo",
"Email": "demo@mobiledgex.com",
"EmailVerified": true,
"Passhash": "",
"Salt": "",
"Iter": 0,
"FamilyName": "",
"GivenName": "",
"Picture": "",
"Nickname": "",
"CreatedAt": "2020-02-26T21:11:34.139642Z",
"UpdatedAt": "2020-03-02T21:41:47.961197Z",
"Locked": false
}
]
There are a few things that one can do to make life a bit easier when talking with an API; here are a few of the ones that I like to use:
npm install json
, and it’s landing page is here.brew install jq
. It’s homepage is here.Example:
$ cat .curlrc
-H "Content-Type: application/json"
-H "Authorization: Bearer jayhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.jayleHAiOjE1ODYwMjYyMTEsImlhdCI6MTU4NTkzOTgxMSwidXNlcm5hbWUiOiJkZW1vIiwiZW1haWwiOiJkZW1vQG1vYmlsZWRnZXguY29tIiwia2lkIjoyfQ.8KJZiqH15xkMfxi0i0NTTC1kdZsmPmbgvjM-fOZKzFFSwIRyG53X6fztc4fXuM_HY2DSB9kHEZZAF0RhXMXw2A"
$ resty https://console.mobiledgex.net/api/v1
https://console.mobiledgex.net/api/v1*
$ POST /auth/user/show '{ "Name": "demoorg" }' | jq
[
{
"Name": "demo",
"Email": "demo@mobiledgex.com",
"EmailVerified": true,
"Passhash": "",
"Salt": "",
"Iter": 0,
"FamilyName": "",
"GivenName": "",
"Picture": "",
"Nickname": "",
"CreatedAt": "2020-02-26T21:11:34.139642Z",
"UpdatedAt": "2020-03-02T21:41:47.961197Z",
"Locked": false
}
]
$ POST /auth/ctrl/ShowCloudlet '{"region": "EU"}' \
| json -Hag data.key.operator_key.name data.key.name
TDG munich-main
TMPL krakow-main
Orange-Spain barcelona
Orange-Spain madrid-coslada
TDG berlin-main
CloudAndHeat secustack
Orange-Spain test-cloudlet
TDG dusseldorf-main
TDG frankfurt-main
TDG hamburg-main
WWT barcelona
azure centralus-main
Nokia wroclaw
Telefonica barcelona
POST /api/vi/auth/ctrl/ShowClusterInst "region": "XX"
$ POST /auth/ctrl/ShowClusterInst '{"region": "EU"}' \
| json -Hag data.key.cluster_key.name data.key.cloudlet_key.operator_key.name data.key.cloudlet_key.name
testcluster TDG munich-main
redisdemo TDG munich-main
flaskcluster TDG munich-main
POST /api/vi/auth/ctrl/ShowApp "region": "XX"
$ POST /auth/ctrl/ShowApp '{"region": "EU"}' \
| json -Hag data.key.name data.image_path data.default_flavor.name
test docker.mobiledgex.net/demoorg/images/test:1.0 m4.small
vmtest https://artifactory.mobiledgex.net/artifactory/repo-demoorg/CentOS-7-x86_64-GenericCloud-1907.qcow2#md5:160aa274e7a69f2edb50e2d89f54270b m4.small
flask_web docker.mobiledgex.net/demoorg/images/flask_web:1.0 m4.small
redis docker.mobiledgex.net/demoorg/images/redis:1.0 m4.small
POST /api/vi/auth/ctrl/ShowApp "region": "XX"
$ POST /auth/ctrl/ShowAppInst '{"region": "EU"}' \
| json -Hag data.key.app_key.name data.key.cluster_inst_key.cloudlet_key.operator_key.name data.key.cluster_inst_key.cloudlet_key.name data.uri
vmtest TDG munich-main demoorgvmtest10.munich-main.tdg.mobiledgex.net
test TDG munich-main testcluster.munich-main.tdg.mobiledgex.net