2018-07-17 16:15:53 -07:00
|
|
|
import { datasetUrlByUrn } from 'wherehows-web/utils/api/datasets/shared';
|
2019-08-31 20:51:14 -07:00
|
|
|
import { getJSON } from '@datahub/utils/api/fetcher';
|
|
|
|
import { FabricType } from '@datahub/metadata-types/constants/common/fabric-type';
|
|
|
|
import { encodeUrn } from '@datahub/utils/validators/urn';
|
2018-07-17 16:15:53 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs the url to retrieve fabrics for a dataset
|
|
|
|
* @param {string} urn
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
const datasetFabricsUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/fabrics`;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches the list of fabrics for a given dataset
|
|
|
|
* @param {string} urn
|
|
|
|
* @return {Promise<Array<Fabric>>}
|
|
|
|
*/
|
2019-08-31 20:51:14 -07:00
|
|
|
const readDatasetFabricsByUrn = (urn: string): Promise<Array<FabricType>> =>
|
|
|
|
getJSON<Array<FabricType>>({ url: datasetFabricsUrlByUrn(encodeUrn(urn)) });
|
2018-07-17 16:15:53 -07:00
|
|
|
|
|
|
|
export { readDatasetFabricsByUrn };
|