UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

137 lines 6.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const axiosClient_1 = require("../../api/axiosClient"); let _getRequestAbortController = new AbortController(); const ClustersAPI = { abortLastGetRequest() { _getRequestAbortController.abort(); /** * The AbortController.signal can only be aborted once per instance. * Therefore in order for other requests to be also abortable we need * to create a new instance when this event occurs */ _getRequestAbortController = new AbortController(); }, makeBaseURI(clusterId) { return `/v2/clusters/${clusterId ? clusterId : ''}`; }, makeDownloadsBaseURI(clusterId) { return `${ClustersAPI.makeBaseURI(clusterId)}/downloads`; }, makeLogsBaseURI(clusterId) { return `${ClustersAPI.makeBaseURI(clusterId)}/logs`; }, makeDownloadsCredentialsBaseURI(clusterId) { return `${ClustersAPI.makeDownloadsBaseURI(clusterId)}/credentials`; }, makeDownloadsCredentialsPresignedBaseURI(clusterId) { return `${ClustersAPI.makeDownloadsBaseURI(clusterId)}/credentials-presigned`; }, makeDownloadsFilesPresignedBaseURI(clusterId) { return `${ClustersAPI.makeDownloadsBaseURI(clusterId)}/files-presigned`; }, makeActionsBaseURI(clusterId) { return `${ClustersAPI.makeBaseURI(clusterId)}/actions`; }, downloadClusterCredentials(clusterId, fileName) { return axiosClient_1.client.get(`${ClustersAPI.makeDownloadsCredentialsBaseURI(clusterId)}?file_name=${fileName}`, { responseType: 'blob', headers: { Accept: 'application/octet-stream', }, }); }, getPresignedForClusterCredentials({ clusterId, fileName, hostId, logsType, }) { const queryParams = `${logsType ? `&logs_type=${logsType}` : ''}${hostId ? `&host_id=${hostId}` : ''}`; return axiosClient_1.client.get(`${ClustersAPI.makeDownloadsCredentialsPresignedBaseURI(clusterId)}?file_name=${fileName}${queryParams}`); }, getPresignedForClusterFiles({ clusterId, fileName, hostId, logsType, }) { const queryParams = `${logsType ? `&logs_type=${logsType}` : ''}${hostId ? `&host_id=${hostId}` : ''}`; return axiosClient_1.client.get(`${ClustersAPI.makeDownloadsFilesPresignedBaseURI(clusterId)}?file_name=${fileName}${queryParams}`); }, list() { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI()}`, { signal: _getRequestAbortController.signal, }); }, get(clusterId) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI(clusterId)}`, { signal: _getRequestAbortController.signal, }); }, getPreflightRequirements(clusterId) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI(clusterId)}/preflight-requirements`); }, getDefaultConfig() { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI()}/default-config`); }, deregister(clusterId) { return axiosClient_1.client.delete(`${ClustersAPI.makeBaseURI(clusterId)}`); }, register(params) { return axiosClient_1.client.post(`${ClustersAPI.makeBaseURI()}`, params); }, update(clusterId, params) { return axiosClient_1.client.patch(`${ClustersAPI.makeBaseURI(clusterId)}`, params); }, install(clusterId) { return axiosClient_1.client.post(`${ClustersAPI.makeActionsBaseURI(clusterId)}/install`); }, cancel(clusterId) { return axiosClient_1.client.post(`${ClustersAPI.makeActionsBaseURI(clusterId)}/cancel`); }, reset(clusterId) { return axiosClient_1.client.post(`${ClustersAPI.makeActionsBaseURI(clusterId)}/reset`); }, registerAddHosts(params) { return axiosClient_1.client.post(`${ClustersAPI.makeBaseURI()}import`, params); }, allowAddHosts(clusterId) { return axiosClient_1.client.post(`${ClustersAPI.makeActionsBaseURI(clusterId)}/allow-add-workers`); }, downloadLogs(clusterId, hostId) { const queryParams = `logs_type=${!hostId ? 'all' : `host&host_id=${hostId}`}`; return axiosClient_1.client.get(`${ClustersAPI.makeLogsBaseURI(clusterId)}?${queryParams}`, { responseType: 'blob', headers: { Accept: 'application/octet-stream', }, }); }, getCredentials(clusterId) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI(clusterId)}/credentials`); }, listByOpenshiftId(openshiftId) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI()}?openshift_cluster_id=${openshiftId || ''}`); }, listBySubscriptionIds(subscriptionIds) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI()}?ams_subscription_ids=${subscriptionIds.toString()}`); }, getManifests(clusterId) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI(clusterId)}/manifests`); }, createCustomManifest(clusterId, params) { return axiosClient_1.client.post(`${ClustersAPI.makeBaseURI(clusterId)}/manifests`, params); }, removeCustomManifest(clusterId, folderName, fileName) { return axiosClient_1.client.delete(`${ClustersAPI.makeBaseURI(clusterId)}/manifests?folder=${folderName}&file_name=${fileName}`); }, getManifestContent(clusterId, folderName, fileName) { return axiosClient_1.client.get(`${ClustersAPI.makeBaseURI(clusterId)}/manifests/files?folder=${folderName}&file_name=${fileName}`, { responseType: 'blob', headers: { Accept: 'application/octet-stream', }, }); }, updateCustomManifest(clusterId, params) { return axiosClient_1.client.patch(`${ClustersAPI.makeBaseURI(clusterId)}/manifests`, params); }, updateInstallConfig(clusterId, config) { return axiosClient_1.client.patch(`${ClustersAPI.makeBaseURI(clusterId)}/install-config`, config, { headers: { 'Content-Type': 'application/json' }, }); }, }; exports.default = ClustersAPI; //# sourceMappingURL=ClustersAPI.js.map