import {z} from 'zod' export type ProfileItemV3QuerySchema = {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, profileId?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_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, startTime?: (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, endTime?: (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, startTimeUnixNano?: (number | string | {_type: 'NotEqual', value: number | string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number | string} | {_type: 'GreaterThanOrEqual', value: number | string} | {_type: 'LessThan', value: number | string} | {_type: 'LessThanOrEqual', value: number | string} | {_type: 'InBetween', startValue: number | string, endValue: number | string}) | undefined, endTimeUnixNano?: (number | string | {_type: 'NotEqual', value: number | string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number | string} | {_type: 'GreaterThanOrEqual', value: number | string} | {_type: 'LessThan', value: number | string} | {_type: 'LessThanOrEqual', value: number | string} | {_type: 'InBetween', startValue: number | string, endValue: number | string}) | undefined, durationNano?: (number | string | {_type: 'NotEqual', value: number | string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number | string} | {_type: 'GreaterThanOrEqual', value: number | string} | {_type: 'LessThan', value: number | string} | {_type: 'LessThanOrEqual', value: number | string} | {_type: 'InBetween', startValue: number | string, endValue: number | string}) | undefined, profileType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, unit?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, periodType?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, period?: (number | string | {_type: 'NotEqual', value: number | string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'GreaterThan', value: number | string} | {_type: 'GreaterThanOrEqual', value: number | string} | {_type: 'LessThan', value: number | string} | {_type: 'LessThanOrEqual', value: number | string} | {_type: 'InBetween', startValue: number | string, endValue: number | 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, entityKeys?: ({_type: 'EqualTo', value: string} | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'Search', value: string}) | undefined, serviceEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, hostEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sPodEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sNodeEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, k8sClusterEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, containerEntityKey?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_type: 'Search', value: string}) | undefined, sampleCount?: (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, originalPayloadFormat?: (string | {_type: 'NotEqual', value: string} | {_type: 'IsNull'} | {_type: 'NotNull'} | {_type: 'Includes', value: Array} | {_type: 'EqualToOrNull', value: string} | {_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 ProfileItemV3SelectSchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, profileId?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, startTime?: boolean | undefined, endTime?: boolean | undefined, startTimeUnixNano?: boolean | undefined, endTimeUnixNano?: boolean | undefined, durationNano?: boolean | undefined, profileType?: boolean | undefined, unit?: boolean | undefined, periodType?: boolean | undefined, period?: boolean | undefined, attributes?: boolean | undefined, attributeKeys?: boolean | undefined, entityKeys?: boolean | undefined, serviceEntityKey?: boolean | undefined, hostEntityKey?: boolean | undefined, k8sPodEntityKey?: boolean | undefined, k8sNodeEntityKey?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, containerEntityKey?: boolean | undefined, sampleCount?: boolean | undefined, originalPayloadFormat?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type ProfileItemV3SortSchema = {projectId?: ('ASC' | 'DESC') | undefined, primaryEntityId?: ('ASC' | 'DESC') | undefined, primaryEntityType?: ('ASC' | 'DESC') | undefined, profileId?: ('ASC' | 'DESC') | undefined, traceId?: ('ASC' | 'DESC') | undefined, spanId?: ('ASC' | 'DESC') | undefined, startTime?: ('ASC' | 'DESC') | undefined, endTime?: ('ASC' | 'DESC') | undefined, startTimeUnixNano?: ('ASC' | 'DESC') | undefined, endTimeUnixNano?: ('ASC' | 'DESC') | undefined, durationNano?: ('ASC' | 'DESC') | undefined, profileType?: ('ASC' | 'DESC') | undefined, unit?: ('ASC' | 'DESC') | undefined, periodType?: ('ASC' | 'DESC') | undefined, period?: ('ASC' | 'DESC') | undefined, serviceEntityKey?: ('ASC' | 'DESC') | undefined, hostEntityKey?: ('ASC' | 'DESC') | undefined, k8sPodEntityKey?: ('ASC' | 'DESC') | undefined, k8sNodeEntityKey?: ('ASC' | 'DESC') | undefined, k8sClusterEntityKey?: ('ASC' | 'DESC') | undefined, containerEntityKey?: ('ASC' | 'DESC') | undefined, sampleCount?: ('ASC' | 'DESC') | undefined, originalPayloadFormat?: ('ASC' | 'DESC') | undefined, retentionDate?: ('ASC' | 'DESC') | undefined, _id?: ('ASC' | 'DESC') | undefined, createdAt?: ('ASC' | 'DESC') | undefined}; export type ProfileItemV3GroupBySchema = {projectId?: boolean | undefined, primaryEntityId?: boolean | undefined, primaryEntityType?: boolean | undefined, profileId?: boolean | undefined, traceId?: boolean | undefined, spanId?: boolean | undefined, profileType?: boolean | undefined, unit?: boolean | undefined, periodType?: boolean | undefined, serviceEntityKey?: boolean | undefined, hostEntityKey?: boolean | undefined, k8sPodEntityKey?: boolean | undefined, k8sNodeEntityKey?: boolean | undefined, k8sClusterEntityKey?: boolean | undefined, containerEntityKey?: boolean | undefined, sampleCount?: boolean | undefined, originalPayloadFormat?: boolean | undefined, _id?: boolean | undefined, createdAt?: boolean | undefined}; export type CreateApiProfileGetListArgs = {body: {query?: ProfileItemV3QuerySchema | undefined, select?: ProfileItemV3SelectSchema | undefined, sort?: ProfileItemV3SortSchema | undefined, groupBy?: ProfileItemV3GroupBySchema | undefined, limit?: number | undefined, skip?: number | undefined}}; export type CreateApiProfileGetListOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const profileItemV3 = z.object({projectId: z.string(), primaryEntityId: z.string(), primaryEntityType: z.string().optional(), profileId: z.string(), traceId: z.string().optional(), spanId: z.string().optional(), startTime: z.string().optional(), endTime: z.string().optional(), startTimeUnixNano: z.string().optional(), endTimeUnixNano: z.string().optional(), durationNano: z.string().optional(), profileType: z.string(), unit: z.string(), periodType: z.string().optional(), period: z.string().optional(), attributes: z.string().optional(), attributeKeys: z.array(z.string()).optional(), entityKeys: z.array(z.string()).optional(), serviceEntityKey: z.string().optional(), hostEntityKey: z.string().optional(), k8sPodEntityKey: z.string().optional(), k8sNodeEntityKey: z.string().optional(), k8sClusterEntityKey: z.string().optional(), containerEntityKey: z.string().optional(), sampleCount: z.number(), originalPayloadFormat: z.string().optional()}); export const createApiProfileGetListResponse = z.object({data: z.array(profileItemV3).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 Profile * * POST /profile/get-list */ export const createApiProfileGetList = async (args: CreateApiProfileGetListArgs, options?: CreateApiProfileGetListOptions) => { 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(/\/+$/, '')}/profile/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(createApiProfileGetListResponse, await res.json()) };