Origins
The azion/applications functions that create, list, read, update, and delete the origins of an application.
An origin is the server an application retrieves content from. These azion/applications functions create, list, read, update, and delete the origins of an application. The API identifies an origin by its origin_key, a UUID, which every function except createOrigin and getOrigins takes as originKey.
createOrigin
Creates an origin in an application. An origin is the server the application retrieves content from.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
data | ApiCreateOriginPayload | Yes | The settings of the origin. The sample sets name, origin_type, addresses, and host_header. |
options | AzionClientOptions | No | Request options. |
Returns data as the created AzionOrigin. The API identifies an origin by its origin_key, a UUID, which the other origin functions take as originKey.
This sample is JavaScript, because ApiCreateOriginPayload requires every origin field, including origin_key and the HMAC fields, and types origin_type as an enum:
Output:
getOrigins
Lists the origins of an application, one page at a time.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
params | ApiListOriginsParams | No | Pagination: page and page_size. |
options | AzionClientOptions | No | Request options. |
Returns an AzionApplicationCollectionResponse whose data.results holds AzionOrigin objects.
Output:
getOrigin
Returns one origin of an application by its origin key.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
originKey | string | Yes | The origin_key of the origin, a UUID. |
options | AzionClientOptions | No | Request options. |
Returns data as an AzionOrigin. A key that matches no origin returns error with the message HTTP error! Status: 404 - NOT FOUND and the operation get origin.
Output:
updateOrigin
Sends the origin fields you pass in a PATCH request.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
originKey | string | Yes | The origin_key of the origin to update. |
data | ApiUpdateOriginRequest | Yes | The fields to change. |
options | AzionClientOptions | No | Request options. |
Returns data as the updated AzionOrigin.
This sample is JavaScript, because ApiUpdateOriginRequest requires an id, which the request does not need:
Output:
deleteOrigin
Deletes an origin of an application by its origin key.
| Parameter | Type | Required | Description |
|---|---|---|---|
applicationId | number | Yes | The ID of the application. |
originKey | string | Yes | The origin_key of the origin 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 origin back with getOrigin. A 404 error confirms the delete.
Output: