import {z} from 'zod' export type SecurityEventItemV1QuerySchema = {projectId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, primaryEntityId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, primaryEntityType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, time?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined, eventUid?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, categoryUid?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, categoryName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, classUid?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, className?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, activityName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, severityId?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, severityName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, statusName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, message?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, vendorName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, productName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, ruleId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, ruleName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, mitreTactics?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, mitreTechniques?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, principalUser?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, principalHost?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, principalIp?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, principalProcess?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, processName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, processPath?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, processCommandLine?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, parentProcessName?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, parentProcessPath?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, parentProcessCommandLine?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, targetUser?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, targetHost?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, targetIp?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, targetPort?: (number | {_type: 'NotEqual', value: number} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number} | {_type: 'GreaterThanOrEqual', value: number} | {_type: 'LessThan', value: number} | {_type: 'LessThanOrEqual', value: number} | {_type: 'InBetween', startValue: number, endValue: number}) | undefined, targetResource?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, observables?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, traceId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, spanId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, sessionId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, requestOutcome?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, attributes?: ({[key: string]: string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Search', value: string}}) | undefined, attributeKeys?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, _id?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array}) | undefined, createdAt?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: string} | {_type: 'GreaterThanOrEqual', value: string} | {_type: 'LessThan', value: string} | {_type: 'LessThanOrEqual', value: string} | {_type: 'InBetween', startValue: string, endValue: string}) | undefined}; export type SecurityEventItemV1SelectSchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, time?: boolean | undefined, eventUid?: boolean | undefined, categoryUid?: boolean | undefined, categoryName?: boolean | undefined, classUid?: boolean | undefined, className?: boolean | undefined, activityName?: boolean | undefined, severityId?: boolean | undefined, severityName?: boolean | undefined, statusName?: boolean | undefined, message?: boolean | undefined, vendorName?: boolean | undefined, productName?: boolean | undefined, ruleId?: boolean | undefined, ruleName?: boolean | undefined, mitreTactics?: boolean | undefined, mitreTechniques?: boolean | undefined, principalUser?: boolean | undefined, principalHost?: boolean | undefined, principalIp?: boolean | undefined, principalProcess?: boolean | undefined, processName?: boolean | undefined, processPath?: boolean | undefined, processCommandLine?: boolean | undefined, parentProcessName?: boolean | undefined, parentProcessPath?: boolean | undefined, parentProcessCommandLine?: boolean | undefined, targetUser?: boolean | undefined, targetHost?: boolean | undefined, targetIp?: boolean | undefined, targetPort?: boolean | undefined, targetResource?: boolean | undefined, observables?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, sessionId?: boolean | undefined, requestOutcome?: boolean | undefined, attributes?: boolean | undefined, attributeKeys?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type SecurityEventItemV1SortSchema = {projectId?: ('ASC' | 'DESC') | undefined, primaryEntityId?: ('ASC' | 'DESC') | undefined, primaryEntityType?: ('ASC' | 'DESC') | undefined, time?: ('ASC' | 'DESC') | undefined, eventUid?: ('ASC' | 'DESC') | undefined, categoryUid?: ('ASC' | 'DESC') | undefined, categoryName?: ('ASC' | 'DESC') | undefined, classUid?: ('ASC' | 'DESC') | undefined, className?: ('ASC' | 'DESC') | undefined, activityName?: ('ASC' | 'DESC') | undefined, severityId?: ('ASC' | 'DESC') | undefined, severityName?: ('ASC' | 'DESC') | undefined, statusName?: ('ASC' | 'DESC') | undefined, message?: ('ASC' | 'DESC') | undefined, vendorName?: ('ASC' | 'DESC') | undefined, productName?: ('ASC' | 'DESC') | undefined, ruleId?: ('ASC' | 'DESC') | undefined, ruleName?: ('ASC' | 'DESC') | undefined, principalUser?: ('ASC' | 'DESC') | undefined, principalHost?: ('ASC' | 'DESC') | undefined, principalIp?: ('ASC' | 'DESC') | undefined, principalProcess?: ('ASC' | 'DESC') | undefined, processName?: ('ASC' | 'DESC') | undefined, processPath?: ('ASC' | 'DESC') | undefined, processCommandLine?: ('ASC' | 'DESC') | undefined, parentProcessName?: ('ASC' | 'DESC') | undefined, parentProcessPath?: ('ASC' | 'DESC') | undefined, parentProcessCommandLine?: ('ASC' | 'DESC') | undefined, targetUser?: ('ASC' | 'DESC') | undefined, targetHost?: ('ASC' | 'DESC') | undefined, targetIp?: ('ASC' | 'DESC') | undefined, targetPort?: ('ASC' | 'DESC') | undefined, targetResource?: ('ASC' | 'DESC') | undefined, traceId?: ('ASC' | 'DESC') | undefined, spanId?: ('ASC' | 'DESC') | undefined, sessionId?: ('ASC' | 'DESC') | undefined, requestOutcome?: ('ASC' | 'DESC') | undefined, retentionDate?: ('ASC' | 'DESC') | undefined, _id?: ('ASC' | 'DESC') | undefined, createdAt?: ('ASC' | 'DESC') | undefined}; export type SecurityEventItemV1GroupBySchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, eventUid?: boolean | undefined, categoryUid?: boolean | undefined, categoryName?: boolean | undefined, classUid?: boolean | undefined, className?: boolean | undefined, activityName?: boolean | undefined, severityId?: boolean | undefined, severityName?: boolean | undefined, statusName?: boolean | undefined, message?: boolean | undefined, vendorName?: boolean | undefined, productName?: boolean | undefined, ruleId?: boolean | undefined, ruleName?: boolean | undefined, principalUser?: boolean | undefined, principalHost?: boolean | undefined, principalIp?: boolean | undefined, principalProcess?: boolean | undefined, processName?: boolean | undefined, processPath?: boolean | undefined, processCommandLine?: boolean | undefined, parentProcessName?: boolean | undefined, parentProcessPath?: boolean | undefined, parentProcessCommandLine?: boolean | undefined, targetUser?: boolean | undefined, targetHost?: boolean | undefined, targetIp?: boolean | undefined, targetPort?: boolean | undefined, targetResource?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, sessionId?: boolean | undefined, requestOutcome?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiSecurityEventsGetListArgs = {body: {query?: SecurityEventItemV1QuerySchema | undefined, select?: SecurityEventItemV1SelectSchema | undefined, sort?: SecurityEventItemV1SortSchema | undefined, groupBy?: SecurityEventItemV1GroupBySchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiSecurityEventsGetListOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const securityEventItemV1 = z.object({projectId: z.string(), primaryEntityId: z.string(), primaryEntityType: z.string().optional(), time: z.string().optional(), eventUid: z.string().optional(), categoryUid: z.number().optional(), categoryName: z.string().optional(), classUid: z.number().optional(), className: z.string().optional(), activityName: z.string().optional(), severityId: z.number().optional(), severityName: z.string().optional(), statusName: z.string().optional(), message: z.string().optional(), vendorName: z.string().optional(), productName: z.string().optional(), ruleId: z.string().optional(), ruleName: z.string().optional(), mitreTactics: z.array(z.string()).optional(), mitreTechniques: z.array(z.string()).optional(), principalUser: z.string().optional(), principalHost: z.string().optional(), principalIp: z.string().optional(), principalProcess: z.string().optional(), processName: z.string().optional(), processPath: z.string().optional(), processCommandLine: z.string().optional(), parentProcessName: z.string().optional(), parentProcessPath: z.string().optional(), parentProcessCommandLine: z.string().optional(), targetUser: z.string().optional(), targetHost: z.string().optional(), targetIp: z.string().optional(), targetPort: z.number().optional(), targetResource: z.string().optional(), observables: z.array(z.string()).optional(), traceId: z.string().optional(), spanId: z.string().optional(), sessionId: z.string().optional(), requestOutcome: z.string().optional(), attributes: z.string().optional(), attributeKeys: z.array(z.string()).optional()}); export const createApiSecurityEventsGetListResponse = z.object({data: z.array(securityEventItemV1).optional(), count: z.number().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 }; /** * List Security Event * * POST /security-events/get-list */ export const createApiSecurityEventsGetList = async (args: CreateApiSecurityEventsGetListArgs, options?: CreateApiSecurityEventsGetListOptions) => { 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(/\/+$/, '')}/security-events/get-list${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(createApiSecurityEventsGetListResponse, await res.json()) };