diff --git a/src/resources/Catalogs/CatalogContent.ts b/src/resources/Catalogs/CatalogContent.ts index 213f9d951..5f99572bb 100644 --- a/src/resources/Catalogs/CatalogContent.ts +++ b/src/resources/Catalogs/CatalogContent.ts @@ -1,6 +1,12 @@ import API from '../../APICore.js'; import Resource from '../Resource.js'; -import {CatalogMetadata, CatalogMetadataName, CatalogObjectType} from './CatalogInterfaces.js'; +import {MetadataPageModel} from '../Sources/index.js'; +import { + CatalogMetadata, + CatalogMetadataName, + CatalogMetadataNameParams, + CatalogObjectType, +} from './CatalogInterfaces.js'; export type ObjectType = { objectType: string; @@ -24,4 +30,10 @@ export default class CatalogContent extends Resource { this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, objectType), ); } + + getMetadataV2(sourceId: string, params?: CatalogMetadataNameParams) { + return this.api.get( + this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, params), + ); + } } diff --git a/src/resources/Catalogs/CatalogInterfaces.ts b/src/resources/Catalogs/CatalogInterfaces.ts index 88b21d51a..c41ea0ad1 100644 --- a/src/resources/Catalogs/CatalogInterfaces.ts +++ b/src/resources/Catalogs/CatalogInterfaces.ts @@ -1,3 +1,5 @@ +import {Paginated} from '../BaseInterfaces.js'; + export interface CatalogsListOptions { /** * Filter that will be matched against the catalog name, description and its configuration name. @@ -457,3 +459,19 @@ export interface CatalogMetadataName { */ metadataNames: string[]; } + +export interface CatalogMetadataNameParams extends Paginated { + /** + * Object type parameter. + */ + objectType: string; + /** + * Filters applied to the returned metadata. Only applies to metadata names, not values or origins. + */ + filter?: string; + + /** + * Indicate the version of MetadataName call + */ + version?: number; +} diff --git a/src/resources/Catalogs/tests/CatalogContent.spec.ts b/src/resources/Catalogs/tests/CatalogContent.spec.ts index abcb722ca..5c63da833 100644 --- a/src/resources/Catalogs/tests/CatalogContent.spec.ts +++ b/src/resources/Catalogs/tests/CatalogContent.spec.ts @@ -1,5 +1,6 @@ import API from '../../../APICore.js'; import CatalogContent, {ObjectType} from '../CatalogContent.js'; +import {CatalogMetadataNameParams} from '../CatalogInterfaces.js'; import queryString from '#query-string'; jest.mock('../../../APICore.js'); @@ -55,4 +56,25 @@ describe('CatalogContent', () => { ); }); }); + + describe('getMetadataV2', () => { + it('should make a GET call to the specific metadataName url', () => { + const defaultOptions: queryString.StringifyOptions = {skipEmptyString: true, skipNull: true, sort: false}; + const sourceId = 'KFC'; + + const params: CatalogMetadataNameParams = { + objectType: 'provigo', + filter: 'a', + version: 2, + page: 0, + perPage: 100, + }; + + metadata.getMetadataV2(sourceId, params); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith( + `${baseUrl}/${sourceId}/metadata?${queryString.stringify(params, {...defaultOptions})}`, + ); + }); + }); });