// AUTO-GENERATED by scripts/generate.ts from .generated-specs. Do not edit. import * as S from "@distilled.cloud/core/schema"; import * as API from "@distilled.cloud/core/api"; import * as T from "../traits.ts"; import { CloudflareProtocol, CloudflarePaginatedProtocol, type CloudflareOpError, type CloudflareOpContext, } from "../protocol.ts"; import { cloudflarePaginate, ResultInfo } from "../pagination.ts"; import { CloudflareError, CloudflareRateLimited } from "../errors.ts"; import * as Retry from "../retry.ts"; export type { CloudflareOpError, CloudflareOpContext }; /** Fallback camelCase→wire mapping for opaque content (mined from the distilled SDK). */ const KEY_DICTIONARY: Record> = { perPage: "per_page", resultInfo: "result_info", totalCount: "total_count", }; export interface ListRequestAction { /** Filters by the action type. */ type?: string; } export const ListRequestAction = /*@__PURE__*/ S.suspend(() => S.Struct({ type: S.optional(S.String), }), ).annotate({ identifier: "ListRequestAction", }) as any as S.Schema; export interface ListRequestActor { /** Filters by the email address of the actor that made the change. */ email?: string; /** Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range. */ ip?: string; } export const ListRequestActor = /*@__PURE__*/ S.suspend(() => S.Struct({ email: S.optional(S.String), ip: S.optional(S.String), }), ).annotate({ identifier: "ListRequestActor", }) as any as S.Schema; export type ListRequestDirection = "desc" | "asc"; export const ListRequestDirection = /*@__PURE__*/ S.String; export interface ListRequestZone { /** Filters by the name of the zone associated to the change. */ name?: string; } export const ListRequestZone = /*@__PURE__*/ S.suspend(() => S.Struct({ name: S.optional(S.String), }), ).annotate({ identifier: "ListRequestZone", }) as any as S.Schema; export interface ListAuditLogsRequest { /** Identifier */ accountId: string; /** Finds a specific log by its ID. */ id?: string; action?: ListRequestAction; actor?: ListRequestActor; /** Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339. */ before?: string; /** Changes the direction of the chronological sorting. */ direction?: ListRequestDirection | (string & {}); /** Indicates that this request is an export of logs in CSV format. */ export?: boolean; /** Indicates whether or not to hide user level audit logs. */ hideUserLogs?: boolean; /** Defines which page of results to return. */ page?: number; /** Sets the number of results to return per page. */ perPage?: number; /** Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339. */ since?: string; zone?: ListRequestZone; } export const ListAuditLogsRequest = /*@__PURE__*/ S.suspend(() => S.Struct({ accountId: S.String.pipe(T.Label("account_id")), id: S.optional(S.String.pipe(T.Query())), action: S.optional(ListRequestAction.pipe(T.DeepQuery("action"))), actor: S.optional(ListRequestActor.pipe(T.DeepQuery("actor"))), before: S.optional(S.String.pipe(T.Query())), direction: S.optional(ListRequestDirection.pipe(T.Query())), export: S.optional(S.Boolean.pipe(T.Query())), hideUserLogs: S.optional(S.Boolean.pipe(T.Query("hide_user_logs"))), page: S.optional(S.Number.pipe(T.Query())), perPage: S.optional(S.Number.pipe(T.Query("per_page"))), since: S.optional(S.String.pipe(T.Query())), zone: S.optional(ListRequestZone.pipe(T.DeepQuery("zone"))), }) .pipe( T.Http({ method: "GET", uri: "/accounts/{account_id}/audit_logs", code: 200, }), ) .pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListAuditLogsRequest", }) as any as S.Schema; export interface ListResultItemAction { /** A boolean that indicates if the action attempted was successful. */ result?: boolean | null; /** A short string that describes the action that was performed. */ type?: string | null; } export const ListResultItemAction = /*@__PURE__*/ S.suspend(() => S.Struct({ result: S.optional(S.NullOr(S.Boolean)), type: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "ListResultItemAction", }) as any as S.Schema; export type ListResultItemActorType = "user" | "admin" | "Cloudflare"; export const ListResultItemActorType = /*@__PURE__*/ S.String; export interface ListResultItemActor { /** The ID of the actor that performed the action. If a user performed the action, this will be their User ID. */ id?: string | null; /** The email of the user that performed the action. */ email?: string | null; /** The IP address of the request that performed the action. */ ip?: string | null; /** The type of actor, whether a User, Cloudflare Admin, or an Automated System. */ type?: ListResultItemActorType | null; } export const ListResultItemActor = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), email: S.optional(S.NullOr(S.String)), ip: S.optional(S.NullOr(S.String)), type: S.optional(S.NullOr(ListResultItemActorType)), }), ).annotate({ identifier: "ListResultItemActor", }) as any as S.Schema; export interface ListResultItemOwner { /** Identifier */ id?: string | null; } export const ListResultItemOwner = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "ListResultItemOwner", }) as any as S.Schema; export interface ListResultItemResource { /** An identifier for the resource that was affected by the action. */ id?: string | null; /** A short string that describes the resource that was affected by the action. */ type?: string | null; } export const ListResultItemResource = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), type: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "ListResultItemResource", }) as any as S.Schema; export interface ListResultItem { /** A string that uniquely identifies the audit log. */ id?: string | null; action?: ListResultItemAction | null; actor?: ListResultItemActor | null; /** The source of the event. */ interface?: string | null; /** An object which can lend more context to the action being logged. This is a flexible value and varies between different actions. */ metadata?: unknown | null; /** The new value of the resource that was modified. */ newValue?: string | null; /** The value of the resource before it was modified. */ oldValue?: string | null; owner?: ListResultItemOwner | null; resource?: ListResultItemResource | null; /** A UTC RFC3339 timestamp that specifies when the action being logged occured. */ when?: string | null; } export const ListResultItem = /*@__PURE__*/ S.suspend(() => S.Struct({ id: S.optional(S.NullOr(S.String)), action: S.optional(S.NullOr(ListResultItemAction)), actor: S.optional(S.NullOr(ListResultItemActor)), interface: S.optional(S.NullOr(S.String)), metadata: S.optional(S.NullOr(S.Unknown)), newValue: S.optional(S.NullOr(S.String)), oldValue: S.optional(S.NullOr(S.String)), owner: S.optional(S.NullOr(ListResultItemOwner)), resource: S.optional(S.NullOr(ListResultItemResource)), when: S.optional(S.NullOr(S.String)), }), ).annotate({ identifier: "ListResultItem" }) as any as S.Schema; export type ListResultList = Array; export const ListResultList = /*@__PURE__*/ S.Array( ListResultItem, ) as any as S.Schema; export interface ListAuditLogsResponse { /** The unwrapped `result` payload of the v4 response envelope. */ result: ListResultList; /** Pagination info from the envelope's `result_info`. */ resultInfo?: ResultInfo | null; } export const ListAuditLogsResponse = /*@__PURE__*/ S.suspend(() => S.Struct({ result: ListResultList.pipe(T.EnvelopePayload()), resultInfo: S.optional(S.NullOr(ResultInfo).pipe(T.ResultInfo())), }).pipe(T.KeyDictionary(KEY_DICTIONARY)), ).annotate({ identifier: "ListAuditLogsResponse", }) as any as S.Schema; export type ListAuditLogsError = CloudflareOpError; /** Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change. */ export const listAuditLogs: API.PaginatedOperationMethod< ListAuditLogsRequest, ListAuditLogsResponse, ListAuditLogsError, CloudflareOpContext, ListResultItem > = /*@__PURE__*/ API.makePaginated( () => ({ input: ListAuditLogsRequest, output: ListAuditLogsResponse, errors: [CloudflareRateLimited, CloudflareError], protocol: CloudflarePaginatedProtocol, retry: Retry.Retry, pagination: { mode: "page", inputToken: "page", outputToken: "resultInfo.page", items: "result", pageSize: "perPage", } as const, }), cloudflarePaginate, ) as any;