Azion Application module
Manage Applications using the Application module.
The Azion Application module provides a comprehensive interface to interact with the Azion Applications API. This module allows you to manage applications and their components including cache settings, device groups, function instances, origins, and Rules Engine configurations.
Go to Azion Libraries OverviewYou can interact with the API using a client or calling the methods directly from the library. When making direct calls, you can use the environment variables to configure the client without passing the token and debug parameters directly.
This is an example of how a .env file with your environment variables may look like:
| Variable | Description |
|---|---|
AZION_TOKEN | Your Azion API token. |
AZION_DEBUG | Enable debug mode (true/false). |
Usage
createClient
TypeScript example:
Usage with Applications
createApplication
Creates a new application.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | { name: string; delivery_protocol: string; application_acceleration: boolean; } | The data for the new application. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionApplication>> | The created application object or error if creation failed. |
getApplications
Lists all applications.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | { page?: number; page_size?: number; order?: 'id'} | 'name'; sort?: 'asc' | 'desc'; } | Optional parameters for filtering and pagination. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionApplication>> | A collection of applications or error if retrieval failed. |
getApplication
Retrieves a specific application.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
applicationId | Number | The ID of the application to retrieve. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionApplication>> | The retrieved application object or error if not found. |
updateApplication
Updates an existing application.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
applicationId | Number | The ID of the application to update. |
data | { name?: string; delivery_protocol?: string; application_acceleration?: boolean; } | The updated data for the application. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionApplication>> | The updated application object or error if the update failed. |
deleteApplication
Deletes an application.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
applicationId | Number | The ID of the application to delete. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedApplication>> | Confirmation of deletion or error if the operation failed. |
Cache Settings
createCacheSetting
Creates a new cache setting.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | { name: string; browser_cache_settings: string; cdn_cache_settings: string; } | The data for the new cache setting. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionCacheSetting>> | The created cache setting object or error if creation failed. |
getCacheSetting
Retrieve a specific cache setting.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
cacheSettingId | Number | The ID of the cache setting to retrieve. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionCacheSetting>> | The retrieved cache setting object or error if not found. |
getCacheSettings
Lists all cache settings.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | { page?: number; page_size?: number; order?: 'id' | 'name'; sort?: 'asc' | 'desc'; } | Optional parameters for filtering and pagination. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionCacheSetting>> | A collection of cache settings or error if retrieval failed. |
updateCacheSetting
Updates an existing cache setting.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
cacheSettingId | Number | The ID of the cache setting to update. |
data | { name?: string; browser_cache_settings?: string; cdn_cache_settings?: string; } | The updated data for the cache setting. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionCacheSetting>> | The updated cache setting object or error if the update failed. |
deleteCacheSetting
Deletes a cache setting.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
cacheSettingId | Number | The ID of the cache setting to delete. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedCacheSetting>> | Confirmation of deletion or error if the operation failed. |
Device Groups
createDeviceGroup
Creates a new device group.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | { name: string; user_agent: string; } | The data for the new device group. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeviceGroup>> | The created device group object or error if creation failed. |
getDeviceGroup
Retrieves a specific device group.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
deviceGroupId | Number | The ID of the device group to retrieve. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeviceGroup>> | The retrieved device group object or error if not found. |
getDeviceGroups
Lists all device groups.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | { page?: number; page_size?: number; order?: 'id' | 'name'; sort?: 'asc' | 'desc'; } | Optional parameters for filtering and pagination. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionDeviceGroup>> | The retrieved device group object or error if not found. |
updateDeviceGroup
Updates an existing device group.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
deviceGroupId | Number | The ID of the device group to update. |
data | { name?: string; user_agent?: string; } | The updated data for the device group. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeviceGroup>> | The updated device group object or error if the update failed. |
deleteDeviceGroup
Deletes a device group.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
deviceGroupId | Number | The ID of the device group to delete. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedDeviceGroup>> | Confirmation of deletion or error if the operation failed. |
Function Instances
createFunctionInstance
Creates a new function instance.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | ApiCreateFunctionInstancePayload | The data for the new function instance. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionFunctionInstance>> | The created function instance object or error if creation failed. |
getFunctionInstance
Retrieves a specific function instance.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
functionInstanceId | Number | The ID of the function instance to retrieve. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionFunctionInstance>> | The retrieved function instance object or error if not found. |
getFunctionInstances
Lists all function instances.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | ApiListFunctionInstancesParams | Optional parameters for filtering and pagination. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionFunctionInstance>> | A collection of function instances or error if retrieval failed. |
updateFunctionInstance
Updates an existing function instance.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
functionInstanceId | Number | The ID of the function instance to update. |
data | ApiUpdateFunctionInstancePayload | The updated data for the function instance. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionFunctionInstance>> | The updated function instance object or error if the update failed. |
deleteFunctionInstance
Deletes a function instance.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
functionInstanceId | Number | The ID of the function instance to delete. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedFunctionInstance>> | Confirmation of deletion or error if the operation failed. |
Origins
createOrigin
Creates a new origin.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | { name: string; url: string; } | The data for the new origin. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionOrigin>> | The created origin object or error if creation failed. |
getOrigin
Retrieves a specific origin.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
originId | Number | The ID of the origin to retrieve. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionOrigin>> | The retrieved origin object or error if not found. |
getOrigins
Lists all origins.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | { page?: number; page_size?: number; order?: 'id' | 'name'; sort?: 'asc' | 'desc'; } | Optional parameters for filtering and pagination. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionOrigin>> | A collection of origins or error if retrieval failed. |
updateOrigin
Updates an existing origin.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
originId | Number | The ID of the origin to update. |
data | { name?: string; url?: string; } | The updated data for the origin. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionOrigin>> | The updated origin object or error if the update failed. |
deleteOrigin
Deletes an origin.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
originId | Number | The ID of the origin to delete. |
options? | { debug?: boolean } | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedOrigin>> | Confirmation of deletion or error if the operation failed. |
Rules Engine
createRule
Creates a new rule.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
data | {ApiCreateRulePayload | The data for the new rule. |
options? | AzionClientOptions | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionRule>> | The created rule object or error if creation failed. |
getRule
Retrieves a specific rule.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
ruleId | Number | The ID of the rule to retrieve. |
options? | AzionClientOptions | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionRule>> | The retrieved rule object or error if not found. |
getRules
Lists all rules.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
params? | ApiListRulesParams | Optional parameters for filtering and pagination. |
options? | AzionClientOptions | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationCollectionResponse<AzionRule>> | A collection of rules or error if retrieval failed. |
updateRule
Updates an existing rule.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
ruleId | Number | The ID of the rule to update. |
data | ApiUpdateRulePayload | The updated data for the rule. |
options? | AzionClientOptions | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionRule>> | The updated rule object or error if the update failed. |
deleteRule
Deletes a rule.
TypeScript example:
Parameters:
| Parameter | Type | Description |
|---|---|---|
ruleId | Number | The ID of the rule to delete. |
options? | AzionClientOptions | Optional parameters including debug mode. |
Returns:
| Return Type | Description |
|---|---|
Promise<AzionApplicationResponse<AzionDeletedRule>> | Confirmation of deletion or error if the operation failed. |