export type GetApiApiV1DotauthSamlMetadataHostIdArgs = {hostId: string}; export type GetApiApiV1DotauthSamlMetadataHostIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Download SAML SP metadata XML for a site * * GET /api/v1/dotauth/saml/metadata/{hostId} */ export const getApiApiV1DotauthSamlMetadataHostId = async (args: GetApiApiV1DotauthSamlMetadataHostIdArgs, options: GetApiApiV1DotauthSamlMetadataHostIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/dotauth/saml/metadata/${encodeURIComponent(String(args.hostId))}${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 res.blob() };