export type GetApiEtcReplicationAgentsRunmodeNameArgs = {runmode: string, name: string}; export type GetApiEtcReplicationAgentsRunmodeNameOptions = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * GET /etc/replication/agents.{runmode}/{name} */ export const getApiEtcReplicationAgentsRunmodeName = async (args: GetApiEtcReplicationAgentsRunmodeNameArgs, options: GetApiEtcReplicationAgentsRunmodeNameOptions) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/etc/replication/agents.${encodeURIComponent(String(args.runmode))}/${encodeURIComponent(String(args.name))}${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 };