Assets API
NOTE: Requests to the assets API require you to authenticate with a Sensu access token or API key.
The code examples in this document use the environment variable $SENSU_API_KEY
to represent a valid API key in API requests.
Get all assets
The /assets
API endpoint provides HTTP GET access to dynamic runtime asset data.
Example
The following example demonstrates a request to the /assets
API endpoint, resulting in a JSON array that contains dynamic runtime asset definitions.
curl -X GET \
http://127.0.0.1:8080/api/core/v2/namespaces/default/assets \
-H "Authorization: Key $SENSU_API_KEY"
HTTP/1.1 200 OK
[
{
"url": "https://github.com/sensu/sensu-influxdb-handler/releases/download/3.1.2/sensu-influxdb-handler_3.1.2_linux_amd64.tar.gz",
"sha512": "612c6ff9928841090c4d23bf20aaf7558e4eed8977a848cf9e2899bb13a13e7540bac2b63e324f39d9b1257bb479676bc155b24e21bf93c722b812b0f15cb3bd",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"builds": null,
"metadata": {
"name": "sensu-influxdb-handler",
"namespace": "default",
"created_by": "admin"
},
"headers": {
"Authorization": "Bearer $TOKEN",
"X-Forwarded-For": "client1, proxy1, proxy2"
}
},
{
"url": "https://github.com/sensu/sensu-slack-handler/releases/download/1.0.3/sensu-slack-handler_1.0.3_linux_amd64.tar.gz",
"sha512": "68720865127fbc7c2fe16ca4d7bbf2a187a2df703f4b4acae1c93e8a66556e9079e1270521999b5871473e6c851f51b34097c54fdb8d18eedb7064df9019adc8",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"builds": null,
"metadata": {
"name": "sensu-slack-handler",
"namespace": "default",
"created_by": "admin"
},
"headers": {
"Authorization": "Bearer $TOKEN",
"X-Forwarded-For": "client1, proxy1, proxy2"
}
}
]
API Specification
/assets (GET) | |
---|---|
description | Returns the list of dynamic runtime assets. |
example url | http://hostname:8080/api/core/v2/namespaces/default/assets |
pagination | This endpoint supports pagination using the limit and continue query parameters. |
response filtering | This endpoint supports API response filtering. |
response type | Array |
response codes |
|
output |
|
Create a new dynamic runtime asset
The /assets
API endpoint provides HTTP POST access to dynamic runtime asset data.
Example
In the following example, an HTTP POST request is submitted to the /assets
API endpoint to create a role named sensu-slack-handler
.
The request returns a successful HTTP 201 Created
response.
curl -X POST \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"url": "https://github.com/sensu/sensu-slack-handler/releases/download/1.0.3/sensu-slack-handler_1.0.3_linux_amd64.tar.gz",
"sha512": "68720865127fbc7c2fe16ca4d7bbf2a187a2df703f4b4acae1c93e8a66556e9079e1270521999b5871473e6c851f51b34097c54fdb8d18eedb7064df9019adc8",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"headers": {
"Authorization": "Bearer $TOKEN",
"X-Forwarded-For": "client1, proxy1, proxy2"
},
"metadata": {
"name": "sensu-slack-handler",
"namespace": "default"
}
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/assets
HTTP/1.1 201 Created
API Specification
/assets (POST) | |
---|---|
description | Creates a Sensu dynamic runtime asset. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/assets |
payload |
|
response codes |
|
Get a specific dynamic runtime asset
The /assets/:asset
API endpoint provides HTTP GET access to dynamic runtime asset data for specific :asset
definitions, by asset name
.
Example
In the following example, querying the /assets/:asset
API endpoint returns a JSON map that contains the requested :asset
definition (in this example, for the :asset
named check_script
).
curl -X GET \
http://127.0.0.1:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler \
-H "Authorization: Key $SENSU_API_KEY"
HTTP/1.1 200 OK
[
{
"url": "https://github.com/sensu/sensu-slack-handler/releases/download/1.0.3/sensu-slack-handler_1.0.3_linux_amd64.tar.gz",
"sha512": "68720865127fbc7c2fe16ca4d7bbf2a187a2df703f4b4acae1c93e8a66556e9079e1270521999b5871473e6c851f51b34097c54fdb8d18eedb7064df9019adc8",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"builds": null,
"metadata": {
"name": "sensu-slack-handler",
"namespace": "default",
"created_by": "admin"
},
"headers": {
"Authorization": "Bearer $TOKEN",
"X-Forwarded-For": "client1, proxy1, proxy2"
}
}
]
API Specification
/assets/:asset (GET) | |
---|---|
description | Returns the specified dynamic runtime asset. |
example url | http://hostname:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler |
response type | Map |
response codes |
|
output |
|
Create or update a dynamic runtime asset
The /assets/:asset
API endpoint provides HTTP PUT access to create or update specific :asset
definitions, by dynamic runtime asset name.
Example
In the following example, an HTTP PUT request is submitted to the /assets/:asset
API endpoint to create the dynamic runtime asset sensu-slack-handler
.
The request returns a successful HTTP 201 Created
response.
curl -X PUT \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"url": "https://github.com/sensu/sensu-slack-handler/releases/download/1.0.3/sensu-slack-handler_1.0.3_linux_amd64.tar.gz",
"sha512": "68720865127fbc7c2fe16ca4d7bbf2a187a2df703f4b4acae1c93e8a66556e9079e1270521999b5871473e6c851f51b34097c54fdb8d18eedb7064df9019adc8",
"filters": [
"entity.system.os == 'linux'",
"entity.system.arch == 'amd64'"
],
"headers": {
"Authorization": "Bearer $TOKEN",
"X-Forwarded-For": "client1, proxy1, proxy2"
},
"metadata": {
"name": "sensu-slack-handler",
"namespace": "default"
}
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/rolebindings/sensu-slack-handler
HTTP/1.1 201 Created
API Specification
/assets/:asset (PUT) | |
---|---|
description | Creates or updates the specified Sensu dynamic runtime asset. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler |
payload |
|
response codes |
|
Delete a dynamic runtime asset
The /assets/:asset
API endpoint provides HTTP DELETE access so you can delete a dynamic runtime assets.
NOTE: Deleting a dynamic runtime asset does not remove the downloaded files from the asset cache or remove any references to the deleted asset in other resources.
Example
curl -X DELETE \
http://127.0.0.1:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler \
-H "Authorization: Key $SENSU_API_KEY"
HTTP/1.1 204 No Content
API Specification
/assets/:asset (DELETE) | |
---|---|
description | Deletes the specified Sensu dynamic runtime asset. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler |
response codes |
|