export type ExternalToken = string; export type BasicAuth = {user: string, password: string}; export type Exclude = {clusters?: Array | undefined, appServices?: Array | undefined}; export type WebhookCustomPayload = {payload: {[key: string]: unknown}}; export type RequestWebhook = {method: 'POST' | 'PUT', url: string, token?: ExternalToken | undefined, basicAuth?: BasicAuth | undefined, headers?: {[key: string]: string} | undefined, exclude?: Exclude | undefined, customPayloads?: {[key: string]: WebhookCustomPayload} | undefined}; export type TestRequestSlack = {webhookURL?: string | undefined, webhookUrl?: string | undefined, channelName?: string | undefined, channel?: string | undefined, botToken?: string | undefined}; export type TestRequestTeams = {url: string}; export type CreateApiV4OrganizationsOrganizationIdProjectsProjectIdAlertIntegrationTestArgs = {body: {kind: 'webhook', config: {webhook: RequestWebhook, slack?: TestRequestSlack | undefined, teams?: TestRequestTeams | undefined} | {webhook: RequestWebhook, slack: TestRequestSlack, teams?: TestRequestTeams | undefined} | {webhook: RequestWebhook, slack?: TestRequestSlack | undefined, teams: TestRequestTeams}} | {kind: 'slack', config: {webhook: RequestWebhook, slack: TestRequestSlack, teams?: TestRequestTeams | undefined} | {webhook?: RequestWebhook | undefined, slack: TestRequestSlack, teams?: TestRequestTeams | undefined} | {webhook?: RequestWebhook | undefined, slack: TestRequestSlack, teams: TestRequestTeams}} | {kind: 'teams', config: {webhook: RequestWebhook, slack?: TestRequestSlack | undefined, teams: TestRequestTeams} | {webhook?: RequestWebhook | undefined, slack: TestRequestSlack, teams: TestRequestTeams} | {webhook?: RequestWebhook | undefined, slack?: TestRequestSlack | undefined, teams: TestRequestTeams}}}; export type CreateApiV4OrganizationsOrganizationIdProjectsProjectIdAlertIntegrationTestOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * Test Alert Integration * * POST /v4/organizations/{organizationId}/projects/{projectId}/alertIntegrationTest */ export const createApiV4OrganizationsOrganizationIdProjectsProjectIdAlertIntegrationTest = async (args: CreateApiV4OrganizationsOrganizationIdProjectsProjectIdAlertIntegrationTestArgs, options?: CreateApiV4OrganizationsOrganizationIdProjectsProjectIdAlertIntegrationTestOptions) => { const {baseUrl = "https://cloudapi.cloud.couchbase.com", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/v4/organizations/${encodeURIComponent(String(args.organizationId))}/projects/${encodeURIComponent(String(args.projectId))}/alertIntegrationTest${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };