Sha256: d2ebd12d018d8ed1e99c49a4a663f7f9232e563817048da8d9abafc3cb9a5cf2

Contents?: true

Size: 2 KB

Versions: 1

Compression:

Stored size: 2 KB

Contents

import { API_OPERATIONS, get, put } from 'foremanReact/redux/API';
import { renderTaskStartedToast } from '../../../../scenes/Tasks/helpers';
import { foremanApi } from '../../../../services/api';
import { getResponseErrorMsgs } from '../../../../utils/helpers';
import {
  HOST_PACKAGES_INSTALL_KEY,
  HOST_PACKAGES_KEY,
  HOST_PACKAGES_REMOVE_KEY,
  HOST_PACKAGES_UPGRADE_KEY,
} from './HostPackagesConstants';

const errorToast = (error) => {
  const message = getResponseErrorMsgs(error.response);
  return message;
};

export const getInstalledPackagesWithLatest = (hostId, params) => get({
  type: API_OPERATIONS.GET,
  key: HOST_PACKAGES_KEY,
  url: foremanApi.getApiUrl(`/hosts/${hostId}/packages?include_latest_upgradable=true`),
  params,
});
export default getInstalledPackagesWithLatest;

export const installPackageViaKatelloAgent = (hostId, params) => put({
  type: API_OPERATIONS.PUT,
  key: HOST_PACKAGES_INSTALL_KEY,
  url: foremanApi.getApiUrl(`/hosts/${hostId}/packages/install`),
  handleSuccess: ({ data }) => renderTaskStartedToast(data),
  errorToast: error => errorToast(error),
  params,
});

export const removePackageViaKatelloAgent = (hostId, params) => put({
  type: API_OPERATIONS.PUT,
  key: HOST_PACKAGES_REMOVE_KEY,
  url: foremanApi.getApiUrl(`/hosts/${hostId}/packages/remove`),
  handleSuccess: ({ data }) => renderTaskStartedToast(data),
  errorToast: error => errorToast(error),
  params,
});

export const upgradePackageViaKatelloAgent = (hostId, params) => put({
  type: API_OPERATIONS.PUT,
  key: HOST_PACKAGES_UPGRADE_KEY,
  url: foremanApi.getApiUrl(`/hosts/${hostId}/packages/upgrade`),
  handleSuccess: ({ data }) => renderTaskStartedToast(data),
  errorToast: error => errorToast(error),
  params,
});

export const upgradeAllViaKatelloAgent = hostId => put({
  type: API_OPERATIONS.PUT,
  key: HOST_PACKAGES_UPGRADE_KEY,
  url: foremanApi.getApiUrl(`/hosts/${hostId}/packages/upgrade_all`),
  handleSuccess: ({ data }) => renderTaskStartedToast(data),
  errorToast: error => errorToast(error),
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-4.4.0.rc2 webpack/components/extensions/HostDetails/HostPackages/HostPackagesActions.js