import type { WebhookConfig, WebhookDelivery } from "../_internal/types.gen";
import type { RequestOptions } from "../base-client";
import { RequestBuilder } from "../request-builder";
/** Attributes for creating a new webhook configuration. */
export type CreateWebhookConfigAttributes = {
    name: string;
    url: string;
    events?: string[];
    enabled?: boolean;
    secret?: string;
    application_id?: string;
    tenant_id?: string | null;
    tenant_ids?: string[] | null;
    workspace_ids?: string[] | null;
    filter_expression?: Record<string, unknown> | null;
};
/**
 * Attributes for updating a webhook configuration.
 *
 * Note: `secret` is intentionally absent — the resource `:update` action does
 * not accept it. Use `rotateSecret` to change the HMAC signing secret.
 */
export type UpdateWebhookConfigAttributes = {
    name?: string;
    url?: string;
    events?: string[];
    enabled?: boolean;
    filter_expression?: Record<string, unknown> | null;
    tenant_ids?: string[] | null;
    workspace_ids?: string[] | null;
};
/**
 * Webhook infrastructure management.
 *
 * Administers webhook endpoint configurations (`configs`) and their delivery
 * records (`deliveries`). Webhook events are dispatched asynchronously via
 * the WebhookSender Oban worker and signed with an HMAC secret for verification.
 */
export declare function createWebhooksNamespace(rb: RequestBuilder): {
    configs: {
        /**
         * Lists all webhook configurations.
         *
         * @param options - Optional request options.
         * @returns Array of WebhookConfig objects.
         */
        list: (options?: RequestOptions) => Promise<WebhookConfig[]>;
        /**
         * Registers a new webhook endpoint to receive platform events.
         *
         * Scope constraints (`tenant_id`, `tenant_ids`, `workspace_ids`) and payload
         * filters (`filter_expression`) are all accepted on create — no follow-up
         * update call is required. The `application_id` is inferred from the API key
         * if not supplied.
         *
         * The `secret` in the response is shown exactly once. Store it immediately —
         * it is used to verify `X-GptCore-Signature` headers on every delivery.
         *
         * @param attributes - Webhook configuration attributes.
         * @param options - Optional request options.
         * @returns The created WebhookConfig, including the plaintext `secret`.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const config = await admin.webhooks.configs.create({
         *   name: "case-decisions-to-zapier",
         *   url: "https://hooks.zapier.com/hooks/catch/...",
         *   events: ["case.decided"],
         *   workspace_ids: ["<workspace-uuid>"],
         *   filter_expression: {
         *     path: "data.case.priority",
         *     op: "eq",
         *     value: "urgent"
         *   }
         * });
         *
         * @see docs/domains/communication.md — Filter DSL and scoping reference
         */
        create: (attributes: CreateWebhookConfigAttributes, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Fetches a single webhook configuration by ID.
         *
         * @param id - WebhookConfig ID.
         * @param options - Optional request options.
         * @returns The WebhookConfig.
         */
        get: (id: string, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Updates webhook endpoint settings.
         *
         * `filter_expression` accepts `eq`, `not_eq`, `contains`, `in`, and `not_null`
         * operators against dot-notation paths into the event payload (e.g.
         * `"data.status"`). Expressions are fail-open: malformed or unresolvable
         * expressions pass all events rather than blocking delivery.
         *
         * To change the HMAC signing secret, use `rotateSecret` instead.
         *
         * @param id - WebhookConfig ID.
         * @param attributes - Partial attributes to update.
         * @param options - Optional request options.
         * @returns Updated WebhookConfig.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const config = await admin.webhooks.configs.update("<config-uuid>", {
         *   enabled: false,
         *   events: ["case.decided", "case.reopened"],
         * });
         *
         * @see docs/domains/communication.md — Filter DSL and scoping reference
         */
        update: (id: string, attributes: UpdateWebhookConfigAttributes, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Permanently deletes a webhook configuration.
         *
         * This action cannot be undone. Associated delivery records are preserved.
         *
         * @param id - WebhookConfig ID.
         * @param options - Optional request options.
         * @returns `true` on success.
         */
        delete: (id: string, options?: RequestOptions) => Promise<true>;
        /**
         * Sends a realistic sample payload to the webhook URL.
         *
         * Verifies connectivity and signature verification by enqueuing a
         * WebhookSender Oban job tagged with `test: true`. Use this to confirm
         * the endpoint is reachable and parsing HMAC signatures correctly before
         * subscribing to live events.
         *
         * @param id - WebhookConfig ID.
         * @param options - Optional request options.
         * @returns The WebhookConfig on success.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * await admin.webhooks.configs.test("<config-uuid>");
         */
        test: (id: string, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Generates a new HMAC-SHA256 signing secret for a webhook configuration,
         * immediately invalidating the old one.
         *
         * The new secret is returned in the response and is the only time it will
         * be visible in plaintext — store it securely immediately.
         *
         * @param id - WebhookConfig ID.
         * @param options - Optional request options.
         * @returns The WebhookConfig with the new `attributes.secret` populated.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const rotated = await admin.webhooks.configs.rotateSecret("<config-uuid>");
         * // Persist rotated.secret immediately — shown only once.
         */
        rotateSecret: (id: string, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Enables multiple webhook configurations by ID in a single batch call.
         *
         * Only configs the actor is authorized to update are affected. Returns
         * a count of how many configs were enabled.
         *
         * @param ids - Array of WebhookConfig IDs to enable.
         * @param options - Optional request options.
         * @returns An object with `success: true` and the count of enabled configs.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const { count } = await admin.webhooks.configs.bulkEnable([
         *   "<config-uuid-1>",
         *   "<config-uuid-2>",
         * ]);
         */
        bulkEnable: (ids: string[], options?: RequestOptions) => Promise<{
            success: boolean;
            count: number;
        }>;
        /**
         * Disables multiple webhook configurations by ID in a single batch call.
         *
         * Only configs the actor is authorized to update are affected. Returns
         * a count of how many configs were disabled.
         *
         * @param ids - Array of WebhookConfig IDs to disable.
         * @param options - Optional request options.
         * @returns An object with `success: true` and the count of disabled configs.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const { count } = await admin.webhooks.configs.bulkDisable([
         *   "<config-uuid-1>",
         *   "<config-uuid-2>",
         * ]);
         */
        bulkDisable: (ids: string[], options?: RequestOptions) => Promise<{
            success: boolean;
            count: number;
        }>;
        /**
         * Re-delivers a range of historical platform events to a webhook endpoint.
         *
         * Use this when an endpoint was down or misconfigured during a window of
         * events and you need to retroactively process those events.
         *
         * @param id - WebhookConfig ID to replay events to.
         * @param options - Optional request options.
         * @returns The WebhookConfig annotated with replay job metadata.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * await admin.webhooks.configs.replay("<config-uuid>");
         */
        replay: (id: string, options?: RequestOptions) => Promise<WebhookConfig>;
        /**
         * Returns aggregated delivery statistics across all webhook configurations.
         *
         * Provides counts of total, successful, failed, and pending deliveries
         * along with average latency metrics. Useful for monitoring webhook
         * health across the platform.
         *
         * @param options - Optional request options.
         * @returns An object containing delivery statistics.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const stats = await admin.webhooks.configs.stats();
         * console.log(stats.failed, stats.pending);
         */
        stats: (options?: RequestOptions) => Promise<Record<string, unknown>>;
        /**
         * Lists the webhook event types this specific configuration is
         * authorized to subscribe to.
         *
         * Unlike the top-level `listEventTypes()` (which returns the global
         * platform catalog), this endpoint authorizes the caller against the
         * specific webhook config first, then returns its resolvable event
         * catalog. Use it to validate the `events` array for one config.
         *
         * @param id - WebhookConfig ID.
         * @param options - Optional request options.
         * @returns A promise resolving to the event type descriptors available
         *   to this configuration.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const events = await admin.webhooks.configs.listEvents("<config-uuid>");
         */
        listEvents: (id: string, options?: RequestOptions) => Promise<Record<string, unknown>>;
    };
    /**
     * Lists all available webhook event types supported by the platform.
     *
     * Returns the complete event catalog. Use this to discover which event
     * types exist, understand their payload shape, and validate the `events`
     * array when registering or updating webhook configs.
     *
     * @param options - Optional request options.
     * @returns A promise that resolves to an array of event type descriptors,
     *   each with `type`, `description`, and `data_object`.
     *
     * @example
     * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
     * const types = await admin.webhooks.listEventTypes();
     * console.log(types.map(t => t.type));
     */
    listEventTypes: (options?: RequestOptions) => Promise<Array<{
        type: string;
        description: string;
        data_object: string;
    }>>;
    deliveries: {
        /**
         * Lists all webhook delivery records across all configurations.
         *
         * Each delivery record tracks the attempt count, status, payload, and
         * response for a single event dispatch.
         *
         * @param options - Optional request options.
         * @returns Array of WebhookDelivery objects.
         */
        list: (options?: RequestOptions) => Promise<WebhookDelivery[]>;
        /**
         * Fetches a single delivery record by ID.
         *
         * @param id - WebhookDelivery ID.
         * @param options - Optional request options.
         * @returns The WebhookDelivery.
         */
        get: (id: string, options?: RequestOptions) => Promise<WebhookDelivery>;
        /**
         * Re-enqueues a failed or pending delivery for immediate re-dispatch.
         *
         * Sets the delivery status to `retrying` and inserts a new WebhookSender
         * Oban job. Use this to recover from transient endpoint failures without
         * waiting for the automatic retry schedule.
         *
         * @param id - WebhookDelivery ID.
         * @param options - Optional request options.
         * @returns Updated WebhookDelivery with status `retrying`.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * await admin.webhooks.deliveries.retry("<delivery-uuid>");
         */
        retry: (id: string, options?: RequestOptions) => Promise<WebhookDelivery>;
        /**
         * Sets multiple delivery records to `retrying` status in bulk.
         *
         * Authorization is actor-scoped — only deliveries the actor can update
         * are affected. Use this to recover from endpoint outages without
         * retrying each delivery individually.
         *
         * @param ids - Array of WebhookDelivery IDs to retry.
         * @param options - Optional request options.
         * @returns An object with `success: true` and the count of queued retries.
         *
         * @example
         * const admin = new GptAdmin({ apiKey: "sk_srv_..." });
         *
         * const { count } = await admin.webhooks.deliveries.bulkRetry([
         *   "<delivery-uuid-1>",
         *   "<delivery-uuid-2>",
         * ]);
         */
        bulkRetry: (ids: string[], options?: RequestOptions) => Promise<{
            success: boolean;
            count: number;
        }>;
    };
};
//# sourceMappingURL=webhooks-ns.d.ts.map