When searching for a package, all matching packages are now returned. First an attempt is made using the api's default limit and if there are more matching packages than the default limit a second request is made with an increased limit. To facilitate this, api.getPackages() now accepts an optional limit parameter. Retrieving all matching packages is necessary because of the sorting logic.
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
import axios from 'axios';
|
|
import {
|
|
IMAGE_BUILDER_API,
|
|
RHSM_API,
|
|
} from './constants';
|
|
|
|
const postHeaders = { headers: { 'Content-Type': 'application/json' }};
|
|
|
|
async function composeImage(body) {
|
|
let path = '/compose';
|
|
const request = await axios.post(IMAGE_BUILDER_API.concat(path), body, postHeaders);
|
|
return request.data;
|
|
}
|
|
|
|
async function getComposes(limit, offset) {
|
|
const params = new URLSearchParams({
|
|
limit,
|
|
offset,
|
|
});
|
|
let path = '/composes?' + params.toString();
|
|
const request = await axios.get(IMAGE_BUILDER_API.concat(path));
|
|
return request.data;
|
|
}
|
|
|
|
async function getComposeStatus(id) {
|
|
let path = '/composes/' + id;
|
|
const request = await axios.get(IMAGE_BUILDER_API.concat(path));
|
|
return request.data;
|
|
}
|
|
|
|
async function getPackages(distribution, architecture, search, limit) {
|
|
const params = new URLSearchParams({
|
|
distribution,
|
|
architecture,
|
|
search,
|
|
});
|
|
limit && params.append('limit', limit);
|
|
let path = '/packages?' + params.toString();
|
|
const request = await axios.get(IMAGE_BUILDER_API.concat(path));
|
|
return request.data;
|
|
}
|
|
|
|
async function getVersion() {
|
|
let path = '/version';
|
|
const request = await axios.get(IMAGE_BUILDER_API.concat(path));
|
|
return request.data;
|
|
}
|
|
|
|
async function getActivationKeys() {
|
|
const path = '/activation_keys';
|
|
const request = await axios.get(RHSM_API.concat(path));
|
|
return request.data.body;
|
|
}
|
|
|
|
export default {
|
|
composeImage,
|
|
getComposes,
|
|
getComposeStatus,
|
|
getPackages,
|
|
getVersion,
|
|
getActivationKeys,
|
|
};
|