Client API and CLI to access APIM instance of Stacker service
Stacker is a simple, trust-based resource sharing broker service. APIM Stacker is an instance of Stacker that manages a pool of APIM server stacks.
apimstacker-client
is a Nodejs client driver for APIM instance of Stacker service. Clients can use the CLI to acquire/release an apim stack manually or use API for programmatic access.
jobId {String} -- Any string can be used. naming convention: use 'test-*' for short unit test jobs, or use your email address.
jobId {String} -- jobId used in the acquire command.
shows the current state of the APIMStacker service.
acquireApimStack
is the only API currently supported. Design goal of Stacker is to add minimum
functionality and let the users cooperate. For example, multiple users can acquire the same
APIM server using the same jobId to share it. Even after it's released, the Stacker does not
prevent the releaser from access to the released APIM server. When it's
acquired by other user, multiple parties will share the resource.
-
jobId
a string to uniquely identify client -
callback
{Function} called with the acquiredserver
url. If the stacker pool is full, it will be delayed indefinitely until an APIM server url is released or expired. -server
{String} APIM server url, e.g., 'sjsldev679.dev.ciondemand.com' -releaseApimStack
{Function} the user must call this function to release it to the pool.
var JOB_ID = 'test-apis-' + (process.env.TRAVIS_JOB_ID ||
require('os').hostname() + '-' + Date.now());
require('apimstacker-client').acquireApimStack(JOB_ID,
function(server, releaseApimStack) {
// server {String} url of the acquired APIM server, e.g., 'sjsldev789.dev.ciondemand.com'
// releaseApimStack {Function}
// begin: example code to access the acquired APIM server
process.env.APIM_MANAGEMENT = server;
...
//end: example code to access the acquired APIM server
delete process.env.APIM_MANAGEMENT;
releaseApimStack();
});
Ask your Stacker administrator and get the REST endpoint, e.g., apimstacker.stage1.myblumix.net.
Shows the APIMStacker REST API help.
http://apimstacker.stage1.mybluemix.net/
____ APIM Stacker ____
-- show apim stack status:
https://apimstacker.stage1.mybluemix.net/dump-pool
-- acquire stack url:
https://apimstacker.stage1.mybluemix.net/acquire-stack/:jobid
-- release stack url:
https://apimstacker.stage1.mybluemix.net/release-stack/:jobid
Shows the current status of the APIMStacker pool.
https://apimstacker.stage1.mybluemix.net/dump-pool
{
"version":"1.0.0",
"description":"APIM Stacker",
"servers":{
"sjsldev679.dev.ciondemand.com":{"id":"","acquiredAt":0,"reachable":true,"checkedAt":0},
"sjsldev967.dev.ciondemand.com":{"id":"","acquiredAt":0,"reachable":true,"checkedAt":0},
"sjsldev803.dev.ciondemand.com":{"id":"","acquiredAt":0,"reachable":true,"checkedAt":0},
"sjsldev769.dev.ciondemand.com":{"id":"","acquiredAt":0,"reachable":true,"checkedAt":0},
"sjsldev911.dev.ciondemand.com":{"id":"","acquiredAt":0,"reachable":true,"checkedAt":0}
},
"queue":[]
}
Acquires an APIM server. The jobId can be any string that uniquely identifies the client as the acquirer. The acquired APIM server url will be released when it expires. To extend, simply call acquire-stack with the same jobId.
Unit test jobs expire much sooner (like 10 min. vs. 3 hrs) than other jobs. If the jobId starts with 'test-', it's deemed as a test job.
https://apimstacker.stage1.mybluemix.net/acquire-stack/tseto@us.ibm.com
{"jobId":"tseto@us.ibm.com","server":"sjsldev789.dev.ciondemand.com"}
Releases the acquired APIM server. The jobId is the string used when the server was acquired. The acquired APIM server url will be automatically released to the pool when it expires. Your Stacker service administrator sets the grace period, for example, three hours.
https://apimstacker.stage1.mybluemix.net/release-stack/tseto@us.ibm.com
{"jobId":"tseto@us.ibm.com","server":""}