Assets API

The /assets API endpoint

/assets (GET)

The /assets API endpoint provides HTTP GET access to asset data.

EXAMPLE

The following example demonstrates a request to the /assets API, resulting in a JSON Array containing asset definitions.

curl http://127.0.0.1:8080/api/core/v2/namespaces/default/assets -H "Authorization: Bearer $SENSU_TOKEN"

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"
    },
    "headers": null,
    "metadata": {
      "name": "sensu-slack-handler",
      "namespace": "default"
    }
  }
]

API Specification

/assets (GET)
description Returns the list of assets.
example url http://hostname:8080/api/core/v2/namespaces/default/assets
pagination This endpoint supports pagination using the limit and continue query parameters. See the API overview for details.
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "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"
    },
    "headers": null,
    "metadata": {
      "name": "sensu-influxdb-handler",
      "namespace": "default"
    }
  },
  {
    "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": null,
    "metadata": {
      "name": "sensu-slack-handler",
      "namespace": "default"
    }
  }
]

/assets (POST)

/assets (POST)
description Create a Sensu asset.
example URL http://hostname:8080/api/core/v2/namespaces/default/assets
payload
{
  "url": "https://asset-url.tar.gz",
  "sha512": "xxxxxxxxxxxxxxxxxxxxx",
  "filters": {
    "entity.system.os": "linux",
    "entity.system.arch": "amd64"
  },
  "headers": {
    "Authorization": "Bearer $TOKEN",
    "X-Forwarded-For": "client1, proxy1, proxy2"
  },
  "metadata": {
    "name": "my-secure-asset",
    "namespace": "default"
  }
}
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /assets/:asset API endpoint

/assets/:asset (GET)

The /assets/:asset API endpoint provides HTTP GET access to asset data for specific :asset definitions, by asset name.

EXAMPLE

In the following example, querying the /assets/:asset API returns a JSON Map containing the requested :asset definition (in this example: for the :asset named check_script).

curl http://127.0.0.1:8080/api/core/v2/namespaces/default/assets/sensu-slack-handler -H "Authorization: Bearer $SENSU_TOKEN"

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"
  },
  "headers": null,
  "metadata": {
    "name": "sensu-slack-handler",
    "namespace": "default"
  }
}

API Specification

/assets/:asset (GET)
description Returns an asset.
example url http://hostname:8080/api/core/v2/namespaces/default/assets/my-secure-asset
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "url": "https://asset-url.tar.gz",
  "sha512": "xxxxxxxxxxxxxxxxxxxxx",
  "filters": {
    "entity.system.os": "linux",
    "entity.system.arch": "amd64"
  },
  "headers": {
    "Authorization": "Bearer $TOKEN",
    "X-Forwarded-For": "client1, proxy1, proxy2"
  },
  "metadata": {
    "name": "my-secure-asset",
    "namespace": "default"
  }
}

/assets/:asset (PUT)

API Specification

/assets/:asset (PUT)
description Create or update a Sensu asset.
example URL http://hostname:8080/api/core/v2/namespaces/default/assets/my-secure-asset
payload
{
  "url": "https://asset-url.tar.gz",
  "sha512": "xxxxxxxxxxxxxxxxxxxxx",
  "filters": {
    "entity.system.os": "linux",
    "entity.system.arch": "amd64"
  },
  "headers": {
    "Authorization": "Bearer $TOKEN",
    "X-Forwarded-For": "client1, proxy1, proxy2"
  },
  "metadata": {
    "name": "my-secure-asset",
    "namespace": "default"
  }
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/assets/:asset (DELETE)

The Sensu Go HTTP API provides the ability to delete an asset. Note that this does not remove the downloaded files from the asset cache, nor does it remove any references in other resources to the deleted asset.

API Specification

/assets/:asset (DELETE)
description Deletes a Sensu asset.
example URL http://hostname:8080/api/core/v2/namespaces/default/assets/my-secure-asset
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
curl -X DELETE -H "Authorization: Bearer $SENSU_TOKEN"  http://localhost:8080/api/core/v2/namespaces/default/assets/my_asset 


 curl -I -X DELETE -H "Authorization: Bearer $SENSU_TOKEN"  http://
demo.sensuplusgremlin.rocks:8080/api/core/v2/namespaces/default/assets/my_asset
4
HTTP/1.1 204 No Content
Content-Type: application/json
Sensu-Entity-Count: 6
Sensu-Entity-Limit: 1000
Date: Mon, 26 Aug 2019 18:51:28 GMT