mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Add organization details patch and instance groups disassociate methods to api
This commit is contained in:
@@ -138,4 +138,36 @@ describe('APIClient (api.js)', () => {
|
|||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('associateInstanceGroup calls expected http method with expected data', async (done) => {
|
||||||
|
const createPromise = () => Promise.resolve();
|
||||||
|
const mockHttp = ({ post: jest.fn(createPromise) });
|
||||||
|
|
||||||
|
const api = new APIClient(mockHttp);
|
||||||
|
const url = 'foo/bar/';
|
||||||
|
const id = 1;
|
||||||
|
await api.associateInstanceGroup(url, id);
|
||||||
|
|
||||||
|
expect(mockHttp.post).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockHttp.post.mock.calls[0][0]).toEqual(url);
|
||||||
|
expect(mockHttp.post.mock.calls[0][1]).toEqual({ id });
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('disassociateInstanceGroup calls expected http method with expected data', async (done) => {
|
||||||
|
const createPromise = () => Promise.resolve();
|
||||||
|
const mockHttp = ({ post: jest.fn(createPromise) });
|
||||||
|
|
||||||
|
const api = new APIClient(mockHttp);
|
||||||
|
const url = 'foo/bar/';
|
||||||
|
const id = 1;
|
||||||
|
await api.disassociateInstanceGroup(url, id);
|
||||||
|
|
||||||
|
expect(mockHttp.post).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockHttp.post.mock.calls[0][0]).toEqual(url);
|
||||||
|
expect(mockHttp.post.mock.calls[0][1]).toEqual({ id, disassociate: true });
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
10
src/api.js
10
src/api.js
@@ -70,6 +70,12 @@ class APIClient {
|
|||||||
return this.http.get(endpoint);
|
return this.http.get(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateOrganizationDetails (id, data) {
|
||||||
|
const endpoint = `${API_ORGANIZATIONS}${id}/`;
|
||||||
|
|
||||||
|
return this.http.patch(endpoint, data);
|
||||||
|
}
|
||||||
|
|
||||||
getOrganizationInstanceGroups (id, params = {}) {
|
getOrganizationInstanceGroups (id, params = {}) {
|
||||||
const endpoint = `${API_ORGANIZATIONS}${id}/instance_groups/`;
|
const endpoint = `${API_ORGANIZATIONS}${id}/instance_groups/`;
|
||||||
|
|
||||||
@@ -113,6 +119,10 @@ class APIClient {
|
|||||||
associateInstanceGroup (url, id) {
|
associateInstanceGroup (url, id) {
|
||||||
return this.http.post(url, { id });
|
return this.http.post(url, { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disassociateInstanceGroup (url, id) {
|
||||||
|
return this.http.post(url, { id, disassociate: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default APIClient;
|
export default APIClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user