2020-10-11 11:40:32 -07:00
|
|
|
import { putJSON } from '@datahub/utils/api/fetcher';
|
2020-08-26 15:44:50 -07:00
|
|
|
import { datasetUrlByUrn } from '@datahub/data-models/api/dataset/dataset';
|
2017-10-25 02:11:28 -07:00
|
|
|
|
2018-02-21 09:46:04 -08:00
|
|
|
/**
|
|
|
|
* Returns the url for a dataset deprecation endpoint by urn
|
|
|
|
* @param {string} urn
|
|
|
|
* @return {string}
|
|
|
|
*/
|
2019-08-31 20:51:14 -07:00
|
|
|
const datasetDeprecationUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/deprecate`;
|
2018-02-21 09:46:04 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Persists the changes to a datasets deprecation properties by urn
|
|
|
|
* @param {string} urn
|
|
|
|
* @param {boolean} deprecated
|
|
|
|
* @param {string} deprecationNote
|
2018-05-10 17:08:50 -07:00
|
|
|
* @param {Date | null} decommissionTime
|
2018-02-21 09:46:04 -08:00
|
|
|
* @return {Promise<void>}
|
|
|
|
*/
|
2020-10-11 11:40:32 -07:00
|
|
|
export const updateDatasetDeprecationByUrn = (
|
2018-03-28 08:58:23 -07:00
|
|
|
urn: string,
|
|
|
|
deprecated: boolean,
|
2020-08-26 15:44:50 -07:00
|
|
|
deprecationNote = '',
|
2018-05-10 17:08:50 -07:00
|
|
|
decommissionTime: number | null
|
2018-03-28 08:58:23 -07:00
|
|
|
): Promise<void> =>
|
2018-02-21 14:41:05 -08:00
|
|
|
putJSON<void>({
|
2018-02-21 09:46:04 -08:00
|
|
|
url: datasetDeprecationUrlByUrn(urn),
|
|
|
|
data: {
|
|
|
|
deprecated,
|
2018-03-28 08:58:23 -07:00
|
|
|
deprecationNote,
|
2018-05-10 17:08:50 -07:00
|
|
|
decommissionTime
|
2018-02-21 09:46:04 -08:00
|
|
|
}
|
|
|
|
});
|