Skip to content

Commit a2cd169

Browse files
authored
Added: Get server by ID and extended options for get orders (#43)
* Added: 1. Get call for api/v3/cmp/servers/__serverId__ * 0.5.1 * Added: 1. Options for duplicate order endpoint * 0.5.2-beta.0 * Added: 1. Options for get order Removed: 1. Options for duplicate postItem API * 0.5.3-beta.0 * 0.5.3
1 parent 2132788 commit a2cd169

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
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.2",
3+
"version": "0.5.3",
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/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)