Skip to content

Commit 0fb9dbf

Browse files
committed
ENG-23580 updated and pushed version
2 parents e17e357 + 90229f2 commit 0fb9dbf

File tree

9 files changed

+82
-8
lines changed

9 files changed

+82
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudbolt/cb-api-helper",
3-
"version": "0.5.1",
3+
"version": "0.5.4",
44
"scripts": {
55
"co:login": "aws sso login && aws codeartifact login --tool npm --repository cloudbolt-npm --domain cloudbolt --domain-owner 499620025628",
66
"husky:install": "husky install",

src/api/services/v3/cmp/OrdersService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default {
1515
* @param {string} id or global_id
1616
* @returns {Promise} resolves with a cloudbolt API Response object of the Order object
1717
*/
18-
get: (id) => crud.getItemById(URL, id),
18+
get: (id, options) => crud.getItemById(URL, id, options),
1919

2020
/**
2121
* Duplicated an Order by a given id

src/api/services/v3/cmp/ResourceActionsService.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,16 @@ export default {
4747
* @returns {Promise} resolves with a cloudbolt API Run Resource Action Success Response
4848
*/
4949
run: (id, runResourceAction) =>
50-
crud.postItem(`${URL}/${id}/runAction`, runResourceAction)
50+
crud.postItem(`${URL}/${id}/runAction`, runResourceAction),
51+
52+
/**
53+
* Run a Resource Action
54+
* @param {string} id or global_id
55+
* @param {object} runResourceAction Resource Action object definition
56+
* @param {array} runResourceAction.resources List of resource hrefs to run the Resource Action on
57+
* @param {object} runResourceAction.parameters Action input parameters
58+
* @returns {Promise} resolves with a cloudbolt API Run Resource Action Success Response
59+
*/
60+
runSync: (id, runResourceAction) =>
61+
crud.postItem(`${URL}/${id}/runActionSync`, runResourceAction)
5162
}

src/api/services/v3/cmp/ResourceActionsService.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,20 @@ test('run calls the correct endpoint', async () => {
8787
mockResourceAction
8888
)
8989
})
90+
91+
test('run calls the synchronous endpoint', async () => {
92+
const mockFn = jest.spyOn(baseApi, 'post').mockResolvedValue({
93+
data: { hello: 'world' }
94+
})
95+
const mockResourceAction = {
96+
resources: ['resource-href'],
97+
parameters: {
98+
param1: 'value1'
99+
}
100+
}
101+
await ResourceActionsService.runSync('resourceAction-id', mockResourceAction)
102+
expect(mockFn).toHaveBeenCalledWith(
103+
'/v3/cmp/resourceActions/resourceAction-id/runActionSync/',
104+
mockResourceAction
105+
)
106+
})

src/api/services/v3/cmp/ServerActionsService.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,16 @@ export default {
4747
* @returns {Promise} resolves with a cloudbolt API Run Server Action Success Response
4848
*/
4949
run: (id, runServerAction) =>
50-
crud.postItem(`${URL}/${id}/runAction`, runServerAction)
50+
crud.postItem(`${URL}/${id}/runAction`, runServerAction),
51+
52+
/**
53+
* Run a Server Action
54+
* @param {string} id or global_id
55+
* @param {object} runServerAction Server Action object definition
56+
* @param {array} runServerAction.servers List of server hrefs to run the Server Action on
57+
* @param {object} runServerAction.parameters Action input parameters
58+
* @returns {Promise} resolves with a cloudbolt API Run Server Action Success Response
59+
*/
60+
runSync: (id, runServerAction) =>
61+
crud.postItem(`${URL}/${id}/runActionSync`, runServerAction)
5162
}

src/api/services/v3/cmp/ServerActionsService.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,20 @@ test('run calls the correct endpoint', async () => {
8282
mockServerAction
8383
)
8484
})
85+
86+
test('run calls the synchronous endpoint', async () => {
87+
const mockFn = jest.spyOn(baseApi, 'post').mockResolvedValue({
88+
data: { hello: 'world' }
89+
})
90+
const mockServerAction = {
91+
servers: ['server-href'],
92+
parameters: {
93+
param1: 'value1'
94+
}
95+
}
96+
await ServerActionsService.runSync('serverAction-id', mockServerAction)
97+
expect(mockFn).toHaveBeenCalledWith(
98+
'/v3/cmp/serverActions/serverAction-id/runActionSync/',
99+
mockServerAction
100+
)
101+
})

src/api/services/v3/cmp/ServerService.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ export default {
99
* @returns {Promise} resolves with a paginated list of existing Resource Types
1010
*/
1111
list: (options) => crud.getItems(URL, options),
12+
13+
/**
14+
* Retrieve an existing Server by id
15+
* @param {string} id or global_id
16+
* @param {Object} options anything parsable by URLSearchParams. See useful options here https://docs.cloudbolt.io/articles/#!cloudbolt-latest-docs/api-conventions/a/h2__904191799
17+
* @returns {Promise} resolves with a cloudbolt API Response object of the Server object
18+
*/
19+
get: (id, options) => crud.getItemById(URL, id, options)
1220
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import { baseApi } from '../../../baseApi'
2-
import ServerService from './ServerService';
2+
import ServerService from './ServerService'
3+
4+
const URL = '/v3/cmp/servers/'
35

46
test('list calls the correct endpoint', async () => {
57
const mockFn = jest.spyOn(baseApi, 'get').mockResolvedValue({
68
data: [{ hello: 'world' }]
79
})
810
await ServerService.list()
9-
expect(mockFn).toHaveBeenCalledWith('/v3/cmp/servers/')
11+
expect(mockFn).toHaveBeenCalledWith(URL)
12+
})
13+
14+
test('get calls the correct endpoint', async () => {
15+
const mockFn = jest.spyOn(baseApi, 'get').mockResolvedValue({
16+
data: { hello: 'world' }
17+
})
18+
await ServerService.get('server-id')
19+
expect(mockFn).toHaveBeenCalledWith(`${URL}server-id/`)
1020
})

0 commit comments

Comments
 (0)