2019-08-31 20:51:14 -07:00
|
|
|
import { ApiVersion, getApiRoot } from '@datahub/utils/api/shared';
|
|
|
|
import { getJSON } from '@datahub/utils/api/fetcher';
|
|
|
|
import { encodeUrn } from '@datahub/utils/validators/urn';
|
|
|
|
|
|
|
|
/**
|
2020-09-29 16:04:25 -07:00
|
|
|
* Constructs the Dataset url root endpoint
|
|
|
|
* @param {ApiVersion} version the version of the api applicable to retrieve the Dataset
|
2019-08-31 20:51:14 -07:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2020-10-11 11:40:32 -07:00
|
|
|
const datasetUrlRoot = (version: ApiVersion): string => `${getApiRoot(version)}/datasets`;
|
2019-08-31 20:51:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs the url for a dataset identified by the provided string urn
|
|
|
|
* @param {string} urn the urn to use in querying for dataset entity
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export const datasetUrlByUrn = (urn: string): string => `${datasetUrlRoot(ApiVersion.v2)}/${encodeUrn(urn)}`;
|
|
|
|
|
2020-10-11 11:40:32 -07:00
|
|
|
/**
|
|
|
|
* Constructs the url for a dataset identified by the provided string urn
|
|
|
|
* @param {string} urn the urn to use in querying for dataset entity
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
export const datasetV1UrlByUrn = (urn: string): string => `${datasetUrlRoot(ApiVersion.v1)}/${encodeUrn(urn)}`;
|
|
|
|
|
2019-08-31 20:51:14 -07:00
|
|
|
/**
|
2020-08-26 15:44:50 -07:00
|
|
|
* Reads a dataset entity from api
|
2019-08-31 20:51:14 -07:00
|
|
|
*/
|
2020-08-26 15:44:50 -07:00
|
|
|
export const readDataset = (urn: string): Promise<Com.Linkedin.Dataset.Dataset> =>
|
|
|
|
getJSON({ url: datasetUrlByUrn(urn) });
|