export type GetApiMetadataSiteStudyDataPackageVersionArgs = {data_package: string, version: string, study: string, site: string}; export type GetApiMetadataSiteStudyDataPackageVersionOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /metadata/{site}/{study}/{data_package}/{version} */ export const getApiMetadataSiteStudyDataPackageVersion = async (args: GetApiMetadataSiteStudyDataPackageVersionArgs, options?: GetApiMetadataSiteStudyDataPackageVersionOptions) => { const {baseUrl = "https://aggregator.smartcumulus.org", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("x-api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/metadata/${encodeURIComponent(String(args.site))}/${encodeURIComponent(String(args.study))}/${encodeURIComponent(String(args.data_package))}/${encodeURIComponent(String(args.version))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };