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.
Create an origin
createOrigin creates an origin in an application. An origin is the server the application retrieves content from.
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:
The signature of createOrigin:
Parameters
| 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. |
Get origins
getOrigins lists the origins of an application, one page at a time.
Returns an AzionApplicationCollectionResponse whose data.results holds AzionOrigin objects.
Output:
The signature of getOrigins:
Parameters
| 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. |
Get an origin
getOrigin returns one origin of an application by its origin key.
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:
The signature of getOrigin:
Parameters
| 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. |
Update an origin
updateOrigin sends the origin fields you pass in a PATCH request.
Returns data as the updated AzionOrigin.
This sample is JavaScript, because ApiUpdateOriginRequest requires an id, which the request does not need:
Output:
The signature of updateOrigin:
Parameters
| 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. |
Delete an origin
deleteOrigin deletes an origin of an application by its origin key.
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:
The signature of deleteOrigin:
Parameters
| 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. |