@osaas/client-core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core.d.ts +53 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +53 -0
- package/lib/core.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/job.d.ts +62 -0
- package/lib/job.d.ts.map +1 -1
- package/lib/job.js +62 -0
- package/lib/job.js.map +1 -1
- package/package.json +2 -2
package/lib/core.d.ts
CHANGED
|
@@ -1,7 +1,60 @@
|
|
|
1
1
|
import { Context, Service } from './context';
|
|
2
2
|
export declare function getService(context: Context, serviceId: string): Promise<Service>;
|
|
3
|
+
/**
|
|
4
|
+
* @typedef ServiceInstance
|
|
5
|
+
* @type object
|
|
6
|
+
* @property {string} name - Service instance name
|
|
7
|
+
* @property {string} url - Service instance URL
|
|
8
|
+
* @property ... - Service specific properties
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of a service in Open Source Cloud
|
|
12
|
+
* @memberof module:@osaas/client-core
|
|
13
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
14
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
15
|
+
* @param {string} token - Service access token
|
|
16
|
+
* @param {object} body - Service instance options. The options are service specific
|
|
17
|
+
* @returns {ServiceInstance} - Service instance
|
|
18
|
+
* @example
|
|
19
|
+
* import { Context, createInstance } from '@osaas/client-core';
|
|
20
|
+
*
|
|
21
|
+
* const ctx = new Context();
|
|
22
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
23
|
+
* const instance = await createInstance(ctx, 'eyevinn-test-adserver', sat, { name: 'my-instance' });
|
|
24
|
+
* console.log(instance.url);
|
|
25
|
+
*/
|
|
3
26
|
export declare function createInstance(context: Context, serviceId: string, token: string, body: any): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Remove an instance of a service in Open Source Cloud
|
|
29
|
+
* @memberof module:@osaas/client-core
|
|
30
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
31
|
+
* @param {string} serviceId - The service identifier
|
|
32
|
+
* @param {string} name - The name of the service instance to remove
|
|
33
|
+
* @param {string} token - Service access token
|
|
34
|
+
* @example
|
|
35
|
+
* import { Context, removeInstance } from '@osaas/client-core';
|
|
36
|
+
* const ctx = new Context();
|
|
37
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
38
|
+
* await removeInstance(ctx, 'eyevinn-test-adserver', 'my-instance', sat);
|
|
39
|
+
*/
|
|
4
40
|
export declare function removeInstance(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve an instance of a service in Open Source Cloud
|
|
43
|
+
* @memberof module:@osaas/client-core
|
|
44
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
45
|
+
* @param {string} serviceId - The service identifier
|
|
46
|
+
* @param {string} name - The name of the service instance to remove
|
|
47
|
+
* @param {string} token - Service access token
|
|
48
|
+
* @returns {ServiceInstance} - Service instance
|
|
49
|
+
*/
|
|
5
50
|
export declare function getInstance(context: Context, serviceId: string, name: string, token: string): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* List all instances of a service in Open Source Cloud
|
|
53
|
+
* @memberof module:@osaas/client-core
|
|
54
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
55
|
+
* @param {string} serviceId - The service identifier
|
|
56
|
+
* @param {string} token - Service access token
|
|
57
|
+
* @returns {Array.<ServiceInstance>} - List of instances
|
|
58
|
+
*/
|
|
6
59
|
export declare function listInstances(context: Context, serviceId: string, token: string): Promise<any>;
|
|
7
60
|
//# sourceMappingURL=core.d.ts.map
|
package/lib/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7C,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAgBnE;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CAad;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBAYd;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,gBAkBd;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAYd"}
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7C,wBAAsB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAgBnE;AAED;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CAad;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBAYd;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,gBAkBd;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,gBAYd"}
|
package/lib/core.js
CHANGED
|
@@ -19,6 +19,29 @@ async function getService(context, serviceId) {
|
|
|
19
19
|
return service;
|
|
20
20
|
}
|
|
21
21
|
exports.getService = getService;
|
|
22
|
+
/**
|
|
23
|
+
* @typedef ServiceInstance
|
|
24
|
+
* @type object
|
|
25
|
+
* @property {string} name - Service instance name
|
|
26
|
+
* @property {string} url - Service instance URL
|
|
27
|
+
* @property ... - Service specific properties
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Create a new instance of a service in Open Source Cloud
|
|
31
|
+
* @memberof module:@osaas/client-core
|
|
32
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
33
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
34
|
+
* @param {string} token - Service access token
|
|
35
|
+
* @param {object} body - Service instance options. The options are service specific
|
|
36
|
+
* @returns {ServiceInstance} - Service instance
|
|
37
|
+
* @example
|
|
38
|
+
* import { Context, createInstance } from '@osaas/client-core';
|
|
39
|
+
*
|
|
40
|
+
* const ctx = new Context();
|
|
41
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
42
|
+
* const instance = await createInstance(ctx, 'eyevinn-test-adserver', sat, { name: 'my-instance' });
|
|
43
|
+
* console.log(instance.url);
|
|
44
|
+
*/
|
|
22
45
|
async function createInstance(context, serviceId, token, body) {
|
|
23
46
|
const service = await getService(context, serviceId);
|
|
24
47
|
const instanceUrl = new URL(service.apiUrl);
|
|
@@ -33,6 +56,19 @@ async function createInstance(context, serviceId, token, body) {
|
|
|
33
56
|
return instance;
|
|
34
57
|
}
|
|
35
58
|
exports.createInstance = createInstance;
|
|
59
|
+
/**
|
|
60
|
+
* Remove an instance of a service in Open Source Cloud
|
|
61
|
+
* @memberof module:@osaas/client-core
|
|
62
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
63
|
+
* @param {string} serviceId - The service identifier
|
|
64
|
+
* @param {string} name - The name of the service instance to remove
|
|
65
|
+
* @param {string} token - Service access token
|
|
66
|
+
* @example
|
|
67
|
+
* import { Context, removeInstance } from '@osaas/client-core';
|
|
68
|
+
* const ctx = new Context();
|
|
69
|
+
* const sat = await ctx.getServiceAccessToken('eyevinn-test-adserver');
|
|
70
|
+
* await removeInstance(ctx, 'eyevinn-test-adserver', 'my-instance', sat);
|
|
71
|
+
*/
|
|
36
72
|
async function removeInstance(context, serviceId, name, token) {
|
|
37
73
|
const service = await getService(context, serviceId);
|
|
38
74
|
const instanceUrl = new URL(service.apiUrl + '/' + name);
|
|
@@ -45,6 +81,15 @@ async function removeInstance(context, serviceId, name, token) {
|
|
|
45
81
|
});
|
|
46
82
|
}
|
|
47
83
|
exports.removeInstance = removeInstance;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieve an instance of a service in Open Source Cloud
|
|
86
|
+
* @memberof module:@osaas/client-core
|
|
87
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
88
|
+
* @param {string} serviceId - The service identifier
|
|
89
|
+
* @param {string} name - The name of the service instance to remove
|
|
90
|
+
* @param {string} token - Service access token
|
|
91
|
+
* @returns {ServiceInstance} - Service instance
|
|
92
|
+
*/
|
|
48
93
|
async function getInstance(context, serviceId, name, token) {
|
|
49
94
|
const service = await getService(context, serviceId);
|
|
50
95
|
const instanceUrl = new URL(service.apiUrl + '/' + name);
|
|
@@ -64,6 +109,14 @@ async function getInstance(context, serviceId, name, token) {
|
|
|
64
109
|
return undefined;
|
|
65
110
|
}
|
|
66
111
|
exports.getInstance = getInstance;
|
|
112
|
+
/**
|
|
113
|
+
* List all instances of a service in Open Source Cloud
|
|
114
|
+
* @memberof module:@osaas/client-core
|
|
115
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
116
|
+
* @param {string} serviceId - The service identifier
|
|
117
|
+
* @param {string} token - Service access token
|
|
118
|
+
* @returns {Array.<ServiceInstance>} - List of instances
|
|
119
|
+
*/
|
|
67
120
|
async function listInstances(context, serviceId, token) {
|
|
68
121
|
const service = await getService(context, serviceId);
|
|
69
122
|
const instanceUrl = new URL(service.apiUrl);
|
package/lib/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AACA,mCAAsC;AACtC,+BAA4B;AAErB,KAAK,UAAU,UAAU,CAAC,OAAgB,EAAE,SAAiB;IAClE,MAAM,UAAU,GAAG,IAAI,GAAG,CACxB,uBAAuB,OAAO,CAAC,cAAc,EAAE,2BAA2B,CAC3E,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAW,EAAY,UAAU,EAAE;QACxD,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,WAAW,EAAE,UAAU,OAAO,CAAC,sBAAsB,EAAE,EAAE;YACzD,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,WAAW,SAAS,kCAAkC,CAAC,CAAC;KACzE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAhBD,gCAgBC;
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;AACA,mCAAsC;AACtC,+BAA4B;AAErB,KAAK,UAAU,UAAU,CAAC,OAAgB,EAAE,SAAiB;IAClE,MAAM,UAAU,GAAG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W,EAAM,WAAW,EAAE;QACzC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,OAAO,EAAE,UAAU,KAAK,EAAE;YAC1B,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC,CAAC;AACL,CAAC;AAfD,sCAeC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,OAAO,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.removeJob = exports.createJob = exports.listInstances = exports.getInstance = exports.removeInstance = exports.createInstance = exports.Context = exports.createFetch = exports.Log = void 0;
|
|
4
|
+
/** @module @osaas/client-core */
|
|
4
5
|
var log_1 = require("./log");
|
|
5
6
|
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return log_1.Log; } });
|
|
6
7
|
var fetch_1 = require("./fetch");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+BAKgB;AAJd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AAEf,6BAMe;AALb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,2GAAA,oBAAoB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AACZ,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+BAKgB;AAJd,sGAAA,cAAc,OAAA;AACd,sGAAA,cAAc,OAAA;AACd,mGAAA,WAAW,OAAA;AACX,qGAAA,aAAa,OAAA;AAEf,6BAMe;AALb,gGAAA,SAAS,OAAA;AACT,gGAAA,SAAS,OAAA;AACT,6FAAA,MAAM,OAAA;AACN,+FAAA,QAAQ,OAAA;AACR,2GAAA,oBAAoB,OAAA"}
|
package/lib/job.d.ts
CHANGED
|
@@ -1,7 +1,69 @@
|
|
|
1
1
|
import { Context } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef ServiceJob
|
|
4
|
+
* @type object
|
|
5
|
+
* @property {string} name - Service job name
|
|
6
|
+
* @property ... - Service specific job properties
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Create a new service job in Open Source Cloud
|
|
10
|
+
* @memberof module:@osaas/client-core
|
|
11
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
12
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
13
|
+
* @param {string} token - Service access token
|
|
14
|
+
* @param {object} body - Service job options. The options are service specific
|
|
15
|
+
* @returns {ServiceJob} - Service job. The job is specific to the service
|
|
16
|
+
* @example
|
|
17
|
+
* import { Context, createJob } from '@osaas/client-core';
|
|
18
|
+
* const serviceAccessToken = await ctx.getServiceAccessToken(
|
|
19
|
+
* 'eyevinn-docker-retransfer'
|
|
20
|
+
* );
|
|
21
|
+
* const job = await createJob(
|
|
22
|
+
* ctx,
|
|
23
|
+
* 'eyevinn-docker-retransfer',
|
|
24
|
+
* serviceAccessToken,
|
|
25
|
+
* {
|
|
26
|
+
* name: 'example',
|
|
27
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
28
|
+
* awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
29
|
+
* cmdLineArgs: 's3://source/myfile.txt s3://dest/'
|
|
30
|
+
* }
|
|
31
|
+
* );
|
|
32
|
+
*/
|
|
2
33
|
export declare function createJob(context: Context, serviceId: string, token: string, body: any): Promise<any>;
|
|
34
|
+
/**
|
|
35
|
+
* Remove a service job in Open Source Cloud
|
|
36
|
+
* @memberof module:@osaas/client-core
|
|
37
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
38
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
39
|
+
* @param {string} name - Name of service job to remove
|
|
40
|
+
* @param {string} token - Service access token
|
|
41
|
+
*/
|
|
3
42
|
export declare function removeJob(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Get a service job in Open Source Cloud
|
|
45
|
+
* @memberof module:@osaas/client-core
|
|
46
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
47
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
48
|
+
* @param {string} name - Name of service job to read
|
|
49
|
+
* @param {string} token - Service access token
|
|
50
|
+
*/
|
|
4
51
|
export declare function getJob(context: Context, serviceId: string, name: string, token: string): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* List service jobs in Open Source Cloud
|
|
54
|
+
* @memberof module:@osaas/client-core
|
|
55
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
56
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
57
|
+
* @param {string} token - Service access token
|
|
58
|
+
*/
|
|
5
59
|
export declare function listJobs(context: Context, serviceId: string, token: string): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* Wait for a service job to complete
|
|
62
|
+
* @memberof module:@osaas/client-core
|
|
63
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
64
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
65
|
+
* @param {string} name - Name of service job to wait for
|
|
66
|
+
* @param {string} token - Service access token
|
|
67
|
+
*/
|
|
6
68
|
export declare function waitForJobToComplete(context: Context, serviceId: string, name: string, token: string): Promise<void>;
|
|
7
69
|
//# sourceMappingURL=job.d.ts.map
|
package/lib/job.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,wBAAsB,SAAS,CAC7B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,GACR,OAAO,CAAC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;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,iBASd"}
|
package/lib/job.js
CHANGED
|
@@ -4,6 +4,37 @@ exports.waitForJobToComplete = exports.listJobs = exports.getJob = exports.remov
|
|
|
4
4
|
const core_1 = require("./core");
|
|
5
5
|
const MAX_ITER = 1000;
|
|
6
6
|
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
7
|
+
/**
|
|
8
|
+
* @typedef ServiceJob
|
|
9
|
+
* @type object
|
|
10
|
+
* @property {string} name - Service job name
|
|
11
|
+
* @property ... - Service specific job properties
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Create a new service job in Open Source Cloud
|
|
15
|
+
* @memberof module:@osaas/client-core
|
|
16
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
17
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
18
|
+
* @param {string} token - Service access token
|
|
19
|
+
* @param {object} body - Service job options. The options are service specific
|
|
20
|
+
* @returns {ServiceJob} - Service job. The job is specific to the service
|
|
21
|
+
* @example
|
|
22
|
+
* import { Context, createJob } from '@osaas/client-core';
|
|
23
|
+
* const serviceAccessToken = await ctx.getServiceAccessToken(
|
|
24
|
+
* 'eyevinn-docker-retransfer'
|
|
25
|
+
* );
|
|
26
|
+
* const job = await createJob(
|
|
27
|
+
* ctx,
|
|
28
|
+
* 'eyevinn-docker-retransfer',
|
|
29
|
+
* serviceAccessToken,
|
|
30
|
+
* {
|
|
31
|
+
* name: 'example',
|
|
32
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
33
|
+
* awsSecretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
34
|
+
* cmdLineArgs: 's3://source/myfile.txt s3://dest/'
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
*/
|
|
7
38
|
async function createJob(context, serviceId, token, body) {
|
|
8
39
|
const service = await (0, core_1.getService)(context, serviceId);
|
|
9
40
|
if (service.serviceType !== 'job') {
|
|
@@ -12,6 +43,14 @@ async function createJob(context, serviceId, token, body) {
|
|
|
12
43
|
return await (0, core_1.createInstance)(context, serviceId, token, body);
|
|
13
44
|
}
|
|
14
45
|
exports.createJob = createJob;
|
|
46
|
+
/**
|
|
47
|
+
* Remove a service job in Open Source Cloud
|
|
48
|
+
* @memberof module:@osaas/client-core
|
|
49
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
50
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
51
|
+
* @param {string} name - Name of service job to remove
|
|
52
|
+
* @param {string} token - Service access token
|
|
53
|
+
*/
|
|
15
54
|
async function removeJob(context, serviceId, name, token) {
|
|
16
55
|
const service = await (0, core_1.getService)(context, serviceId);
|
|
17
56
|
if (service.serviceType !== 'job') {
|
|
@@ -20,6 +59,14 @@ async function removeJob(context, serviceId, name, token) {
|
|
|
20
59
|
return await (0, core_1.removeInstance)(context, serviceId, name, token);
|
|
21
60
|
}
|
|
22
61
|
exports.removeJob = removeJob;
|
|
62
|
+
/**
|
|
63
|
+
* Get a service job in Open Source Cloud
|
|
64
|
+
* @memberof module:@osaas/client-core
|
|
65
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
66
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
67
|
+
* @param {string} name - Name of service job to read
|
|
68
|
+
* @param {string} token - Service access token
|
|
69
|
+
*/
|
|
23
70
|
async function getJob(context, serviceId, name, token) {
|
|
24
71
|
const service = await (0, core_1.getService)(context, serviceId);
|
|
25
72
|
if (service.serviceType !== 'job') {
|
|
@@ -28,6 +75,13 @@ async function getJob(context, serviceId, name, token) {
|
|
|
28
75
|
return await (0, core_1.getInstance)(context, serviceId, name, token);
|
|
29
76
|
}
|
|
30
77
|
exports.getJob = getJob;
|
|
78
|
+
/**
|
|
79
|
+
* List service jobs in Open Source Cloud
|
|
80
|
+
* @memberof module:@osaas/client-core
|
|
81
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
82
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
83
|
+
* @param {string} token - Service access token
|
|
84
|
+
*/
|
|
31
85
|
async function listJobs(context, serviceId, token) {
|
|
32
86
|
const service = await (0, core_1.getService)(context, serviceId);
|
|
33
87
|
if (service.serviceType !== 'job') {
|
|
@@ -36,6 +90,14 @@ async function listJobs(context, serviceId, token) {
|
|
|
36
90
|
return await (0, core_1.listInstances)(context, serviceId, token);
|
|
37
91
|
}
|
|
38
92
|
exports.listJobs = listJobs;
|
|
93
|
+
/**
|
|
94
|
+
* Wait for a service job to complete
|
|
95
|
+
* @memberof module:@osaas/client-core
|
|
96
|
+
* @param {Context} context - Open Source Cloud configuration context
|
|
97
|
+
* @param {string} serviceId - Service identifier. The service identifier is {github-organization}-{github-repo}
|
|
98
|
+
* @param {string} name - Name of service job to wait for
|
|
99
|
+
* @param {string} token - Service access token
|
|
100
|
+
*/
|
|
39
101
|
async function waitForJobToComplete(context, serviceId, name, token) {
|
|
40
102
|
for (const _ of Array(MAX_ITER)) {
|
|
41
103
|
const job = await getJob(context, serviceId, name, token);
|
package/lib/job.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":";;;AACA,iCAMgB;AAEhB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":";;;AACA,iCAMgB;AAEhB,MAAM,QAAQ,GAA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,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,OAAO,MAAM,IAAA,kBAAW,EAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC;AAXD,wBAWC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,QAAQ,CAC5B,OAAgB,EAChB,SAAiB,EACjB,KAAa;IAEb,MAAM,OAAO,GAAG,MAAM,IAAA,iBAAU,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IACD,OAAO,MAAM,IAAA,oBAAa,EAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAVD,4BAUC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAAgB,EAChB,SAAiB,EACjB,IAAY,EACZ,KAAa;IAEb,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC/B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,GAAG,CAAC,MAAM,KAAK,UAAU,EAAE;YAC7B,MAAM;SACP;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;KACnB;AACH,CAAC;AAbD,oDAaC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osaas/client-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Open Source Cloud Client SDK core library",
|
|
5
5
|
"author": "Eyevinn Technology <work@eyevinn.se>",
|
|
6
6
|
"homepage": "https://www.osaas.io",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0d54f545a51a26df68290fc3a3bcfce2ce2851aa"
|
|
35
35
|
}
|