import {z} from 'zod' export type GetApiPublicV2ProjectsProjectIdLogStreamsPaginatedArgs = {project_id: unknown, include_counts?: boolean | undefined, starting_token?: number | undefined, limit?: number | undefined}; export type GetApiPublicV2ProjectsProjectIdLogStreamsPaginatedOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const userInfo = z.object({id: z.string(), email: z.string(), first_name: z.string().nullable().optional(), last_name: z.string().nullable().optional()}); export const logStreamResponse = z.object({id: z.string(), created_at: z.string(), updated_at: z.string(), name: z.string(), project_id: z.string(), created_by: z.string().nullable().optional(), created_by_user: userInfo.nullable().optional(), num_spans: z.number().int().nullable().optional(), num_traces: z.number().int().nullable().optional(), has_user_created_sessions: z.boolean().optional()}); export const listLogStreamResponse = z.object({starting_token: z.number().int().optional(), limit: z.number().int().optional(), paginated: z.boolean().optional(), next_starting_token: z.number().int().nullable().optional(), log_streams: z.array(logStreamResponse)}); 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 Log Streams Paginated * * GET /public/v2/projects/{project_id}/log_streams/paginated * * Also accepts auth: ClassicAPIKeyHeader, OAuth2PasswordBearer, HTTPBasic */ export const getApiPublicV2ProjectsProjectIdLogStreamsPaginated = async (args: GetApiPublicV2ProjectsProjectIdLogStreamsPaginatedArgs, options?: GetApiPublicV2ProjectsProjectIdLogStreamsPaginatedOptions) => { const {baseUrl = "https://api.galileo.ai", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.include_counts != null) query.append("include_counts", String(args.include_counts)) if (args.starting_token != null) query.append("starting_token", String(args.starting_token)) if (args.limit != null) query.append("limit", String(args.limit)) if (APIKeyHeader !== undefined) headers.set("Splunk-AO-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/public/v2/projects/${encodeURIComponent(String(args.project_id))}/log_streams/paginated${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(listLogStreamResponse, await res.json()) };