import {z} from 'zod' export type IncidentGoogleMeetConfigurationPatchDataAttributesRequest = {allow_manual_meeting_creation?: boolean | undefined, auto_summarize?: boolean | undefined}; export type IncidentGoogleMeetConfigurationType = 'google_meet_configurations'; export type IncidentGoogleMeetConfigurationPatchDataRequest = {attributes?: IncidentGoogleMeetConfigurationPatchDataAttributesRequest | undefined, id: string, type: IncidentGoogleMeetConfigurationType}; export type IncidentGoogleMeetConfigurationPatchRequest = {data: IncidentGoogleMeetConfigurationPatchDataRequest}; export type PatchApiApiV2IncidentsConfigGoogleMeetConfigurationsIdArgs = {id: string, body: IncidentGoogleMeetConfigurationPatchRequest}; export type PatchApiApiV2IncidentsConfigGoogleMeetConfigurationsIdOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, appKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const incidentGoogleMeetConfigurationDataAttributesResponse = z.object({allow_manual_meeting_creation: z.boolean(), auto_summarize: z.boolean(), created_at: z.string().optional(), modified_at: z.string()}); export const usersType = z.literal("users"); export const relationshipToUserData = z.object({id: z.string(), type: usersType}); export const relationshipToUser = z.object({data: relationshipToUserData}); export const incidentTypeType = z.literal("incident_types"); export const relationshipToIncidentTypeData = z.object({id: z.string(), type: incidentTypeType}); export const relationshipToIncidentType = z.object({data: relationshipToIncidentTypeData}); export const incidentGoogleMeetConfigurationRelationships = z.object({created_by_user: relationshipToUser.optional(), incident_type: relationshipToIncidentType.optional(), last_modified_by_user: relationshipToUser.optional()}); export const incidentGoogleMeetConfigurationType = z.literal("google_meet_configurations"); export const incidentGoogleMeetConfigurationDataResponse = z.object({attributes: incidentGoogleMeetConfigurationDataAttributesResponse, id: z.string(), relationships: incidentGoogleMeetConfigurationRelationships.optional(), type: incidentGoogleMeetConfigurationType}); export const incidentUserAttributes = z.object({email: z.string().optional(), handle: z.string().optional(), icon: z.string().optional(), name: z.string().nullable().optional(), uuid: z.string().optional()}); export const incidentUserData = z.object({attributes: incidentUserAttributes.optional(), id: z.string().optional(), type: usersType.optional()}); export const incidentGoogleMeetConfigurationResponse = z.object({data: incidentGoogleMeetConfigurationDataResponse, included: z.array(incidentUserData).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update an incident Google Meet configuration * * PATCH /api/v2/incidents/config/google-meet-configurations/{id} * * Also accepts auth: AuthZ */ export const patchApiApiV2IncidentsConfigGoogleMeetConfigurationsId = async (args: PatchApiApiV2IncidentsConfigGoogleMeetConfigurationsIdArgs, options?: PatchApiApiV2IncidentsConfigGoogleMeetConfigurationsIdOptions) => { const {baseUrl = "https://api.datadoghq.com", fetch: fetchFn = fetch, apiKeyAuth, appKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (apiKeyAuth !== undefined) headers.set("DD-API-KEY", apiKeyAuth) if (appKeyAuth !== undefined) headers.set("DD-APPLICATION-KEY", appKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/incidents/config/google-meet-configurations/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 validateResponse(incidentGoogleMeetConfigurationResponse, await res.json()) };