import {z} from 'zod' export type IncidentGoogleMeetConfigurationDataAttributesRequest = {allow_manual_meeting_creation: boolean, auto_summarize: boolean}; export type IncidentTypeType = 'incident_types'; export type RelationshipToIncidentTypeData = {id: string, type: IncidentTypeType}; export type RelationshipToIncidentType = {data: RelationshipToIncidentTypeData}; export type IncidentGoogleMeetConfigurationRelationshipsRequest = {incident_type: RelationshipToIncidentType}; export type IncidentGoogleMeetConfigurationType = 'google_meet_configurations'; export type IncidentGoogleMeetConfigurationDataRequest = {attributes: IncidentGoogleMeetConfigurationDataAttributesRequest, relationships: IncidentGoogleMeetConfigurationRelationshipsRequest, type: IncidentGoogleMeetConfigurationType}; export type IncidentGoogleMeetConfigurationRequest = {data: IncidentGoogleMeetConfigurationDataRequest}; export type CreateApiApiV2IncidentsConfigGoogleMeetConfigurationsArgs = {body: IncidentGoogleMeetConfigurationRequest}; export type CreateApiApiV2IncidentsConfigGoogleMeetConfigurationsOptions = {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 }; /** * Create an incident Google Meet configuration * * POST /api/v2/incidents/config/google-meet-configurations * * Also accepts auth: AuthZ */ export const createApiApiV2IncidentsConfigGoogleMeetConfigurations = async (args: CreateApiApiV2IncidentsConfigGoogleMeetConfigurationsArgs, options?: CreateApiApiV2IncidentsConfigGoogleMeetConfigurationsOptions) => { 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${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 validateResponse(incidentGoogleMeetConfigurationResponse, await res.json()) };