import {z} from 'zod' 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 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 TeamRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined}; export type UserRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, email?: boolean | undefined, profilePictureId?: boolean | undefined, twoFactorAuthEnabled?: boolean | undefined}; export type ServiceLevelObjectiveBurnRateRuleSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, serviceLevelObjectiveId?: boolean | undefined, name?: boolean | undefined, isEnabled?: boolean | undefined, burnRateThreshold?: boolean | undefined, longWindowInMinutes?: boolean | undefined, shortWindowInMinutes?: boolean | undefined, minimumSampleCount?: boolean | undefined, refireSuppressionMinutes?: boolean | undefined, shouldCreateAlert?: boolean | undefined, shouldCreateIncident?: boolean | undefined, alertSeverityId?: boolean | undefined, onCallDutyPolicies?: OnCallDutyPolicyRelationSelectSchema | undefined, alertTitleTemplate?: boolean | undefined, alertDescriptionTemplate?: boolean | undefined, alertRemediationNotes?: boolean | undefined, isAlertPrivate?: boolean | undefined, autoResolveAlert?: boolean | undefined, alertLabels?: LabelRelationSelectSchema | undefined, alertOwnerTeams?: TeamRelationSelectSchema | undefined, alertOwnerUsers?: UserRelationSelectSchema | undefined, incidentSeverityId?: boolean | undefined, incidentOnCallDutyPolicies?: OnCallDutyPolicyRelationSelectSchema | undefined, incidentTitleTemplate?: boolean | undefined, incidentDescriptionTemplate?: boolean | undefined, incidentRemediationNotes?: boolean | undefined, isIncidentPrivate?: boolean | undefined, autoResolveIncident?: boolean | undefined, incidentLabels?: LabelRelationSelectSchema | undefined, incidentOwnerTeams?: TeamRelationSelectSchema | undefined, incidentOwnerUsers?: UserRelationSelectSchema | undefined, addSloOwnersAsOwners?: boolean | undefined, lastAlertCreatedAt?: boolean | undefined, lastAlertResolvedAt?: boolean | undefined, lastIncidentCreatedAt?: boolean | undefined, lastIncidentResolvedAt?: boolean | undefined, createdByUserId?: boolean | undefined}; export type CreateApiServiceLevelObjectiveBurnRateRuleIdGetItemArgs = {id: string, body: {select?: ServiceLevelObjectiveBurnRateRuleSelectSchema | undefined}}; export type CreateApiServiceLevelObjectiveBurnRateRuleIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const serviceLevelObjectiveBurnRateRule = 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(), serviceLevelObjectiveId: z.string(), name: z.string(), isEnabled: z.boolean(), burnRateThreshold: z.number(), longWindowInMinutes: z.number(), shortWindowInMinutes: z.number(), minimumSampleCount: z.number().optional(), refireSuppressionMinutes: z.number().optional(), shouldCreateAlert: z.boolean(), shouldCreateIncident: z.boolean(), alertSeverityId: z.string().optional(), onCallDutyPolicies: z.array(z.object({_id: z.string().optional()})).optional(), alertTitleTemplate: z.string().optional(), alertDescriptionTemplate: z.string().optional(), alertRemediationNotes: z.string().optional(), isAlertPrivate: z.boolean(), autoResolveAlert: z.boolean(), alertLabels: z.array(z.object({_id: z.string().optional()})).optional(), alertOwnerTeams: z.array(z.object({_id: z.string().optional()})).optional(), alertOwnerUsers: z.array(z.object({_id: z.string().optional()})).optional(), incidentSeverityId: z.string().optional(), incidentOnCallDutyPolicies: z.array(z.object({_id: z.string().optional()})).optional(), incidentTitleTemplate: z.string().optional(), incidentDescriptionTemplate: z.string().optional(), incidentRemediationNotes: z.string().optional(), isIncidentPrivate: z.boolean(), autoResolveIncident: z.boolean(), incidentLabels: z.array(z.object({_id: z.string().optional()})).optional(), incidentOwnerTeams: z.array(z.object({_id: z.string().optional()})).optional(), incidentOwnerUsers: z.array(z.object({_id: z.string().optional()})).optional(), addSloOwnersAsOwners: z.boolean(), lastAlertCreatedAt: z.object({}).optional(), lastAlertResolvedAt: z.object({}).optional(), lastIncidentCreatedAt: z.object({}).optional(), lastIncidentResolvedAt: z.object({}).optional(), createdByUserId: z.string().optional()}); export const createApiServiceLevelObjectiveBurnRateRuleIdGetItemResponse = z.object({data: serviceLevelObjectiveBurnRateRule.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 SLO Burn Rate Rule * * POST /service-level-objective-burn-rate-rule/{id}/get-item */ export const createApiServiceLevelObjectiveBurnRateRuleIdGetItem = async (args: CreateApiServiceLevelObjectiveBurnRateRuleIdGetItemArgs, options?: CreateApiServiceLevelObjectiveBurnRateRuleIdGetItemOptions) => { 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(/\/+$/, '')}/service-level-objective-burn-rate-rule/${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(createApiServiceLevelObjectiveBurnRateRuleIdGetItemResponse, await res.json()) };