2017-04-28 22:02:46 -07:00
|
|
|
import { classifiers } from 'wherehows-web/constants';
|
|
|
|
|
2017-03-24 20:50:42 -07:00
|
|
|
/**
|
2017-04-01 14:13:28 -07:00
|
|
|
* Builds a privacyCompliancePolicy map with default / unset
|
|
|
|
* values for non null properties
|
2017-03-24 20:50:42 -07:00
|
|
|
*/
|
2017-04-28 22:02:46 -07:00
|
|
|
const createPrivacyCompliancePolicy = () => {
|
2017-03-24 20:50:42 -07:00
|
|
|
const policy = {
|
|
|
|
// default to first item in compliance types list
|
2017-03-29 18:51:26 -07:00
|
|
|
complianceType: 'AUTO_PURGE',
|
2017-03-24 20:50:42 -07:00
|
|
|
compliancePurgeEntities: []
|
|
|
|
};
|
|
|
|
|
|
|
|
// Ensure we deep clone map to prevent mutation from consumers
|
|
|
|
return JSON.parse(JSON.stringify(policy));
|
|
|
|
};
|
|
|
|
|
2017-04-01 14:13:28 -07:00
|
|
|
/**
|
|
|
|
* Builds a securitySpecification map with default / unset values
|
2017-04-28 22:02:46 -07:00
|
|
|
* for non null properties as per Avro schema
|
2017-04-01 14:13:28 -07:00
|
|
|
* @param {number} id
|
|
|
|
*/
|
2017-04-28 22:02:46 -07:00
|
|
|
const createSecuritySpecification = id => {
|
|
|
|
const classification = classifiers.reduce((classification, classifier) => {
|
|
|
|
classification[classifier] = [];
|
|
|
|
return classification;
|
|
|
|
}, {});
|
2017-03-24 20:50:42 -07:00
|
|
|
|
2017-04-01 14:13:28 -07:00
|
|
|
const securitySpecification = {
|
|
|
|
classification,
|
|
|
|
datasetId: id,
|
|
|
|
geographicAffinity: { affinity: '' },
|
|
|
|
recordOwnerType: '',
|
2017-05-01 22:58:16 -07:00
|
|
|
retentionPolicy: { retentionType: '' },
|
|
|
|
datasetClassification: {}
|
2017-03-29 18:51:26 -07:00
|
|
|
};
|
2017-04-01 14:13:28 -07:00
|
|
|
|
|
|
|
return JSON.parse(JSON.stringify(securitySpecification));
|
|
|
|
};
|
2017-04-28 22:02:46 -07:00
|
|
|
|
|
|
|
export { createSecuritySpecification, createPrivacyCompliancePolicy };
|