import type { Except, JsonValue, SetOptional } from 'type-fest';
import type { BasicMetaSysProps, CollectionProp, DefaultElements, MakeRequest, MetaLinkProps, SysLink } from '../common-types';
interface EqualityConstraint {
    equals: [Doc, string];
}
interface Doc {
    doc: 'sys.id' | 'sys.contentType.sys.id' | 'sys.environment.sys.id';
}
interface InConstraint {
    in: [Doc, [string, ...string[]]];
}
interface RegexpConstraint {
    regexp: [Doc, Pattern];
}
interface Pattern {
    pattern: string;
}
interface NotConstraint {
    not: EqualityConstraint | InConstraint | RegexpConstraint;
}
export type WebhookCalls = {
    total: number;
    healthy: number;
};
export type WebhookCallRequest = {
    url: string;
    method: string;
    headers: {
        [key: string]: string;
    };
    body: string;
};
export type WebhookCallResponse = WebhookCallRequest & {
    statusCode: number;
};
export type WebhookHealthSys = Except<BasicMetaSysProps, 'version' | 'updatedAt' | 'updatedBy' | 'createdAt'>;
export type WebhookCallDetailsSys = Except<BasicMetaSysProps, 'version' | 'updatedAt' | 'updatedBy'>;
export type WebhookHeader = {
    key: string;
    value: string;
    secret?: boolean;
};
export type WebhookFilter = EqualityConstraint | InConstraint | RegexpConstraint | NotConstraint;
export type WebhookTransformation = {
    method?: null | 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
    contentType?: null | 'application/vnd.contentful.management.v1+json' | 'application/vnd.contentful.management.v1+json; charset=utf-8' | 'application/json' | 'application/json; charset=utf-8' | 'application/x-www-form-urlencoded' | 'application/x-www-form-urlencoded; charset=utf-8';
    includeContentLength?: boolean | null;
    body?: JsonValue;
};
export type CreateWebhooksProps = SetOptional<Except<WebhookProps, 'sys'>, 'headers' | 'active'>;
export type UpdateWebhookProps = SetOptional<Except<WebhookProps, 'sys'>, 'headers' | 'name' | 'topics' | 'url' | 'active'>;
export type UpsertWebhookSigningSecretPayload = {
    value: string;
};
export type WebhookCallDetailsProps = {
    /**
     * System metadata
     */
    sys: WebhookCallDetailsSys;
    /**
     * Request object
     */
    request: WebhookCallRequest;
    /**
     * Request object
     */
    response: WebhookCallResponse;
    /**
     * Status code of the request
     */
    statusCode: number;
    /**
     * Errors
     */
    errors: any[];
    /**
     * Type of the webhook
     */
    eventType: string;
    /**
     * Url of the request
     */
    url: string;
    /**
     * Timestamp of the request
     */
    requestAt: string;
    /**
     * Timestamp of the response
     */
    responseAt: string;
};
export type WebhookCallOverviewProps = Except<WebhookCallDetailsProps, 'request' | 'response'>;
export type WebhookHealthProps = {
    /**
     * System metadata
     */
    sys: WebhookHealthSys & {
        space: {
            sys: MetaLinkProps;
        };
    };
    /**
     * Webhook call statistics
     */
    calls: WebhookCalls;
};
export type WebhookSigningSecretSys = Except<BasicMetaSysProps, 'version'>;
export type WebhookSigningSecretProps = {
    sys: WebhookSigningSecretSys & {
        space: {
            sys: MetaLinkProps;
        };
    };
    redactedValue: string;
};
export type WebhookRetryPolicyPayload = {
    maxRetries: number;
};
export type WebhookRetryPolicySys = Except<BasicMetaSysProps, 'version'>;
export type WebhookRetryPolicyProps = {
    sys: WebhookRetryPolicySys & {
        space: {
            sys: MetaLinkProps;
        };
    };
    maxRetries: number;
};
export type WebhookProps = {
    /**
     * System metadata
     */
    sys: BasicMetaSysProps & {
        space: SysLink;
    };
    /**
     * Webhook name
     */
    name: string;
    /**
     * Webhook url
     */
    url: string;
    /**
     * Topics the webhook wants to subscribe to
     */
    topics: string[];
    /**
     * Username for basic http auth
     */
    httpBasicUsername?: string;
    /**
     * Password for basic http auth
     */
    httpBasicPassword?: string;
    /**
     * Headers that should be appended to the webhook request
     */
    headers: Array<WebhookHeader>;
    /**
     * Webhook filters
     */
    filters?: WebhookFilter[];
    /**
     * Transformation to apply
     */
    transformation?: WebhookTransformation;
    /**
     * Whether the Webhook is active. If set to false, no calls will be made
     */
    active: boolean;
};
export interface WebHooks extends WebhookProps, DefaultElements<WebhookProps> {
    /**
     * Sends an update to the server with any changes made to the object's properties
     * @returns Object returned from the server with updated changes.
     * ```javascript
     * const contentful = require('contentful-management')
     *
     * const client = contentful.createClient({
     *   accessToken: '<content_management_api_key>'
     * })
     *
     * client.getSpace('<space_id>')
     * .then((space) => space.getWebhook('<webhook_id>'))
     * .then((webhook) => {
     *  webhook.name = 'new webhook name'
     *  return webhook.update()
     * })
     * .then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
     * .catch(console.error)
     * ```
     */
    update(): Promise<WebHooks>;
    /**
     * Deletes this object on the server.
     * @returns Promise for the deletion. It contains no data, but the Promise error case should be handled.
     * ```javascript
     * const contentful = require('contentful-management')
     *
     * const client = contentful.createClient({
     *   accessToken: '<content_management_api_key>'
     * })
     *
     * client.getSpace('<space_id>')
     * .then((space) => space.getWebhook('<webhook_id>'))
     * .then((webhook) => webhook.delete())
     * .then((webhook) => console.log(`webhook ${webhook.sys.id} updated.`))
     * .catch(console.error)
     * ```
     */
    delete(): Promise<void>;
    /**
     * List of the most recent webhook calls. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details.
     * @returns Promise for list of calls
     * ```javascript
     * const contentful = require('contentful-management')
     *
     * const client = contentful.createClient({
     *   accessToken: '<content_management_api_key>'
     * })
     *
     * client.getSpace('<space_id>')
     * .then((space) => space.getWebhook('<webhook_id>'))
     * .then((webhook) => webhook.getCalls())
     * .then((response) => console.log(response.items)) // webhook calls
     * .catch(console.error)
     * ```
     */
    getCalls(): Promise<CollectionProp<WebhookCallOverviewProps>>;
    /**
     * Webhook call with specific id. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details
     * @returns Promise for call details
     * ```javascript
     * const contentful = require('contentful-management')
     *
     * const client = contentful.createClient({
     *   accessToken: '<content_management_api_key>'
     * })
     *
     * client.getSpace('<space_id>')
     * .then((space) => space.getWebhook('<webhook_id>'))
     * .then((webhook) => webhook.getCall('<call-id>'))
     * .then((webhookCall) => console.log(webhookCall))
     * .catch(console.error)
     * ```
     */
    getCall(id: string): Promise<WebhookCallDetailsProps>;
    /**
     * Overview of the health of webhook calls. See https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-call-overviews for more details.
     * @returns Promise for health info
     * ```javascript
     * const contentful = require('contentful-management')
     *
     * const client = contentful.createClient({
     *   accessToken: '<content_management_api_key>'
     * })
     *
     * client.getSpace('<space_id>')
     * .then((space) => space.getWebhook('<webhook_id>'))
     * .then((webhook) => webhook.getHealth())
     * .then((webhookHealth) => console.log(webhookHealth))
     * .catch(console.error)
     * ```
     */
    getHealth(): Promise<WebhookHealthProps>;
}
/**
 * @internal
 * @param makeRequest - function to make requests via an adapter
 * @param data - Raw webhook data
 * @returns Wrapped webhook data
 */
export declare function wrapWebhook(makeRequest: MakeRequest, data: WebhookProps): WebHooks;
/**
 * @internal
 */
export declare const wrapWebhookCollection: (makeRequest: MakeRequest, data: CollectionProp<WebhookProps>) => import("..").Collection<WebHooks, WebhookProps>;
export {};
