mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-29 01:42:08 +00:00
Merge pull request #1279 from theseyi/sprint-7-23-retention
implements write to both retention and compliance apis for persisting…
This commit is contained in:
commit
c7bb011c7a
@ -9,6 +9,8 @@ import {
|
||||
IComplianceSuggestionResponse
|
||||
} from 'wherehows-web/typings/api/datasets/compliance';
|
||||
import { getJSON, postJSON } from 'wherehows-web/utils/api/fetcher';
|
||||
import { saveDatasetRetentionByUrn } from 'wherehows-web/utils/api/datasets/retention';
|
||||
import { extractRetentionFromComplianceInfo } from 'wherehows-web/utils/datasets/retention';
|
||||
|
||||
/**
|
||||
* Constructs the dataset compliance url
|
||||
@ -87,8 +89,10 @@ const readDatasetComplianceByUrn = async (urn: string): Promise<IReadComplianceR
|
||||
* @param {IComplianceInfo} complianceInfo
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
const saveDatasetComplianceByUrn = (urn: string, complianceInfo: IComplianceInfo): Promise<void> =>
|
||||
postJSON<void>({ url: datasetComplianceUrlByUrn(urn), data: complianceInfo });
|
||||
const saveDatasetComplianceByUrn = async (urn: string, complianceInfo: IComplianceInfo): Promise<void> => {
|
||||
await postJSON<void>({ url: datasetComplianceUrlByUrn(urn), data: complianceInfo });
|
||||
await saveDatasetRetentionByUrn(urn, extractRetentionFromComplianceInfo(complianceInfo));
|
||||
};
|
||||
|
||||
/**
|
||||
* Requests the compliance suggestions for a given dataset Id and returns the suggestion list
|
||||
|
||||
24
wherehows-web/app/utils/datasets/retention.ts
Normal file
24
wherehows-web/app/utils/datasets/retention.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { IComplianceInfo } from 'wherehows-web/typings/api/datasets/compliance';
|
||||
import { IDatasetRetention } from 'wherehows-web/typings/api/datasets/retention';
|
||||
import { fleece } from 'wherehows-web/utils/object';
|
||||
|
||||
/**
|
||||
* Extracts values from an IComplianceInfo instance to create an instance of IDatasetRetention
|
||||
* @param {IComplianceInfo} complianceInfo the compliance info object
|
||||
* @returns {IDatasetRetention}
|
||||
*/
|
||||
const extractRetentionFromComplianceInfo = (complianceInfo: IComplianceInfo): IDatasetRetention => {
|
||||
const { datasetUrn, compliancePurgeNote, complianceType } = <IComplianceInfo>fleece<IComplianceInfo>([
|
||||
'complianceType',
|
||||
'compliancePurgeNote',
|
||||
'datasetUrn'
|
||||
])(complianceInfo);
|
||||
|
||||
return {
|
||||
purgeNote: compliancePurgeNote,
|
||||
purgeType: complianceType,
|
||||
datasetUrn: datasetUrn!
|
||||
};
|
||||
};
|
||||
|
||||
export { extractRetentionFromComplianceInfo };
|
||||
Loading…
x
Reference in New Issue
Block a user