UNPKG

azion

Version:

Azion Packages for Edge Computing.

1,454 lines (1,363 loc) 85.3 kB
declare enum AdaptiveDeliveryAction { IGNORE = "ignore", OPTIMIZE = "optimize" } declare interface Address { address: string; weight?: number | null; server_role?: ServerRole; is_active?: boolean; } declare interface ApiApplication extends ApiBaseApplicationPayload { id: number; } export declare interface ApiBaseApplicationPayload { name: string; delivery_protocol?: DeliveryProtocol; http3?: boolean; http_port?: HttpPort[]; https_port?: HttpsPort[]; minimum_tls_version?: TlsVersion; active?: boolean; debug_rules?: boolean; application_acceleration?: boolean; caching?: boolean; device_detection?: boolean; edge_firewall?: boolean; edge_functions?: boolean; image_optimization?: boolean; l2_caching?: boolean; load_balancer?: boolean; raw_logs?: boolean; web_application_firewall?: boolean; supported_ciphers?: SupportedCiphers; } export declare interface ApiBaseCacheSettingPayload { name: string; browser_cache_settings?: BrowserCacheSettings; browser_cache_settings_maximum_ttl?: number; cdn_cache_settings?: CdnCacheSettings; cdn_cache_settings_maximum_ttl?: number; cache_by_query_string?: CacheByQueryString; query_string_fields?: string[]; enable_query_string_sort?: boolean; cache_by_cookies?: CacheByCookies; cookie_names?: string[]; adaptive_delivery_action?: AdaptiveDeliveryAction; device_group?: string[]; enable_caching_for_post?: boolean; l2_caching_enabled?: boolean; is_slice_configuration_enabled?: boolean; is_slice_edge_caching_enabled?: boolean; is_slice_l2_caching_enabled?: boolean; slice_configuration_range?: number; enable_caching_for_options?: boolean; enable_stale_cache?: boolean; l2_region?: string | null; } declare interface ApiBaseDeviceGroupPayload { name: string; user_agent: string; } export declare interface ApiBaseFunctionInstancePayload { name: string; code: string; language: 'JavaScript'; initiator_type: 'edge_application' | 'edge_firewall'; active: boolean; json_args: Record<string, unknown>; } declare interface ApiCacheSetting extends ApiBaseCacheSettingPayload { id: number; } declare interface ApiCreateApplicationPayload extends ApiBaseApplicationPayload { } declare interface ApiCreateCacheSettingPayload extends ApiBaseCacheSettingPayload { } declare interface ApiCreateDeviceGroupPayload extends ApiBaseDeviceGroupPayload { } declare interface ApiCreateFunctionInstancePayload { name: string; edge_function_id: number; args: Record<string, unknown>; active?: boolean; } export declare type ApiCreateOriginPayload = Omit<ApiOrigin, 'id' | 'method'> & { origin_path?: string; hmac_authentication?: boolean; hmac_region_name?: string; hmac_access_key?: string; hmac_secret_key?: string; connection_timeout?: number; timeout_between_bytes?: number; }; export declare interface ApiCreateRulePayload { name: string; phase: 'request' | 'response'; behaviors: Behavior[]; criteria: Criterion[][]; is_active?: boolean; order?: number; description?: string; } export declare interface ApiCreateRulePayload { name: string; phase: 'request' | 'response'; behaviors: Behavior[]; criteria: Criterion[][]; is_active?: boolean; order?: number; description?: string; } declare interface ApiFunctionInstance extends ApiBaseFunctionInstancePayload { id: number; } export declare interface ApiListApplicationsParams { page?: number; page_size?: number; sort?: 'name' | 'id'; order_by?: string; } export declare interface ApiListCacheSettingsParams { page?: number; page_size?: number; sort?: 'name' | 'id'; order?: 'asc' | 'desc'; } declare interface ApiListDeviceGroupsParams { page?: number; page_size?: number; sort?: 'name' | 'id'; order?: 'asc' | 'desc'; } export declare interface ApiListFunctionInstancesParams { page?: number; page_size?: number; sort?: 'name' | 'id'; order?: 'asc' | 'desc'; order_by?: string; filter?: string; } export declare interface ApiListOriginsParams { page?: number; page_size?: number; sort?: 'name' | 'id'; order?: OrderDirection; filter?: string; } export declare interface ApiListRulesParams { page?: number; page_size?: number; sort?: string; order?: 'asc' | 'desc'; filter?: string; } export declare interface ApiListRulesParams { page?: number; page_size?: number; sort?: string; order?: 'asc' | 'desc'; filter?: string; } export declare interface ApiListRulesParams { page?: number; page_size?: number; sort?: string; order?: 'asc' | 'desc'; filter?: string; } declare interface ApiOrigin { id: number; origin_key: string; name: string; origin_type: OriginType; addresses: Address[]; origin_protocol_policy: OriginProtocolPolicy; is_origin_redirection_enabled: boolean; host_header: string; method: string; origin_path: string; connection_timeout: number; timeout_between_bytes: number; hmac_authentication: boolean; hmac_region_name: string; hmac_access_key: string; hmac_secret_key: string; } declare interface ApiRuleResponse { results: Rule; schema_version: number; } declare interface ApiRuleResponse { results: Rule; schema_version: number; } export declare interface ApiUpdateApplicationPayload extends Partial<ApiBaseApplicationPayload> { } export declare interface ApiUpdateCacheSettingPayload extends Partial<ApiBaseCacheSettingPayload> { } declare interface ApiUpdateDeviceGroupPayload extends Partial<ApiBaseDeviceGroupPayload> { } export declare interface ApiUpdateFunctionInstancePayload extends Partial<ApiBaseFunctionInstancePayload> { } export declare type ApiUpdateOriginRequest = Partial<ApiCreateOriginPayload> & { id: number; }; export declare interface ApiUpdateRulePayload extends Partial<ApiCreateRulePayload> { } export declare interface ApiUpdateRulePayload extends Partial<ApiCreateRulePayload> { } /** * Interface representing an Azion Application with all its associated operations. * * @interface AzionApplication * @extends ApiApplication */ export declare interface AzionApplication extends ApiApplication { /** * Operations related to cache settings for the application. * @type {CacheOperations} * * @example * // Creating a new cache setting * const { error, data } = await application.cache.createCacheSetting({ * data: { * name: 'My Cache Setting', * browser_cache_settings: 'override', * cdn_cache_settings: 'override', * cache_by_query_string: 'ignore' * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created cache setting:', data); * } */ cache: CacheOperations; /** * Operations related to origins for the application. * @type {OriginOperations} * * @example * // Creating a new origin * const { error, data } = await application.origins.createOrigin({ * data: { * name: 'My Origin', * addresses: [{ address: 'example.com' }], * origin_type: 'single_origin', * host_header: 'example.com' * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created origin:', data); * } */ origins: OriginOperations; /** * Operations related to rules for the application. * @type {{ request: RuleOperations; response: RuleOperations }} */ rules: { /** * Operations for request rules. * @type {RuleOperations} * * @example * // Creating a new request rule * const { error, data } = await application.rules.request.createRule({ * data: { * name: 'My Request Rule', * phase: 'request', * behaviors: [{ name: 'set_origin', target: 'origin1' }], * criteria: [[{ conditional: 'if', input: '${uri}', operator: 'starts_with', value: '/api' }]] * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created request rule:', data); * } */ request: RuleOperations; /** * Operations for response rules. * @type {RuleOperations} * * @example * // Creating a new response rule * const { error, data } = await application.rules.response.createRule({ * data: { * name: 'My Response Rule', * phase: 'response', * behaviors: [{ name: 'add_response_header', target: 'X-Custom-Header', value: 'CustomValue' }], * criteria: [[{ conditional: 'if', input: '${status}', operator: 'is_equal', value: '200' }]] * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created response rule:', data); * } */ response: RuleOperations; }; /** * Operations related to device groups for the application. * @type {DeviceGroupOperations} * * @example * // Creating a new device group * const { error, data } = await application.devices.createDeviceGroup({ * data: { * name: 'Mobile Devices', * user_agent: 'Mobile|Android|iPhone|iPad|iPod' * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created device group:', data); * } */ devices: DeviceGroupOperations; /** * Operations related to functions for the application. * @type {FunctionOperations} * * @example * // Creating a new function instance * const { error, data } = await application.functions.createFunctionInstance({ * data: { * name: 'My Function', * edge_function_id: 5678, * args: {} * } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created function instance:', data); * } */ functions: FunctionOperations; } /** * Options for retrieving a collection of Azion applications. * * @interface AzionApplicationCollectionOptions * @property {number} [page] - The page number for pagination. * @property {number} [page_size] - The number of items per page. * @property {'name' | 'id'} [sort] - The field to sort the results by. * @property {string} [order_by] - The order of the sorting (e.g., 'asc' or 'desc'). */ export declare interface AzionApplicationCollectionOptions { page?: number; page_size?: number; sort?: 'name' | 'id'; order_by?: string; } /** * Generic response structure for Azion API calls returning collections. * * @interface AzionApplicationCollectionResponse * @template T - The type of items in the collection. * @property {{ count: number; total_pages: number; schema_version: number; links: { previous: string | null; next: string | null }; results: T[] }} [data] - The collection data. * @property {{ message: string; operation: string }} [error] - Error information if the call failed. */ export declare interface AzionApplicationCollectionResponse<T> { data?: { count: number; total_pages: number; schema_version: number; links: { previous: string | null; next: string | null; }; results: T[]; }; error?: { message: string; operation: string; }; } /** * Generic response structure for Azion API calls. * * @interface AzionApplicationResponse * @template T - The type of data returned in the response. * @property {T} [data] - The response data. * @property {{ message: string; operation: string }} [error] - Error information if the call failed. */ export declare interface AzionApplicationResponse<T> { data?: T; error?: { message: string; operation: string; }; } /** * Interface for the Azion Application Client, providing methods to interact with Azion Edge Applications. * * @interface AzionApplicationsClient */ export declare interface AzionApplicationsClient { /** * Creates a new Azion Edge Application. * * @function * @name AzionApplicationsClient.createApplication * @param {Object} params - The parameters for creating an application. * @param {ApiCreateApplicationPayload} params.data - The data for the new application. * @returns {Promise<AzionApplicationResponse<AzionApplication>>} A promise that resolves with the created application data or an error. * * @example * const { error, data } = await applicationClient.createApplication({ * data: { * name: 'My New Application', * delivery_protocol: 'http', * origin_type: 'single_origin', * address: 'example.com' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created application:', data); * } */ createApplication: (params: { data: ApiCreateApplicationPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionApplication>>; /** * Retrieves a specific Azion Edge Application. * * @function * @name AzionApplicationsClient.getApplication * @param {Object} params - The parameters for retrieving an application. * @param {number} params.applicationId - The ID of the application to retrieve. * @returns {Promise<AzionApplicationResponse<AzionApplication>>} A promise that resolves with the application data or an error. * * @example * const { error, data } = await applicationClient.getApplication({ * applicationId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved application:', data); * } */ getApplication: (params: { applicationId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionApplication>>; /** * Retrieves a list of Azion Edge Applications. * * @function * @name AzionApplicationsClient.getApplications * @param {Object} params - The parameters for retrieving applications. * @param {AzionApplicationCollectionOptions} [params.params] - Optional parameters for filtering and pagination. * @returns {Promise<AzionApplicationCollectionResponse<AzionApplication>>} A promise that resolves with a collection of applications or an error. * * @example * const { error, data } = await applicationClient.getApplications({ * params: { page: 1, page_size: 20 }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved applications:', data.results); * } */ getApplications: (params: { params?: AzionApplicationCollectionOptions; options?: AzionClientOptions; }) => Promise<AzionApplicationCollectionResponse<AzionApplication>>; /** * Updates an existing Azion Edge Application. * * @function * @name AzionApplicationsClient.putApplication * @param {Object} params - The parameters for updating an application. * @param {number} params.applicationId - The ID of the application to update. * @param {ApiUpdateApplicationPayload} params.data - The updated data for the application. * @returns {Promise<AzionApplicationResponse<AzionApplication>>} A promise that resolves with the updated application data or an error. * * @example * const { error, data } = await applicationClient.putApplication({ * applicationId: 123, * data: { * name: 'Updated Application', * delivery_protocol: 'https' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Updated application:', data); * } */ putApplication: (params: { applicationId: number; data: ApiUpdateApplicationPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionApplication>>; /** * Deletes an Azion Edge Application. * * @function * @name AzionApplicationsClient.deleteApplication * @param {Object} params - The parameters for deleting an application. * @param {number} params.applicationId - The ID of the application to delete. * @returns {Promise<AzionApplicationResponse<void>>} A promise that resolves when the application is deleted or rejects with an error. * * @example * const { error, data } = await applicationClient.deleteApplication({ * applicationId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Application deleted successfully'); * } */ deleteApplication: (params: { applicationId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Partially updates an existing Azion Edge Application. * * @function * @name AzionApplicationsClient.patchApplication * @param {Object} params - The parameters for partially updating an application. * @param {number} params.applicationId - The ID of the application to update. * @param {Partial<ApiUpdateApplicationPayload>} params.data - The partial data for updating the application. * @returns {Promise<AzionApplicationResponse<AzionApplication>>} A promise that resolves with the updated application data or an error. * * @example * const { error, data } = await applicationClient.patchApplication({ * applicationId: 123, * data: { name: 'Partially Updated Application' }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Partially updated application:', data); * } */ patchApplication: (params: { applicationId: number; data: Partial<ApiUpdateApplicationPayload>; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionApplication>>; } export declare type AzionApplicationSettings = ApiApplication; export declare type AzionCacheSetting = ApiCacheSetting; /** * @fileoverview This module defines the types and interfaces used throughout the Azion Application SDK. * It includes definitions for client options, response structures, and operation interfaces for various * Azion Edge Application features such as cache settings, origins, rules, device groups, and functions. * @module application/types */ /** * Options for configuring the Azion client behavior. * * @interface AzionClientOptions * @property {boolean} [debug] - Enable debug mode for detailed logging. * @property {boolean} [force] - Force the operation even if it might be destructive. */ export declare interface AzionClientOptions { debug?: boolean; force?: boolean; } export declare interface AzionDeviceGroup { id: number; name: string; user_agent: string; } export declare type AzionFunctionInstance = ApiFunctionInstance; export declare type AzionOrigin = ApiOrigin; export declare type AzionRule = ApiRuleResponse['results']; declare interface Behavior { name: string; target?: string | null | BehaviorTarget; } declare interface Behavior { name: string; target?: string | null | BehaviorTarget; } declare interface BehaviorTarget { captured_array: string; subject: string; regex: string; } declare interface BehaviorTarget { captured_array: string; subject: string; regex: string; } declare enum BrowserCacheSettings { HONOR = "honor", OVERRIDE = "override", IGNORE = "ignore" } declare enum CacheByCookies { IGNORE = "ignore", WHITELIST = "whitelist", BLACKLIST = "blacklist", ALL = "all" } declare enum CacheByQueryString { IGNORE = "ignore", WHITELIST = "whitelist", BLACKLIST = "blacklist", ALL = "all" } /** * Interface for cache setting operations. * * @interface CacheOperations */ export declare interface CacheOperations { /** * Creates a new cache setting. * * @function * @name CacheOperations.createCacheSetting * @param {Object} params - The parameters for creating a cache setting. * @param {ApiCreateCacheSettingPayload} params.data - The data for the new cache setting. * @returns {Promise<AzionApplicationResponse<AzionCacheSetting>>} A promise that resolves with the created cache setting data or an error. * * @example * const { error, data } = await cacheOperations.createCacheSetting({ * data: { * name: 'My Cache Setting', * browser_cache_settings: 'override', * cdn_cache_settings: 'override', * cache_by_query_string: 'ignore', * cookie_names: ['session_id'], * enable_stale_cache: true * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created cache setting:', data); * } */ createCacheSetting: (params: { data: ApiCreateCacheSettingPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionCacheSetting>>; /** * Retrieves a specific cache setting. * * @function * @name CacheOperations.getCacheSetting * @param {Object} params - The parameters for retrieving a cache setting. * @param {number} params.cacheSettingId - The ID of the cache setting to retrieve. * @returns {Promise<AzionApplicationResponse<AzionCacheSetting>>} A promise that resolves with the cache setting data or an error. * * @example * const { error, data } = await cacheOperations.getCacheSetting({ * cacheSettingId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved cache setting:', data); * } */ getCacheSetting: (params: { cacheSettingId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionCacheSetting>>; /** * Retrieves a list of cache settings. * * @function * @name CacheOperations.getCacheSettings * @param {Object} params - The parameters for retrieving cache settings. * @param {ApiListCacheSettingsParams} [params.params] - Optional parameters for filtering and pagination. * @returns {Promise<AzionApplicationCollectionResponse<AzionCacheSetting>>} A promise that resolves with a collection of cache settings or an error. * * @example * const { error, data } = await cacheOperations.getCacheSettings({ * params: { page: 1, page_size: 20 }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved cache settings:', data.results); * } */ getCacheSettings: (params: { params?: ApiListCacheSettingsParams; options?: AzionClientOptions; }) => Promise<AzionApplicationCollectionResponse<AzionCacheSetting>>; /** * Updates an existing cache setting. * * @function * @name CacheOperations.updateCacheSetting * @param {Object} params - The parameters for updating a cache setting. * @param {number} params.cacheSettingId - The ID of the cache setting to update. * @param {ApiUpdateCacheSettingPayload} params.data - The updated data for the cache setting. * @returns {Promise<AzionApplicationResponse<AzionCacheSetting>>} A promise that resolves with the updated cache setting data or an error. * * @example * const { error, data } = await cacheOperations.updateCacheSetting({ * cacheSettingId: 123, * data: { * name: 'Updated Cache Setting', * browser_cache_settings: 'honor', * cdn_cache_settings: 'honor' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Updated cache setting:', data); * } */ updateCacheSetting: (params: { cacheSettingId: number; data: ApiUpdateCacheSettingPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionCacheSetting>>; /** * Deletes a cache setting. * * @function * @name CacheOperations.deleteCacheSetting * @param {Object} params - The parameters for deleting a cache setting. * @param {number} params.cacheSettingId - The ID of the cache setting to delete. * @returns {Promise<AzionApplicationResponse<void>>} A promise that resolves when the cache setting is deleted or rejects with an error. * * @example * const { error, data } = await cacheOperations.deleteCacheSetting({ * cacheSettingId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Cache setting deleted successfully'); * } */ deleteCacheSetting: (params: { cacheSettingId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; } declare enum CdnCacheSettings { HONOR = "honor", OVERRIDE = "override" } /** * Creates a new Azion Edge Application. * * @async * @function * @param {Object} params - The parameters for creating an application. * @param {ApiCreateApplicationPayload} params.data - The data for the new application. * @param {AzionClientOptions} [params.options] - Optional client options. * @returns {Promise<AzionApplicationResponse<AzionApplication>>} A promise that resolves with the created application data or an error. * * @example * const result = await createApplication({ * data: { name: 'My New App', delivery_protocol: 'http' }, * options: { debug: true } * }); * if (result.data) { * console.log('Application created:', result.data); * } else { * console.error('Error:', result.error); * } */ export declare const createApplication: ({ data, options, }: { data: ApiCreateApplicationPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionApplication>>; /** * Function type for creating an Azion Application Client. * * @param {Object} [config] - Configuration options for the application client. * @param {string} [config.token] - Authentication token for Azion API. If not provided, * the client will attempt to use the AZION_TOKEN environment variable. * @param {AzionClientOptions} [config.options] - Additional client options. * * @returns {AzionApplicationsClient} An instance of the Azion Application Client. * * @example * // Create an application client with a token and debug mode enabled * const appClient = createAzionApplicationClient({ * token: 'your-api-token', * options: { debug: true } * }); * * @example * // Create an application client using environment variables for token * const appClient = createAzionApplicationClient(); */ export declare type CreateAzionApplicationClient = (config?: Partial<{ token: string; options?: AzionClientOptions; }>) => AzionApplicationsClient; declare const createAzionApplicationClient: CreateAzionApplicationClient; export { createAzionApplicationClient } export default createAzionApplicationClient; /** * Wrapper function to create a new cache setting for a specific application. * * @param {Object} params - Parameters for creating a cache setting. * @param {number} params.applicationId - Application ID. * @param {ApiBaseCacheSettingPayload} params.data - Data for the cache setting to be created. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<AzionCacheSetting>>} The created cache setting or an error. * * @example * const { error, data } = await createCacheSetting({ * applicationId: 1234, * data: { name: 'My Cache Setting', browser_cache_settings: 'override' }, * options: { debug: true } * }); * if (error) { * console.error('Failed to create cache setting:', error); * } else { * console.log('Cache setting created:', data.name); * } */ export declare const createCacheSetting: ({ applicationId, data, options, }: { applicationId: number; data: ApiBaseCacheSettingPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionCacheSetting>>; /** * Function to create a new device group for a specific application. * * @param {Object} params - Parameters for creating a device group. * @param {number} params.applicationId - Application ID. * @param {ApiCreateDeviceGroupPayload} params.data - Data for the device group to be created. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<AzionDeviceGroup>>} The created device group or an error. * * @example * const { error, data } = await createDeviceGroup({ * applicationId: 1234, * data: { name: 'My Device Group', user_agent: 'Mozilla/5.0' }, * options: { debug: true } * }); * if (error) { * console.error('Failed to create device group:', error); * } else { * console.log('Device group created:', data.name); * } */ export declare const createDeviceGroup: ({ applicationId, data, options, }: { applicationId: number; data: ApiCreateDeviceGroupPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionDeviceGroup>>; /** * Create a new function instance for a specific application. * * @param {Object} params - Parameters for creating a function instance. * @param {number} params.applicationId - Application ID. * @param {ApiCreateFunctionInstancePayload} params.data - Data for the function instance to be created. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<AzionFunctionInstance>>} The created function instance or an error. * * @example * const { error, data } = await createFunctionInstance({ * applicationId: 1234, * data: { * name: 'My Function Instance', * edge_function_id: 5678, * args: {} * }, * options: { debug: true } * }); * if (error) { * console.error('Failed to create function instance:', error); * } else { * console.log('Function instance created:', data.name); * } */ export declare const createFunctionInstance: ({ applicationId, data, options, }: { applicationId: number; data: ApiCreateFunctionInstancePayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionFunctionInstance>>; /** * Creates a new origin for a specific application. * * @param {Object} params - Parameters for creating an origin. * @param {number} params.applicationId - Application ID. * @param {ApiCreateOriginPayload} params.data - Data for the origin to be created. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<AzionOrigin>>} The created origin or an error. * * @example * const { error, data } = await createOrigin({ * applicationId: 1234, * data: { * name: 'My New Origin', * addresses: [{ address: 'example.com' }], * origin_type: 'single_origin' * }, * options: { debug: true } * }); * if (error) { * console.error('Failed to create origin:', error); * } else { * console.log('Origin created:', data); * } */ export declare const createOrigin: ({ applicationId, data, options, }: { applicationId: number; data: ApiCreateOriginPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionOrigin>>; /** * Creates a new rule for an Azion Edge Application. * * @async * @function * @param {Object} params - The parameters for creating a rule. * @param {number} params.applicationId - The ID of the application to create the rule for. * @param {'request' | 'response'} params.phase - The phase of the rule (request or response). * @param {ApiCreateRulePayload} params.data - The data for the new rule. * @param {AzionClientOptions} [params.options] - Optional client options. * @returns {Promise<AzionApplicationResponse<AzionRule>>} A promise that resolves with the created rule data or an error. * * @example * const { error, data } = await createRule({ * applicationId: 123, * phase: 'request', * data: { name: 'My New Rule', behaviors: [...] }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Rule created:', data); * } */ export declare const createRule: ({ applicationId, phase, data, options, }: { applicationId: number; phase: "request" | "response"; data: ApiCreateRulePayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionRule>>; declare interface Criterion { variable: string; operator: string; conditional: 'if' | 'and' | 'or'; input_value: string; } declare interface Criterion { variable: string; operator: string; conditional: 'if' | 'and' | 'or'; input_value: string; } /** * Deletes an Azion Edge Application. * * @async * @function * @param {Object} params - The parameters for deleting an application. * @param {number} params.applicationId - The ID of the application to delete. * @param {AzionClientOptions} [params.options] - Optional client options. * @returns {Promise<AzionApplicationResponse<void>>} A promise that resolves when the application is deleted or rejects with an error. * * @example * const result = await deleteApplication({ * applicationId: 123, * options: { debug: true } * }); * if (result.data !== undefined) { * console.log('Application deleted successfully'); * } else { * console.error('Error:', result.error); * } */ export declare const deleteApplication: ({ applicationId, options, }: { applicationId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Wrapper function to delete a specific cache setting from an application. * * @param {Object} params - Parameters for deleting a cache setting. * @param {number} params.applicationId - Application ID. * @param {number} params.cacheSettingId - Cache setting ID to delete. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<void>>} A response indicating success or an error. * * @example * const { error, data } = await deleteCacheSetting({ * applicationId: 1234, * cacheSettingId: 5678, * options: { debug: true } * }); * if (error) { * console.error('Failed to delete cache setting:', error); * } else { * console.log('Cache setting deleted successfully'); * } */ export declare const deleteCacheSetting: ({ applicationId, cacheSettingId, options, }: { applicationId: number; cacheSettingId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Function to delete a specific device group from an application. * * @param {Object} params - Parameters for deleting a device group. * @param {number} params.applicationId - Application ID. * @param {number} params.deviceGroupId - Device group ID to delete. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<void>>} A response indicating success or an error. * * @example * const { error, data } = await deleteDeviceGroup({ * applicationId: 1234, * deviceGroupId: 5678, * options: { debug: true } * }); * if (error) { * console.error('Failed to delete device group:', error); * } else { * console.log('Device group deleted successfully'); * } */ export declare const deleteDeviceGroup: ({ applicationId, deviceGroupId, options, }: { applicationId: number; deviceGroupId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Delete a function instance from a specific application. * * @param {Object} params - Parameters for deleting a function instance. * @param {number} params.applicationId - Application ID. * @param {number} params.functionInstanceId - ID of the function instance to delete. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<void>>} Confirmation of deletion or an error. * * @example * const { error, data } = await deleteFunctionInstance({ * applicationId: 1234, * functionInstanceId: 5678, * options: { debug: true } * }); * if (error) { * console.error('Failed to delete function instance:', error); * } else { * console.log('Function instance deleted successfully'); * } */ export declare const deleteFunctionInstance: ({ applicationId, functionInstanceId, options, }: { applicationId: number; functionInstanceId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Deletes a specific origin from an application. * * @param {Object} params - Parameters for deleting an origin. * @param {number} params.applicationId - Application ID. * @param {string} params.originKey - Key of the origin to delete. * @param {AzionClientOptions} [params.options] - Client options including debug mode. * @returns {Promise<AzionApplicationResponse<void>>} A response indicating success or an error. * * @example * const { error, data } = await deleteOrigin({ * applicationId: 1234, * originKey: 'origin-key', * options: { debug: true } * }); * if (error) { * console.error('Failed to delete origin:', error); * } else { * console.log('Origin deleted successfully'); * } */ export declare const deleteOrigin: ({ applicationId, originKey, options, }: { applicationId: number; originKey: string; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; /** * Deletes a rule from an Azion Edge Application. * * @async * @function * @param {Object} params - The parameters for deleting a rule. * @param {number} params.applicationId - The ID of the application containing the rule. * @param {'request' | 'response'} params.phase - The phase of the rule (request or response). * @param {number} params.ruleId - The ID of the rule to delete. * @param {AzionClientOptions} [params.options] - Optional client options. * @returns {Promise<AzionApplicationResponse<void>>} A promise that resolves when the rule is deleted or rejects with an error. * * @example * const { error, data } = await deleteRule({ * applicationId: 123, * phase: 'request', * ruleId: 456, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Rule deleted successfully'); * } */ export declare const deleteRule: ({ applicationId, phase, ruleId, options, }: { applicationId: number; phase: "request" | "response"; ruleId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; export declare enum DeliveryProtocol { HTTP = "http", HTTPS = "https", HTTP_HTTPS = "http,https" } /** * Interface for device group operations. * * @interface DeviceGroupOperations */ export declare interface DeviceGroupOperations { /** * Creates a new device group. * * @function * @name DeviceGroupOperations.createDeviceGroup * @param {Object} params - The parameters for creating a device group. * @param {ApiCreateDeviceGroupPayload} params.data - The data for the new device group. * @returns {Promise<AzionApplicationResponse<AzionDeviceGroup>>} A promise that resolves with the created device group data or an error. * * @example * const { error, data } = await deviceGroupOperations.createDeviceGroup({ * data: { * name: 'Mobile Devices', * user_agent: 'Mobile|Android|iPhone|iPad|iPod' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created device group:', data); * } */ createDeviceGroup: (params: { data: ApiCreateDeviceGroupPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionDeviceGroup>>; /** * Retrieves a specific device group. * * @function * @name DeviceGroupOperations.getDeviceGroup * @param {Object} params - The parameters for retrieving a device group. * @param {number} params.deviceGroupId - The ID of the device group to retrieve. * @returns {Promise<AzionApplicationResponse<AzionDeviceGroup>>} A promise that resolves with the device group data or an error. * * @example * const { error, data } = await deviceGroupOperations.getDeviceGroup({ * deviceGroupId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved device group:', data); * } */ getDeviceGroup: (params: { deviceGroupId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionDeviceGroup>>; /** * Retrieves a list of device groups. * * @function * @name DeviceGroupOperations.getDeviceGroups * @param {Object} params - The parameters for retrieving device groups. * @param {ApiListDeviceGroupsParams} [params.params] - Optional parameters for filtering and pagination. * @returns {Promise<AzionApplicationCollectionResponse<AzionDeviceGroup>>} A promise that resolves with a collection of device groups or an error. * * @example * const { error, data } = await deviceGroupOperations.getDeviceGroups({ * params: { page: 1, page_size: 20 }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved device groups:', data.results); * } */ getDeviceGroups: (params: { params?: ApiListDeviceGroupsParams; options?: AzionClientOptions; }) => Promise<AzionApplicationCollectionResponse<AzionDeviceGroup>>; /** * Updates an existing device group. * * @function * @name DeviceGroupOperations.updateDeviceGroup * @param {Object} params - The parameters for updating a device group. * @param {number} params.deviceGroupId - The ID of the device group to update. * @param {ApiUpdateDeviceGroupPayload} params.data - The updated data for the device group. * @returns {Promise<AzionApplicationResponse<AzionDeviceGroup>>} A promise that resolves with the updated device group data or an error. * * @example * const { error, data } = await deviceGroupOperations.updateDeviceGroup({ * deviceGroupId: 123, * data: { * name: 'Updated Mobile Devices', * user_agent: 'Mobile|Android|iPhone|iPad|iPod|BlackBerry' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Updated device group:', data); * } */ updateDeviceGroup: (params: { deviceGroupId: number; data: ApiUpdateDeviceGroupPayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionDeviceGroup>>; /** * Deletes a device group. * * @function * @name DeviceGroupOperations.deleteDeviceGroup * @param {Object} params - The parameters for deleting a device group. * @param {number} params.deviceGroupId - The ID of the device group to delete. * @returns {Promise<AzionApplicationResponse<void>>} A promise that resolves when the device group is deleted or rejects with an error. * * @example * const { error, data } = await deviceGroupOperations.deleteDeviceGroup({ * deviceGroupId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Device group deleted successfully'); * } */ deleteDeviceGroup: (params: { deviceGroupId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<void>>; } /** * Interface for function operations. * * @interface FunctionOperations */ export declare interface FunctionOperations { /** * Creates a new function instance. * * @function * @name FunctionOperations.createFunctionInstance * @param {Object} params - The parameters for creating a function instance. * @param {ApiCreateFunctionInstancePayload} params.data - The data for the new function instance. * @returns {Promise<AzionApplicationResponse<AzionFunctionInstance>>} A promise that resolves with the created function instance data or an error. * * @example * const { error, data } = await functionOperations.createFunctionInstance({ * data: { * name: 'My Function', * code: 'async function handleRequest(request) { return new Response("Hello, World!"); }', * language: 'javascript' * }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Created function instance:', data); * } */ createFunctionInstance: (params: { data: ApiCreateFunctionInstancePayload; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionFunctionInstance>>; /** * Retrieves a specific function instance. * * @function * @name FunctionOperations.getFunctionInstance * @param {Object} params - The parameters for retrieving a function instance. * @param {number} params.functionInstanceId - The ID of the function instance to retrieve. * @returns {Promise<AzionApplicationResponse<AzionFunctionInstance>>} A promise that resolves with the function instance data or an error. * * @example * const { error, data } = await functionOperations.getFunctionInstance({ * functionInstanceId: 123, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved function instance:', data); * } */ getFunctionInstance: (params: { functionInstanceId: number; options?: AzionClientOptions; }) => Promise<AzionApplicationResponse<AzionFunctionInstance>>; /** * Retrieves a list of function instances. * * @function * @name FunctionOperations.getFunctionInstances * @param {Object} params - The parameters for retrieving function instances. * @param {ApiListFunctionInstancesParams} [params.params] - Optional parameters for filtering and pagination. * @returns {Promise<AzionApplicationCollectionResponse<AzionFunctionInstance>>} A promise that resolves with a collection of function instances or an error. * * @example * const { error, data } = await functionOperations.getFunctionInstances({ * params: { page: 1, page_size: 20 }, * options: { debug: true } * }); * if (error) { * console.error('Error:', error); * } else { * console.log('Retrieved function instances:', data.results); * } */ getFunctionInstances: (params: { params?: ApiListFunctionInstancesParams; options?: AzionClientOptions; }) => Promise<AzionApplicationCollecti