mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-03 14:57:53 +00:00

* Releases updated version of datahub-web client UI code * Fix typo in yarn lock * Change yarn lock to match yarn registry directories * Previous commit missed some paths * Even more changes to yarnlock missing in previous commit * Include codegen file for typings * Add files to get parity for datahub-web and current OS datahub-midtier * Add in typo fix from previous commit - change to proper license * Implement proper OS fix for person entity picture url * Workarounds for open source DH issues * Fixes institutional memory api and removes unopensourced tabs for datasets * Fixes search dataset deprecation and user search issue as a result of changes * Remove internal only options in the avatar menu
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
|
|
import { IDatasetRetention, IGetDatasetRetentionResponse } from 'datahub-web/typings/api/datasets/retention';
|
|
import { omit } from 'datahub-web/utils/object';
|
|
import { isNotFoundApiError } from '@datahub/utils/api/shared';
|
|
import { datasetUrlByUrn } from '@datahub/data-models/api/dataset/dataset';
|
|
|
|
/**
|
|
* Constructs the url for a datasets retention policy
|
|
* @param {string} urn the urn for the dataset
|
|
* @return {string}
|
|
*/
|
|
const datasetRetentionUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/retention`;
|
|
|
|
/**
|
|
* Fetches the list of retention policy for a dataset by urn
|
|
* @param {string} urn urn for the dataset
|
|
* @return {Promise<Array<IDatasetEntity>>}
|
|
*/
|
|
const readDatasetRetentionByUrn = async (urn: string): Promise<IGetDatasetRetentionResponse | null> => {
|
|
try {
|
|
return await getJSON<IGetDatasetRetentionResponse>({ url: datasetRetentionUrlByUrn(urn) });
|
|
} catch (e) {
|
|
if (isNotFoundApiError(e)) {
|
|
return null;
|
|
}
|
|
|
|
throw e;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Persists the dataset retention policy remotely
|
|
* @param {string} urn the urn of the dataset to save
|
|
* @param {IDatasetRetention} retention the dataset retention policy to update
|
|
* @return {Promise<IDatasetRetention>}
|
|
*/
|
|
const saveDatasetRetentionByUrn = (urn: string, retention: IDatasetRetention): Promise<IDatasetRetention> =>
|
|
postJSON<IDatasetRetention>({
|
|
url: datasetRetentionUrlByUrn(urn),
|
|
data: omit(retention, ['modifiedBy', 'modifiedTime'])
|
|
});
|
|
|
|
export { readDatasetRetentionByUrn, saveDatasetRetentionByUrn };
|