import {z} from 'zod' export type GetApiDataServiceApiShieldAuditsAccessDataCountsArgs = {fromTime?: number | undefined, toTime?: number | undefined, interval?: (string | null) | undefined, 'includeQuery.userId'?: (string | null) | undefined, 'includeQuery.applicationName'?: (string | null) | undefined, 'includeQuery.requestType'?: (string | null) | undefined, 'includeQuery.trait'?: (string | null) | undefined, 'includeQuery.result'?: (string | null) | undefined, 'includeQuery.threadId'?: (string | null) | undefined, 'includeQuery.transactionSequenceNumber'?: (string | null) | undefined, 'includeQuery.transactionId'?: (string | null) | undefined, 'includeQuery.objectType'?: (string | null) | undefined, 'includeQuery.action'?: (string | null) | undefined}; export type GetApiDataServiceApiShieldAuditsAccessDataCountsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const getApiDataServiceApiShieldAuditsAccessDataCountsResponse = z.unknown(); 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 Access Data Counts * * GET /data-service/api/shield_audits/access_data_counts */ export const getApiDataServiceApiShieldAuditsAccessDataCounts = async (args: GetApiDataServiceApiShieldAuditsAccessDataCountsArgs, options: GetApiDataServiceApiShieldAuditsAccessDataCountsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.fromTime != null) query.append("fromTime", String(args.fromTime)) if (args.toTime != null) query.append("toTime", String(args.toTime)) if (args.interval != null) query.append("interval", String(args.interval)) if (args['includeQuery.userId'] != null) query.append("includeQuery.userId", String(args['includeQuery.userId'])) if (args['includeQuery.applicationName'] != null) query.append("includeQuery.applicationName", String(args['includeQuery.applicationName'])) if (args['includeQuery.requestType'] != null) query.append("includeQuery.requestType", String(args['includeQuery.requestType'])) if (args['includeQuery.trait'] != null) query.append("includeQuery.trait", String(args['includeQuery.trait'])) if (args['includeQuery.result'] != null) query.append("includeQuery.result", String(args['includeQuery.result'])) if (args['includeQuery.threadId'] != null) query.append("includeQuery.threadId", String(args['includeQuery.threadId'])) if (args['includeQuery.transactionSequenceNumber'] != null) query.append("includeQuery.transactionSequenceNumber", String(args['includeQuery.transactionSequenceNumber'])) if (args['includeQuery.transactionId'] != null) query.append("includeQuery.transactionId", String(args['includeQuery.transactionId'])) if (args['includeQuery.objectType'] != null) query.append("includeQuery.objectType", String(args['includeQuery.objectType'])) if (args['includeQuery.action'] != null) query.append("includeQuery.action", String(args['includeQuery.action'])) const url = `${baseUrl.replace(/\/+$/, '')}/data-service/api/shield_audits/access_data_counts${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(getApiDataServiceApiShieldAuditsAccessDataCountsResponse, await res.json()) };