Device groups
The azion/applications functions that create, list, read, update, and delete the device groups of an application.
A device group matches devices by a regular expression that the platform compares with the User-Agent request header. These azion/applications functions create, list, read, update, and delete the device groups of an application.
createDeviceGroup
Creates a device group in an application. A device group matches devices by a regular expression that the platform compares with the User-Agent request header.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId |
number |
Yes | The ID of the application. |
data |
{ name: string; user_agent: string } |
Yes | name names the group, and user_agent holds the regular expression, such as Mobile|Android|iPhone. |
options |
AzionClientOptions |
No | Request options. |
Returns data as the created AzionDeviceGroup. The API refuses a name that contains a space or a hyphen. The function then returns error with the message HTTP error! Status: 400 - BAD REQUEST.
Output:
getDeviceGroups
Lists the device groups of an application, one page at a time.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId |
number |
Yes | The ID of the application. |
params |
ApiListDeviceGroupsParams |
No | Pagination: page and page_size. |
options |
AzionClientOptions |
No | Request options. |
Returns an AzionApplicationCollectionResponse whose data.results holds AzionDeviceGroup objects.
Output:
getDeviceGroup
Returns one device group of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId |
number |
Yes | The ID of the application. |
deviceGroupId |
number |
Yes | The ID of the device group. |
options |
AzionClientOptions |
No | Request options. |
Returns data as an AzionDeviceGroup.
Output:
updateDeviceGroup
Sends the device group fields you pass in a PATCH request. The new name follows the same rule as on create: no spaces and no hyphens.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId |
number |
Yes | The ID of the application. |
deviceGroupId |
number |
Yes | The ID of the device group to update. |
data |
{ name?: string; user_agent?: string } |
Yes | The fields to change. |
options |
AzionClientOptions |
No | Request options. |
Returns data as the updated AzionDeviceGroup.
Output:
deleteDeviceGroup
Deletes a device group of an application by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId |
number |
Yes | The ID of the application. |
deviceGroupId |
number |
Yes | The ID of the device group to delete. |
options |
AzionClientOptions |
No | Request options. |
A successful delete returns error with the message Expected JSON response, but got: , so the sample reads the device group back with getDeviceGroup. A 404 error confirms the delete.
Output: