import {z} from 'zod' export type MonitorRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, monitorTemplateId?: boolean | undefined, autoProvisionedNetworkDeviceId?: boolean | undefined, networkAlertPolicyId?: boolean | undefined, monitorType?: boolean | undefined, currentMonitorStatusId?: boolean | undefined, monitorSteps?: boolean | undefined}; export type HostRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, hostIdentifier?: boolean | undefined, otelCollectorStatus?: boolean | undefined, agentVersion?: boolean | undefined, lastSeenAt?: boolean | undefined, osType?: boolean | undefined, osVersion?: boolean | undefined, hostId?: boolean | undefined, hostArch?: boolean | undefined, hostType?: boolean | undefined, hostIpAddresses?: boolean | undefined, cpuCores?: boolean | undefined, totalMemoryBytes?: boolean | undefined, processCount?: boolean | undefined, containerRuntime?: boolean | undefined, deploymentEnvironment?: boolean | undefined, runtimeName?: boolean | undefined, runtimeVersion?: boolean | undefined, cloudProvider?: boolean | undefined, cloudPlatform?: boolean | undefined, cloudRegion?: boolean | undefined, cloudAccountId?: boolean | undefined, latestCpuPercent?: boolean | undefined, latestMemoryPercent?: boolean | undefined, latestSwapPercent?: boolean | undefined, latestDiskPercent?: boolean | undefined, latestDiskMountpoint?: boolean | undefined, latestInodesPercent?: boolean | undefined, latestInodesMountpoint?: boolean | undefined, latestLoadAverage15m?: boolean | undefined, bootedAt?: boolean | undefined, failedSystemdUnitCount?: boolean | undefined, failedSystemdUnits?: boolean | undefined, readingsUpdatedAt?: boolean | undefined}; export type KubernetesClusterRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, clusterIdentifier?: boolean | undefined, provider?: boolean | undefined, otelCollectorStatus?: boolean | undefined, agentVersion?: boolean | undefined, lastSeenAt?: boolean | undefined, aiAccessRunnerId?: boolean | undefined}; export type DockerHostRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, hostIdentifier?: boolean | undefined, otelCollectorStatus?: boolean | undefined, agentVersion?: boolean | undefined, lastSeenAt?: boolean | undefined, osType?: boolean | undefined, osVersion?: boolean | undefined}; export type PodmanHostRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, hostIdentifier?: boolean | undefined, otelCollectorStatus?: boolean | undefined, agentVersion?: boolean | undefined, lastSeenAt?: boolean | undefined, osType?: boolean | undefined, osVersion?: boolean | undefined}; export type ServiceRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, serviceColor?: boolean | undefined, serviceLanguage?: boolean | undefined, techStack?: boolean | undefined, lastSeenAt?: boolean | undefined, serviceVersion?: boolean | undefined, deploymentEnvironment?: boolean | undefined, serviceNamespace?: boolean | undefined, runtimeName?: boolean | undefined, runtimeVersion?: boolean | undefined, telemetrySdkLanguage?: boolean | undefined, cloudProvider?: boolean | undefined, cloudPlatform?: boolean | undefined, cloudRegion?: boolean | undefined, cloudAccountId?: boolean | undefined}; export type OnCallDutyPolicyRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, repeatPolicyIfNoOneAcknowledgesNoOfTimes?: boolean | undefined}; export type StatusPageRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, smtpConfigId?: boolean | undefined, callSmsConfigId?: boolean | undefined, defaultBarColor?: boolean | undefined, subscriberEmailNotificationFooterText?: boolean | undefined}; export type LabelRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, projectId?: boolean | undefined, color?: boolean | undefined, isArchived?: boolean | undefined}; export type IncidentTemplateSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, title?: boolean | undefined, templateName?: boolean | undefined, templateDescription?: boolean | undefined, description?: boolean | undefined, slug?: boolean | undefined, createdByUserId?: boolean | undefined, monitors?: MonitorRelationSelectSchema | undefined, hosts?: HostRelationSelectSchema | undefined, kubernetesClusters?: KubernetesClusterRelationSelectSchema | undefined, dockerHosts?: DockerHostRelationSelectSchema | undefined, podmanHosts?: PodmanHostRelationSelectSchema | undefined, services?: ServiceRelationSelectSchema | undefined, onCallDutyPolicies?: OnCallDutyPolicyRelationSelectSchema | undefined, statusPages?: StatusPageRelationSelectSchema | undefined, labels?: LabelRelationSelectSchema | undefined, incidentSeverityId?: boolean | undefined, changeMonitorStatusToId?: boolean | undefined, initialIncidentStateId?: boolean | undefined, customFields?: boolean | undefined, customFieldSettings?: boolean | undefined}; export type CreateApiIncidentTemplatesIdGetItemArgs = {id: string, body: {select?: IncidentTemplateSelectSchema | undefined}}; export type CreateApiIncidentTemplatesIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const incidentTemplate = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), projectId: z.string(), title: z.string(), templateName: z.string(), templateDescription: z.string(), description: z.string().optional(), slug: z.string(), createdByUserId: z.string().optional(), monitors: z.array(z.object({_id: z.string().optional()})).optional(), hosts: z.array(z.object({_id: z.string().optional()})).optional(), kubernetesClusters: z.array(z.object({_id: z.string().optional()})).optional(), dockerHosts: z.array(z.object({_id: z.string().optional()})).optional(), podmanHosts: z.array(z.object({_id: z.string().optional()})).optional(), services: z.array(z.object({_id: z.string().optional()})).optional(), onCallDutyPolicies: z.array(z.object({_id: z.string().optional()})).optional(), statusPages: z.array(z.object({_id: z.string().optional()})).optional(), isScopedToStatusPages: z.boolean(), labels: z.array(z.object({_id: z.string().optional()})).optional(), incidentSeverityId: z.string().optional(), changeMonitorStatusToId: z.string().optional(), initialIncidentStateId: z.string().optional(), customFields: z.object({}).optional(), customFieldSettings: z.object({}).optional()}); export const createApiIncidentTemplatesIdGetItemResponse = z.object({data: incidentTemplate.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 }; /** * Get Incident Template * * POST /incident-templates/{id}/get-item */ export const createApiIncidentTemplatesIdGetItem = async (args: CreateApiIncidentTemplatesIdGetItemArgs, options?: CreateApiIncidentTemplatesIdGetItemOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/incident-templates/${encodeURIComponent(String(args.id))}/get-item${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(createApiIncidentTemplatesIdGetItemResponse, await res.json()) };