import {z} from 'zod' export type AuditLogSortDirectionV1 = 'DESC' | 'ASC'; export type AuditLogEventTypeGroupV1 = 'DEPLOYED' | 'PROMOTED' | 'ACTIVATED_DEACTIVATED' | 'AUTOSCALING_SETTINGS' | 'INSTANCE_TYPE_CHANGED' | 'ENVIRONMENT_SETTINGS' | 'REPLICA_TERMINATED' | 'DELETED' | 'SECRETS' | 'API_KEYS' | 'GATEWAY' | 'WEBHOOK_SIGNING_SECRETS' | 'USER_MANAGEMENT' | 'DIRECTORY_GROUP_MANAGEMENT' | 'SSH'; export type AuditLogSourceV1 = 'UI' | 'API' | 'MCP' | 'OTHER'; export type GetApiV1ChainsChainIdAuditLogsArgs = {cursor?: (string | null) | undefined, limit?: number | undefined, direction?: AuditLogSortDirectionV1 | undefined, search?: (string | null) | undefined, event_type_groups?: Array | undefined, user_ids?: Array | undefined, deployment_ids?: Array | undefined, chain_deployment_ids?: Array | undefined, environment_names?: Array | undefined, sources?: Array | undefined, start_epoch_millis?: (number | null) | undefined, end_epoch_millis?: (number | null) | undefined}; export type GetApiV1ChainsChainIdAuditLogsOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const auditLogEventTypeV1 = z.enum(["MODEL_DEPLOYED", "MODEL_DEPLOYMENT_ACTIVATED", "MODEL_DEPLOYMENT_DEACTIVATED", "MODEL_DEPLOYMENT_RETRIED", "MODEL_DEPLOYMENT_PROMOTED", "MODEL_DEPLOYMENT_AUTOSCALING_SETTINGS_CHANGED", "MODEL_DEPLOYMENT_INSTANCE_TYPE_CHANGED", "MODEL_DEPLOYMENT_DELETED", "MODEL_DELETED", "CHAIN_DEPLOYED", "CHAIN_DEPLOYMENT_ACTIVATED", "CHAIN_DEPLOYMENT_DEACTIVATED", "CHAIN_DEPLOYMENT_PROMOTED", "CHAINLET_AUTOSCALING_SETTINGS_CHANGED", "CHAINLET_INSTANCE_TYPE_CHANGED", "CHAIN_DEPLOYMENT_DELETED", "CHAIN_DELETED", "CHAIN_ENVIRONMENT_CREATED", "CHAIN_ENVIRONMENT_UPDATED", "SECRET_UPDATED", "SECRET_DELETED", "API_KEY_CREATED", "API_KEY_DELETED", "GATEWAY_ENDPOINT_CREATED", "GATEWAY_ENDPOINT_UPDATED", "GATEWAY_ENDPOINT_DELETED", "USER_INVITED", "USER_JOINED_ORGANIZATION", "WEBHOOK_SIGNING_SECRET_CREATED", "WEBHOOK_SIGNING_SECRET_ROTATED", "WEBHOOK_SIGNING_SECRET_DELETED", "USER_ROLE_UPDATED", "USER_TEAM_ROLE_UPDATED", "USER_REMOVED", "DIRECTORY_GROUP_ROLE_UPDATED", "REQUIRE_GROUP_BASED_ADMINS_ENABLED", "ENVIRONMENT_CREATED", "ENVIRONMENT_UPDATED", "ENVIRONMENT_DELETED", "REPLICA_TERMINATED", "MODEL_PROMOTION_CONTROL_ACTION", "SSH_CERTIFICATE_SIGNED"]); export const auditLogEventModelDeployedV1 = z.object({event_type: z.literal("MODEL_DEPLOYED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), scale_previous_to_zero: z.boolean(), trusted: z.boolean(), publish: z.boolean(), environment_name: z.string().nullable()}); export const auditLogEventModelDeploymentActivatedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_ACTIVATED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string()}); export const auditLogEventModelDeploymentDeactivatedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_DEACTIVATED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string()}); export const auditLogEventModelDeploymentRetriedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_RETRIED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), retried: z.boolean()}); export const auditLogEventModelDeploymentPromotedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_PROMOTED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), environment_name: z.string().nullable(), environment_id: z.string().nullable()}); export const auditLogEventAutoscalingSettingsV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable()}); export const auditLogEventModelDeploymentAutoscalingSettingsChangedV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable(), event_type: z.literal("MODEL_DEPLOYMENT_AUTOSCALING_SETTINGS_CHANGED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), deployment_type: z.string().nullable(), previous_settings: auditLogEventAutoscalingSettingsV1.nullable()}); export const auditLogEventModelDeploymentInstanceTypeChangedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_INSTANCE_TYPE_CHANGED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), instance_type_name: z.string()}); export const auditLogEventModelDeploymentDeletedV1 = z.object({event_type: z.literal("MODEL_DEPLOYMENT_DELETED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string()}); export const auditLogEventModelDeletedV1 = z.object({event_type: z.literal("MODEL_DELETED"), model_id: z.string(), model_name: z.string()}); export const auditLogEventChainDeployedV1 = z.object({event_type: z.literal("CHAIN_DEPLOYED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable(), is_primary: z.boolean(), publish: z.boolean()}); export const auditLogEventChainDeploymentActivatedV1 = z.object({event_type: z.literal("CHAIN_DEPLOYMENT_ACTIVATED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable()}); export const auditLogEventChainDeploymentDeactivatedV1 = z.object({event_type: z.literal("CHAIN_DEPLOYMENT_DEACTIVATED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable()}); export const auditLogEventChainDeploymentPromotedV1 = z.object({event_type: z.literal("CHAIN_DEPLOYMENT_PROMOTED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable(), environment_name: z.string().nullable(), environment_id: z.string().nullable()}); export const auditLogEventChainletAutoscalingSettingsChangedV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable(), event_type: z.literal("CHAINLET_AUTOSCALING_SETTINGS_CHANGED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable(), chainlet_name: z.string(), chainlet_id: z.string(), previous_settings: auditLogEventAutoscalingSettingsV1.nullable()}); export const auditLogEventChainletInstanceTypeChangedV1 = z.object({event_type: z.literal("CHAINLET_INSTANCE_TYPE_CHANGED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), chain_deployment_name: z.string().nullable(), chainlet_name: z.string(), chainlet_id: z.string(), instance_type_name: z.string()}); export const auditLogEventChainDeploymentDeletedV1 = z.object({event_type: z.literal("CHAIN_DEPLOYMENT_DELETED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_id: z.string(), deployment_name: z.string().nullable()}); export const auditLogEventChainDeletedV1 = z.object({event_type: z.literal("CHAIN_DELETED"), chain_id: z.string(), chain_name: z.string(), chain_deployment_name: z.string().nullable()}); export const auditLogEventChainEnvironmentCreatedV1 = z.object({event_type: z.literal("CHAIN_ENVIRONMENT_CREATED"), chain_id: z.string(), chain_name: z.string(), environment_name: z.string(), redeploy_on_promotion: z.boolean().nullable(), ramp_up_while_promoting: z.boolean().nullable(), ramp_up_duration_seconds: z.number().int().nullable()}); export const auditLogEventChainEnvironmentUpdatedV1 = z.object({event_type: z.literal("CHAIN_ENVIRONMENT_UPDATED"), chain_id: z.string(), chain_name: z.string(), environment_name: z.string(), redeploy_on_promotion: z.boolean().nullable(), ramp_up_while_promoting: z.boolean().nullable(), ramp_up_duration_seconds: z.number().int().nullable()}); export const auditLogEventSecretUpdatedV1 = z.object({event_type: z.literal("SECRET_UPDATED"), secret_id: z.string(), secret_name: z.string()}); export const auditLogEventSecretDeletedV1 = z.object({event_type: z.literal("SECRET_DELETED"), secret_id: z.string(), secret_name: z.string()}); export const auditLogApiKeyTypeV1 = z.enum(["PERSONAL", "CREATOR_SERVICE_ACCOUNT", "MANAGE_API_KEYS_SERVICE_ACCOUNT", "INVOKE_ALL_MODELS_SERVICE_ACCOUNT", "INVOKE_ALLOWED_MODELS_SERVICE_ACCOUNT", "INVOKE_SCOPED_ENVS_AND_MODELS_SERVICE_ACCOUNT", "EXPORT_METRICS_ALL_MODELS_SERVICE_ACCOUNT", "EXPORT_METRICS_ALLOWED_MODELS_SERVICE_ACCOUNT", "INVOKE_ALL_SHARED_ENDPOINTS_SERVICE_ACCOUNT", "INVOKE_ALLOWED_SHARED_ENDPOINTS_SERVICE_ACCOUNT"]); export const auditLogEventApiKeyCreatedV1 = z.object({event_type: z.literal("API_KEY_CREATED"), api_key_id: z.string(), api_key_type: auditLogApiKeyTypeV1, prefix: z.string()}); export const auditLogEventApiKeyDeletedV1 = z.object({event_type: z.literal("API_KEY_DELETED"), api_key_id: z.string(), api_key_type: auditLogApiKeyTypeV1, prefix: z.string()}); export const auditLogEventGatewayEndpointCreatedV1 = z.object({event_type: z.literal("GATEWAY_ENDPOINT_CREATED"), gateway_endpoint_id: z.string(), slug: z.string()}); export const auditLogEventGatewayEndpointUpdatedV1 = z.object({event_type: z.literal("GATEWAY_ENDPOINT_UPDATED"), gateway_endpoint_id: z.string(), slug: z.string(), previous_slug: z.string().nullable()}); export const auditLogEventGatewayEndpointDeletedV1 = z.object({event_type: z.literal("GATEWAY_ENDPOINT_DELETED"), gateway_endpoint_id: z.string(), slug: z.string()}); export const auditLogEventUserInvitedV1 = z.object({event_type: z.literal("USER_INVITED"), invited_user_email: z.string(), role_name: z.string()}); export const auditLogEventUserJoinedOrganizationV1 = z.object({event_type: z.literal("USER_JOINED_ORGANIZATION"), new_user_email: z.string(), user_id: z.string()}); export const auditLogEventWebhookSigningSecretCreatedV1 = z.object({event_type: z.literal("WEBHOOK_SIGNING_SECRET_CREATED"), webhook_signing_secret_id: z.string()}); export const auditLogEventWebhookSigningSecretRotatedV1 = z.object({event_type: z.literal("WEBHOOK_SIGNING_SECRET_ROTATED"), webhook_signing_secret_id: z.string()}); export const auditLogEventWebhookSigningSecretDeletedV1 = z.object({event_type: z.literal("WEBHOOK_SIGNING_SECRET_DELETED"), webhook_signing_secret_id: z.string()}); export const auditLogEventUserRoleUpdatedV1 = z.object({event_type: z.literal("USER_ROLE_UPDATED"), user_id: z.string(), user_email: z.string(), new_role_name: z.string()}); export const auditLogEventUserTeamRoleUpdatedV1 = z.object({event_type: z.literal("USER_TEAM_ROLE_UPDATED"), user_id: z.string(), user_email: z.string(), team_id: z.string(), team_name: z.string(), new_role_name: z.string()}); export const auditLogEventUserRemovedV1 = z.object({event_type: z.literal("USER_REMOVED"), removed_user_email: z.string()}); export const auditLogEventDirectoryGroupRoleUpdatedV1 = z.object({event_type: z.literal("DIRECTORY_GROUP_ROLE_UPDATED"), directory_group_id: z.string(), directory_group_name: z.string(), new_role_name: z.string(), team_id: z.string().nullable(), team_name: z.string().nullable()}); export const auditLogEventRequireGroupBasedAdminsEnabledV1 = z.object({event_type: z.literal("REQUIRE_GROUP_BASED_ADMINS_ENABLED"), organization_id: z.string()}); export const auditLogEventEnvironmentCreatedV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable(), redeploy_on_promotion: z.boolean().nullable(), rolling_deploy: z.boolean().nullable(), rolling_deploy_strategy: z.string().nullable(), max_unavailable_percent: z.number().int().nullable(), max_surge_percent: z.number().int().nullable(), stabilization_time_seconds: z.number().int().nullable(), replica_overhead_percent: z.number().int().nullable(), promotion_cleanup_strategy: z.string().nullable(), ramp_up_while_promoting: z.boolean().nullable(), ramp_up_duration_seconds: z.number().int().nullable(), ramp_up_step_size: z.number().int().nullable(), model_id: z.string(), model_name: z.string(), environment_name: z.string(), deployment_type: z.string().nullable(), event_type: z.literal("ENVIRONMENT_CREATED")}); export const auditLogEventEnvironmentSettingsV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable(), redeploy_on_promotion: z.boolean().nullable(), rolling_deploy: z.boolean().nullable(), rolling_deploy_strategy: z.string().nullable(), max_unavailable_percent: z.number().int().nullable(), max_surge_percent: z.number().int().nullable(), stabilization_time_seconds: z.number().int().nullable(), replica_overhead_percent: z.number().int().nullable(), promotion_cleanup_strategy: z.string().nullable(), ramp_up_while_promoting: z.boolean().nullable(), ramp_up_duration_seconds: z.number().int().nullable(), ramp_up_step_size: z.number().int().nullable()}); export const auditLogEventEnvironmentUpdatedV1 = z.object({min_replica: z.number().int(), max_replica: z.number().int(), concurrency_target: z.number().int(), autoscaling_window: z.number().int().nullable(), scale_down_delay: z.number().int().nullable(), target_utilization_percentage: z.number().int().nullable(), target_in_flight_tokens: z.number().int().nullable(), max_scale_down_rate: z.number().nullable(), redeploy_on_promotion: z.boolean().nullable(), rolling_deploy: z.boolean().nullable(), rolling_deploy_strategy: z.string().nullable(), max_unavailable_percent: z.number().int().nullable(), max_surge_percent: z.number().int().nullable(), stabilization_time_seconds: z.number().int().nullable(), replica_overhead_percent: z.number().int().nullable(), promotion_cleanup_strategy: z.string().nullable(), ramp_up_while_promoting: z.boolean().nullable(), ramp_up_duration_seconds: z.number().int().nullable(), ramp_up_step_size: z.number().int().nullable(), model_id: z.string(), model_name: z.string(), environment_name: z.string(), deployment_type: z.string().nullable(), event_type: z.literal("ENVIRONMENT_UPDATED"), previous_settings: auditLogEventEnvironmentSettingsV1.nullable()}); export const auditLogEventEnvironmentDeletedV1 = z.object({event_type: z.literal("ENVIRONMENT_DELETED"), model_id: z.string(), model_name: z.string(), environment_name: z.string()}); export const auditLogEventReplicaTerminatedV1 = z.object({event_type: z.literal("REPLICA_TERMINATED"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), replica_id: z.string()}); export const auditLogPromotionControlActionV1 = z.enum(["PAUSE", "RESUME", "FORCE_CANCEL", "FORCE_ROLL_FORWARD", "GRACEFUL_CANCEL"]); export const auditLogEventModelPromotionControlActionV1 = z.object({event_type: z.literal("MODEL_PROMOTION_CONTROL_ACTION"), model_id: z.string(), model_name: z.string(), deployment_id: z.string(), deployment_name: z.string(), environment_name: z.string(), environment_id: z.string().nullable(), action: auditLogPromotionControlActionV1}); export const auditLogEventSshCertificateSignedV1 = z.object({event_type: z.literal("SSH_CERTIFICATE_SIGNED"), workload_type: z.string(), workload_id: z.string(), project_id: z.string(), replica_id: z.string(), proxy_address: z.string(), expires_at: z.string()}); export const auditLogSourceV1 = z.enum(["UI", "API", "MCP", "OTHER"]); export const auditLogActorTypeV1 = z.enum(["USER", "API_KEY", "BASETEN_USER", "BASETEN_SYSTEM", "TOMBSTONE_USER"]); export const auditLogActorV1 = z.object({type: auditLogActorTypeV1, email: z.string().nullable().optional(), api_key_prefix: z.string().nullable().optional()}); export const auditLogEntryV1 = z.object({id: z.string(), created: z.string(), event_type: auditLogEventTypeV1, event_data: z.discriminatedUnion("event_type", [auditLogEventModelDeployedV1, auditLogEventModelDeploymentActivatedV1, auditLogEventModelDeploymentDeactivatedV1, auditLogEventModelDeploymentRetriedV1, auditLogEventModelDeploymentPromotedV1, auditLogEventModelDeploymentAutoscalingSettingsChangedV1, auditLogEventModelDeploymentInstanceTypeChangedV1, auditLogEventModelDeploymentDeletedV1, auditLogEventModelDeletedV1, auditLogEventChainDeployedV1, auditLogEventChainDeploymentActivatedV1, auditLogEventChainDeploymentDeactivatedV1, auditLogEventChainDeploymentPromotedV1, auditLogEventChainletAutoscalingSettingsChangedV1, auditLogEventChainletInstanceTypeChangedV1, auditLogEventChainDeploymentDeletedV1, auditLogEventChainDeletedV1, auditLogEventChainEnvironmentCreatedV1, auditLogEventChainEnvironmentUpdatedV1, auditLogEventSecretUpdatedV1, auditLogEventSecretDeletedV1, auditLogEventApiKeyCreatedV1, auditLogEventApiKeyDeletedV1, auditLogEventGatewayEndpointCreatedV1, auditLogEventGatewayEndpointUpdatedV1, auditLogEventGatewayEndpointDeletedV1, auditLogEventUserInvitedV1, auditLogEventUserJoinedOrganizationV1, auditLogEventWebhookSigningSecretCreatedV1, auditLogEventWebhookSigningSecretRotatedV1, auditLogEventWebhookSigningSecretDeletedV1, auditLogEventUserRoleUpdatedV1, auditLogEventUserTeamRoleUpdatedV1, auditLogEventUserRemovedV1, auditLogEventDirectoryGroupRoleUpdatedV1, auditLogEventRequireGroupBasedAdminsEnabledV1, auditLogEventEnvironmentCreatedV1, auditLogEventEnvironmentUpdatedV1, auditLogEventEnvironmentDeletedV1, auditLogEventReplicaTerminatedV1, auditLogEventModelPromotionControlActionV1, auditLogEventSshCertificateSignedV1]), source: auditLogSourceV1.nullable().optional(), actor: auditLogActorV1, client_name: z.string().nullable().optional(), client_version: z.string().nullable().optional(), client_session_id: z.string().nullable().optional()}); export const paginationResponseV1 = z.object({has_more: z.boolean(), cursor: z.string().nullable().optional()}); export const listAuditLogsResponseV1 = z.object({items: z.array(auditLogEntryV1), pagination: paginationResponseV1}); 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 }; /** * Gets the audit log for a chain * * GET /v1/chains/{chain_id}/audit_logs */ export const getApiV1ChainsChainIdAuditLogs = async (args: GetApiV1ChainsChainIdAuditLogsArgs, options: GetApiV1ChainsChainIdAuditLogsOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.direction != null) query.append("direction", String(args.direction)) if (args.search != null) query.append("search", String(args.search)) for (const item of args.event_type_groups ?? []) query.append("event_type_groups", String(item)) for (const item of args.user_ids ?? []) query.append("user_ids", String(item)) for (const item of args.deployment_ids ?? []) query.append("deployment_ids", String(item)) for (const item of args.chain_deployment_ids ?? []) query.append("chain_deployment_ids", String(item)) for (const item of args.environment_names ?? []) query.append("environment_names", String(item)) for (const item of args.sources ?? []) query.append("sources", String(item)) if (args.start_epoch_millis != null) query.append("start_epoch_millis", String(args.start_epoch_millis)) if (args.end_epoch_millis != null) query.append("end_epoch_millis", String(args.end_epoch_millis)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/chains/${encodeURIComponent(String(args.chain_id))}/audit_logs${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(listAuditLogsResponseV1, await res.json()) };