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 -s http://127.0.0.1:8080/api/core/v2/namespaces/default/assets -H "Authorization: Bearer TOKEN"
[
  {
    "url": "http://example.com/asset1.tar.gz",
    "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
    "metadata": {
      "name": "check_script1",
      "namespace": "default",
      "labels": null,
      "annotations": null
    }
  }
]

API Specification

/assets (GET)
description Returns the list of assets.
example url http://hostname:8080/api/core/v2/namespaces/default/assets
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "url": "http://example.com/asset1.tar.gz",
    "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
    "metadata": {
      "name": "check_script1",
      "namespace": "default",
      "labels": null,
      "annotations": null
    }
  },
  {
    "url": "http://example.com/asset2.tar.gz",
    "sha512": "37c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a84f926bf4328fbad2b9cac873d11450576b2c58ad9ab40c9e2edc31b288d066b195b21b7f771914f4b87",
    "metadata": {
      "name": "check_script2",
      "namespace": "default",
      "labels": null,
      "annotations": null
    }
  }
]

/assets (POST)

/assets (POST)
description Create a Sensu asset.
example URL http://hostname:8080/api/core/v2/namespaces/default/assets
payload
{
  "url": "http://example.com/asset1.tar.gz",
  "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
  "metadata": {
    "name": "check_script1",
    "namespace": "default",
    "labels": null,
    "annotations": null
  }
}
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 -s http://127.0.0.1:8080/api/core/v2/namespaces/default/assets/check_script -H "Authorization: Bearer TOKEN"
{
  "url": "http://example.com/asset.tar.gz",
  "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
  "filters": [
    "system.os == 'linux'",
    "system.arch == 'amd64'"
  ],
  "metadata": {
    "name": "check_script",
    "namespace": "default",
    "labels": null,
    "annotations": null
  }
}

API Specification

/assets/:asset (GET)
description Returns an asset.
example url http://hostname:8080/api/core/v2/namespaces/default/assets/check_script
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "url": "http://example.com/asset.tar.gz",
  "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
  "filters": [
    "system.os == 'linux'",
    "system.arch == 'amd64'"
  ],
  "metadata": {
    "name": "check_script",
    "namespace": "default",
    "labels": null,
    "annotations": null
  }
}

/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/check_script
payload
{
  "url": "http://example.com/asset1.tar.gz",
  "sha512": "4f926bf4328fbad2b9cac873d117f771914f4b837c9c85584c38ccf55a3ef3c2e8d154812246e5dda4a87450576b2c58ad9ab40c9e2edc31b288d066b195b21b",
  "metadata": {
    "name": "check_script1",
    "namespace": "default",
    "labels": null,
    "annotations": null
  }
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)