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.
Create a device group
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.
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:
The signature of createDeviceGroup:
Parameters
| 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. |
Get device groups
getDeviceGroups lists the device groups of an application, one page at a time.
Returns an AzionApplicationCollectionResponse whose data.results holds AzionDeviceGroup objects.
Output:
The signature of getDeviceGroups:
Parameters
| 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. |
Get a device group
getDeviceGroup returns one device group of an application by its ID.
Returns data as an AzionDeviceGroup.
Output:
The signature of getDeviceGroup:
Parameters
| 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. |
Update a device group
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.
Returns data as the updated AzionDeviceGroup.
Output:
The signature of updateDeviceGroup:
Parameters
| 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. |
Delete a device group
deleteDeviceGroup deletes a device group of an application by its ID.
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:
The signature of deleteDeviceGroup:
Parameters
| 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. |