Getting RESTful with your assets
Collins API design principles and conventions
The initial design goal was that the entire API should be usable from the command line, even with netcat. To that end, basic auth is used for HTTP authentication, and curl is an adequate client interface as long as you're inclined. There are no plans to ever use OAuth or a similar authentication mechanism.
The collins API has two nice features. First, it is as RESTful as it could be without being an ass. Status codes are used to indicate what happened uniformly, appropriate HTTP methods (PUT, GET, etc) for each endpoint, plural/singular endpoints as you would expect, etc. Second, you can request the output for any API endpoint as plain text, JSON, or bash (sh compatible).
Note that some status codes listed below won't be listed in the documentation. Status codes 400, 401, 405 and 500 will never be documented. You will always get an HTTP 400 if there is a bad parameter, you will always get an HTTP 401 if you fail to authenticate, you will always get an HTTP 405 if you use the wrong verb, and you will always get an HTTP 500 if there is an internal server error. I am stating this once to avoid restating it dozens of times in the internal docs.
Code | Use |
200 | Normal operation, expect this |
---|---|
201 | Resource created, all PUT calls should return this on success |
202 | Resource accepted for deletion |
400 | Bad input found, modify your request and try again |
401 | You failed to authenticate successfully, retry using different credentials |
403 | You do not have appropriate privileges to perform the specified operation |
404 | Resource not found - this is a normalish response code |
405 | Unsupported HTTP method - modify request before retry |
409 | Performing the operation would have created a conflict (duplicate IP, duplicate name, etc) |
429 | You are being rate limited, slow down |
500 | An internal error occurred, you should probably try again |
501 | You are trying to perform an operation that the system is not configured for |
504 | If multicollins or the provision plugins are configured and a timeout occurs interacting with a remote service |
Use the Accept
header to specify the output format. JSON is the default output format and in general the best to use. However,
every API endpoint has support for plain text, bash, and JSON output. The recognized accept headers for the API are:
text/plain
application/json
text/x-shellscript
The text/x-shellscript
endpoint will modify keys to make them valid POSIX variables. Specifically, if a key starts with a special character or digit, an underscore will be prepended to the key. Also, any special characters in a key will be replaced with underscores.
Collins supports API versioning via the accept header. This allows developers to make breaking changes to the API and continue to have old clients work. This is implemented but I'll leave this to Dan to document.
Paginated result sets always provide results in a standard format. Paginated results also always included a header with the same pagination information that can be found in the result set. The headers with pagination information are:
X-Pagination-PreviousPage
X-Pagination-CurrentPage
X-Pagination-NextPage
X-Pagination-TotalResults
The JSON output format will return an object with a Pagination
key and an object value. The pagination object has the following
keys: PreviousPage
, CurrentPage
, NextPage
, Total Results
.
If an API endpoint can be paginated it will be annotated with a Paginated marker. Paginated API endpoints accept the following parameters:
Name | Type | Description |
page | Option[Integer] | Defaults to zero, indexed from zero. The page of results that you want. |
---|---|---|
size | Option[Integer] | Number of results to return. Generally defaults to 10. |
sort | Option[String] | Valid values are "ASC" or "DESC". Generally defaults to "DESC". |
If a URI contains a colon (:) followed by text, this is a required part of the URI. This is
typically used for specifying the resource you are interacting with. For instance if a URI is documented
as /api/foo/:bar
then :bar
is a variable that is specified as part of the URI.
CRUD operations for your assets
The Asset API is the primary interface for manipulating Collins assets. The operations that can be performed is somewhat dependent on the status of an asset (for instance, you can not upload new LSHW data to an asset that is Allocated). For more information on asset states and status see the Status & State document.
Description | Create a new asset | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | PUT /api/asset/:tag | |||||||||||||||
Permission | controllers.AssetApi.createAsset | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:created", "data": { "ASSET": { "ID": 2, "TAG": "tumblrtag30", "STATE": null, "STATUS": "Incomplete", "TYPE": "Server Node", "CREATED": "2012-09-16T18:30:55", "UPDATED": null, "DELETED": null }, "IPMI": { "ASSET_ID": 2, "ASSET_TAG": "tumblrtag30", "IPMI_USERNAME": "root", "IPMI_PASSWORD": "WqbXjuqWd5MZ01fD", "IPMI_GATEWAY": "172.16.32.1", "IPMI_ADDRESS": "172.16.32.20", "IPMI_NETMASK": "255.255.240.0", "ID": 2 } } }
ASSET_ID=3; ASSET_CREATED="2012-09-16T18:42:21"; ASSET_TAG="tumblrtag31"; ASSET_STATUS="Incomplete"; ASSET_DELETED=; ASSET_UPDATED=; ASSET_STATE=; ASSET_TYPE="Server Node"; IPMI_IPMI_USERNAME="root"; IPMI_ID=3; IPMI_IPMI_ADDRESS="172.16.32.21"; IPMI_IPMI_NETMASK="255.255.240.0"; IPMI_ASSET_ID=3; IPMI_ASSET_TAG="tumblrtag31"; IPMI_IPMI_GATEWAY="172.16.32.1"; IPMI_IPMI_PASSWORD="zqkWfV9baxlrJa5Y";
ASSET ID 4 CREATED 2012-09-16T18:43:35 TAG tumblrtag32 STATUS Incomplete DELETED null UPDATED null STATE null TYPE Server Node IPMI IPMI_USERNAME root ID 4 IPMI_ADDRESS 172.16.32.22 IPMI_NETMASK 255.255.240.0 ASSET_ID 4 ASSET_TAG tumblrtag32 IPMI_GATEWAY 172.16.32.1 IPMI_PASSWORD BCGHWinJlme9g9x0
Description | Update an asset | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag | ||||||||||||||||||||||||
Permission | controllers.AssetApi.updateAsset | ||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||
Response Codes |
|
curl --basic -u collins:collins \ --data-urlencode "lldp@./test/resources/lldpctl-two-nic.xml" \ --data-urlencode "lshw@./test/resources/lshw-basic.xml" \ --data-urlencode 'CHASSIS_TAG=chassistag123' \ --data-urlencode 'attribute=NODECLASS;web' \ http://localhost:9000/api/asset/tumblrtag30
{ "status": "success:ok", "data": { "SUCCESS": true } }
SUCCESS=true;
SUCCESS true
Description | Update the status or state of an asset | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag/status | |||||||||||||||
Permission | controllers.AssetApi.updateAssetStatus | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Get an asset by tag | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag | ||||||
Permission | controllers.AssetApi.getAsset | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "ASSET": { "ID": 2, "TAG": "tumblrtag30", "STATE": { "ID": 1, "STATUS": null, "NAME": "NEW", "LABEL": "New", "DESCRIPTION": "A service in this state is inactive. It does minimal work and consumes minimal resources." }, "STATUS": "New", "TYPE": "Server Node", "CREATED": "2012-09-16T18:30:55", "UPDATED": "2012-09-16T18:46:41", "DELETED": null }, "HARDWARE": { "CPU": [ { "CORES": 6, "THREADS": 6, "SPEED_GHZ": 2.3, "DESCRIPTION": "AMD Opteron(tm) Processor 4174 HE Hynix Semiconductor (Hyundai Electronics)", "PRODUCT": "", "VENDOR": "" }, { "CORES": 6, "THREADS": 6, "SPEED_GHZ": 2.3, "DESCRIPTION": "AMD Opteron(tm) Processor 4174 HE Hynix Semiconductor (Hyundai Electronics)", "PRODUCT": "", "VENDOR": "" } ], "MEMORY": [ { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 0, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 1, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 8589934592, "SIZE_S": "8589934592", "SIZE_HUMAN": "8.00 GB", "BANK": 2, "DESCRIPTION": "DIMM DDR3 Synchronous 1333 MHz (0.8 ns) - Hyundai HMT31GR7BFR4A-H9", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 3, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 4, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 8589934592, "SIZE_S": "8589934592", "SIZE_HUMAN": "8.00 GB", "BANK": 5, "DESCRIPTION": "DIMM DDR3 Synchronous 1333 MHz (0.8 ns) - Hyundai HMT31GR7BFR4A-H9", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 6, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 7, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 8589934592, "SIZE_S": "8589934592", "SIZE_HUMAN": "8.00 GB", "BANK": 8, "DESCRIPTION": "DIMM DDR3 Synchronous 1333 MHz (0.8 ns) - Hyundai HMT31GR7BFR4A-H9", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 9, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 0, "SIZE_S": "0", "SIZE_HUMAN": "0 Bytes", "BANK": 10, "DESCRIPTION": "Empty Memory Bank", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 8589934592, "SIZE_S": "8589934592", "SIZE_HUMAN": "8.00 GB", "BANK": 11, "DESCRIPTION": "DIMM DDR3 Synchronous 1333 MHz (0.8 ns) - Hyundai HMT31GR7BFR4A-H9", "PRODUCT": "", "VENDOR": "" } ], "NIC": [ { "SPEED": 1000000000, "SPEED_S": "1000000000", "SPEED_HUMAN": "1.00 Gb", "MAC_ADDRESS": "e8:9a:8f:23:15:72", "DESCRIPTION": "82576 Gigabit Network Connection - Intel Corporation", "PRODUCT": "", "VENDOR": "" }, { "SPEED": 1000000000, "SPEED_S": "1000000000", "SPEED_HUMAN": "1.00 Gb", "MAC_ADDRESS": "e8:9a:8f:23:15:72", "DESCRIPTION": "82576 Gigabit Network Connection - Intel Corporation", "PRODUCT": "", "VENDOR": "" } ], "DISK": [ { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" }, { "SIZE": 1000204886016, "SIZE_S": "1000204886016", "SIZE_HUMAN": "931.51 GB", "TYPE": "SCSI", "DESCRIPTION": "Seagate ST91000640NS", "PRODUCT": "", "VENDOR": "" } ] }, "LLDP": { "INTERFACES": [ { "NAME": "eth0", "CHASSIS": { "NAME": "core01.dfw01", "ID": { "TYPE": "mac", "VALUE": "78:19:f7:88:60:c0" }, "DESCRIPTION": "Juniper Networks, Inc. ex4500-40f , version 11.1S1 Build date: 2011-04-21 08:03:12 UTC " }, "PORT": { "ID": { "TYPE": "local", "VALUE": "608" }, "DESCRIPTION": "ge-0\/0\/3.0" }, "VLANS": [ { "ID": 106, "NAME": "DFW-LOGGING" } ] }, { "NAME": "eth1", "CHASSIS": { "NAME": "core02.dfw01", "ID": { "TYPE": "mac", "VALUE": "5c:5e:ab:68:a5:80" }, "DESCRIPTION": "Juniper Networks, Inc. ex4500-40f , version 11.1R1.10 Build date: 2011-03-16 08:17:03 UTC " }, "PORT": { "ID": { "TYPE": "local", "VALUE": "608" }, "DESCRIPTION": "ge-0\/0\/3.0" }, "VLANS": [ { "ID": 106, "NAME": "DFW-LOGGING" } ] } ] }, "IPMI": { "ASSET_ID": 2, "ASSET_TAG": "tumblrtag30", "IPMI_USERNAME": "root", "IPMI_PASSWORD": "WqbXjuqWd5MZ01fD", "IPMI_GATEWAY": "172.16.32.1", "IPMI_ADDRESS": "172.16.32.20", "IPMI_NETMASK": "255.255.240.0", "ID": 2 }, "ADDRESSES": [ ], "POWER": [ { "UNIT_ID": 0, "UNITS": [ { "KEY": "POWER_PORT_A", "VALUE": "plug a", "TYPE": "POWER_PORT", "LABEL": "Plug Strip A", "POSITION": 0, "IS_REQUIRED": true, "UNIQUE": true }, { "KEY": "POWER_OUTLET_A", "VALUE": "outlet a", "TYPE": "POWER_OUTLET", "LABEL": "Outlet A", "POSITION": 1, "IS_REQUIRED": true, "UNIQUE": false } ] }, { "UNIT_ID": 1, "UNITS": [ { "KEY": "POWER_PORT_B", "VALUE": "plug b", "TYPE": "POWER_PORT", "LABEL": "Plug Strip B", "POSITION": 0, "IS_REQUIRED": true, "UNIQUE": true }, { "KEY": "POWER_OUTLET_B", "VALUE": "outlet b", "TYPE": "POWER_OUTLET", "LABEL": "Outlet B", "POSITION": 1, "IS_REQUIRED": true, "UNIQUE": false } ] } ], "ATTRIBS": { "0": { "DISK_STORAGE_TOTAL": "6001229316096", "NODECLASS": "web", "CHASSIS_TAG": "chassistag123" } } } }
Description | Find specified assets | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | GET /api/assets | ||||||||||||||||||||||||||||||||||||
Permission | controllers.AssetApi.getAssets | ||||||||||||||||||||||||||||||||||||
Parameters Paginated |
|
||||||||||||||||||||||||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "Pagination": { "PreviousPage": 0, "CurrentPage": 0, "NextPage": 0, "TotalResults": 3 }, "Data": [ { "ID": 4, "TAG": "tumblrtag32", "STATE": { "ID": 3, "STATUS": null, "NAME": "RUNNING", "LABEL": "Running", "DESCRIPTION": "A service in this state is operational." }, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-09-16T19:49:31", "UPDATED": "2012-09-16T19:50:05", "DELETED": null }, { "ID": 2, "TAG": "tumblrtag30", "STATE": { "ID": 3, "STATUS": null, "NAME": "RUNNING", "LABEL": "Running", "DESCRIPTION": "A service in this state is operational." }, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-09-16T19:49:24", "UPDATED": "2012-09-16T19:49:57", "DELETED": null }, { "ID": 3, "TAG": "tumblrtag31", "STATE": { "ID": 3, "STATUS": null, "NAME": "RUNNING", "LABEL": "Running", "DESCRIPTION": "A service in this state is operational." }, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-09-16T19:49:28", "UPDATED": "2012-09-16T19:50:02", "DELETED": null } ] } }
Description | Find assets similar to another | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/similar | ||||||
Permission | controllers.AssetApi.getAssets | ||||||
Note This depends on having a proper nodeclassifer setup. See the nodeclassifier section of the configuration documentation. | |||||||
Parameters Paginated |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "Pagination": { "PreviousPage": 0, "CurrentPage": 0, "NextPage": 1, "TotalResults": 435 }, "Data": [ { "ID": 388, "TAG": "000915", "STATE": null, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-04-05T23:40:42", "UPDATED": "2012-09-14T16:59:53", "DELETED": null }, { "ID": 437, "TAG": "000919", "STATE": null, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-04-05T23:42:33", "UPDATED": "2012-09-14T17:12:22", "DELETED": null }, { "ID": 391, "TAG": "000923", "STATE": null, "STATUS": "Unallocated", "TYPE": "Server Node", "CREATED": "2012-04-05T23:41:03", "UPDATED": "2012-09-14T17:09:11", "DELETED": null } ] } }
Description | Delete a tag associated with an asset | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/asset/:tag/attribute/:attribute | ||||||||||||
Permission | controllers.AssetApi.deleteAssetAttribute | ||||||||||||
Parameters |
|
||||||||||||
Response Codes |
|
{ "status": "success:accepted", "data": { "SUCCESS": true } }
Description | Decommission the specified asset | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/asset/:tag | |||||||||
Permission | controllers.AssetApi.deleteAsset | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Provisioning, power management, IPMI data
Most of the API endpoints that are part of the asset management API are provisioning, power, or IPMI related. All of the asset management endpoints are going to depend somewhat on how you have configured collins. While the API remains consistent, the under the hood behavior of Collins will depend greatly on configuration. For more details in provisioning, IPMI, and power configurations see the configuration documentation.
Description | Create or update IPMI data | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag/ipmi | ||||||||||||||||||
Permission | controllers.IpmiApi.updateIpmi | ||||||||||||||||||
Note This is one of the few API endpoints that will both create and/or update a resource. This will likely change in the future (PUT for create, POST for update). If you are creating IPMI info, all parameters below are required. If you are updating IPMI info, at least one parameter must be specified. | |||||||||||||||||||
Parameters |
|
||||||||||||||||||
Response Codes |
|
{ "status": "success:created", "data": { "SUCCESS": true } } { "status": "success:ok", "data": { "SUCCESS": true } }
Description | Send a power management event to an asset. | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag/power | ||||||||||||||||||
Permission | controllers.AssetManagementApi.powerManagement | ||||||||||||||||||
Parameters |
|
||||||||||||||||||
Power Actions |
|
||||||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Determine the power status for a machine (on, off, unknown) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/power | ||||||||||
Permission | controllers.AssetManagementApi.powerStatus | ||||||||||
Parameters |
|
||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "MESSAGE": "on" } }
Description | Provision the specified asset using the specified parameters. | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/provision/:tag | |||||||||||||||||||||||||||
Permission | controllers.AssetManagementApi.provisionAsset | |||||||||||||||||||||||||||
Note This API call may take a long time (depending on the configured provisioning backend). Client implementations should account for this with an appropriate timeout. | ||||||||||||||||||||||||||||
Parameters |
|
|||||||||||||||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Retrieve a list of available provisioning profiles. | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/provision/profiles | ||||||
Permission | controllers.AssetManagementApi.getProvisioningProfiles | ||||||
Parameters | None | ||||||
Response Codes |
|
{ "status": "success:ok", "data": { "PROFILES": [ { "PROFILE": "aaacanode", "LABEL": "AAA/CA Server", "PREFIX": "aaa", "SUFFIX_ALLOWED": true, "PRIMARY_ROLE": "INFRA", "REQUIRES_PRIMARY_ROLE": true, "POOL": null, "REQUIRES_POOL": true, "SECONDARY_ROLE": null, "REQUIRES_SECONDARY_ROLE": false }, { "PROFILE": "adminwebnode", "LABEL": "Admin Web Server", "PREFIX": "adminweb", "SUFFIX_ALLOWED": false, "PRIMARY_ROLE": "TUMBLR_APP", "REQUIRES_PRIMARY_ROLE": true, "POOL": "ADMIN_POOL", "REQUIRES_POOL": true, "SECONDARY_ROLE": "ALL", "REQUIRES_SECONDARY_ROLE": false }, { "PROFILE": "appcronnode", "LABEL": "App Cron Server", "PREFIX": "app-cron", "SUFFIX_ALLOWED": false, "PRIMARY_ROLE": "TUMBLR_APP", "REQUIRES_PRIMARY_ROLE": true, "POOL": "UTIL", "REQUIRES_POOL": true, "SECONDARY_ROLE": null, "REQUIRES_SECONDARY_ROLE": false }, { "PROFILE": "assetnode", "LABEL": "Asset Server", "PREFIX": "assets", "SUFFIX_ALLOWED": false, "PRIMARY_ROLE": null, "REQUIRES_PRIMARY_ROLE": true, "POOL": null, "REQUIRES_POOL": true, "SECONDARY_ROLE": null, "REQUIRES_SECONDARY_ROLE": false } ] } }
Asset Hierarchy operations
The Asset Hierarchy API enables you to define physical hierarchical links betwen assets. This information is used to build Rack and Blade views. Please note this API is still experimental, and lacks complete tests and HTTP safety checks.
Description | Create or update an Asset Hierarchy link | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/hierarchy/:tag | |||||||||||||||
Permission | controllers.HierarchyApi.updateHierarchy | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:created" }
Description | Remove Asset Hierarchy link | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/hierarchy/:tag/:child | |||||||||
Permission | controllers.HierarchyApi.updateHierarchy | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
{ "status": "success:created" }
Description | Get the parent of an asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/hierarchy/:tag/parent | ||||||
Parameters |
|
Description | Get the children of an asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/hierarchy/:tag/children. | ||||||
Parameters |
|
Description | Get all hierirchy links |
---|---|
Request | GET /api/hierarchy/nodes |
Audit trail for your assets
The logs API is fairly straight forward, offering only 3 endpoints to interact with. You can create logs, fetch logs for a specific asset, or fetch all logs. All log levels (referred to as type in the API) are listed below.
Level | Description |
EMERGENCY | A "panic" condition - notify all tech staff on call? (earthquake? tornado?) - affects multiple apps/servers/sites... |
ALERT | Should be corrected immediately - notify staff who can fix the problem - example is loss of backup ISP connection |
CRITICAL | Should be corrected immediately, but indicates failure in a primary system - fix CRITICAL problems before ALERT - example is loss of primary ISP connection |
ERROR | Non-urgent failures - these should be relayed to developers or admins; each item must be resolved within a given time |
WARNING | Warning messages - not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time |
NOTICE | Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required |
INFORMATIONAL | Normal operational messages - may be harvested for reporting, measuring throughput, etc - no action required |
DEBUG | Info useful to developers for debugging the application, not useful during operations |
NOTE | Creates by users via the web UI, can be any kind of message |
Description | Create a new log entry for the specified asset | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | PUT /api/asset/:tag/log | |||||||||||||||
Permission | controllers.AssetLogApi.submitLogData | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:created", "data": { "SUCCESS": true } }
Description | Get logs associated with an asset | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/logs | |||||||||
Permission | controllers.AssetLogApi.getLogData | |||||||||
Parameters Paginated |
|
|||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "Pagination": { "PreviousPage": 0, "CurrentPage": 0, "NextPage": 0, "TotalResults": 3 }, "Data": [ { "ID": 3, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T13:04:52", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User collins: Hello World" }, { "ID": 2, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:15", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User collins: Hello World" }, { "ID": 1, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:07", "FORMAT": "text\/plain", "SOURCE": "INTERNAL", "TYPE": "INFORMATIONAL", "MESSAGE": "Automatically created by database migration" } ] } }
Description | Get all log data, not bound to a specific asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/assets/logs | ||||||
Permission | controllers.AssetLogApi.getAllLogData | ||||||
Parameters Paginated |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "Pagination": { "PreviousPage": 0, "CurrentPage": 0, "NextPage": 0, "TotalResults": 3 }, "Data": [ { "ID": 3, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T13:04:52", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User collins: Hello World" }, { "ID": 2, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:15", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User collins: Hello World" }, { "ID": 1, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:07", "FORMAT": "text\/plain", "SOURCE": "INTERNAL", "TYPE": "INFORMATIONAL", "MESSAGE": "Automatically created by database migration" } ] } }
System tag management
The tags API provides access to all system tags. It provides the ability to list all tags, and to list all values for a given tag. Note that it is not possible to list the values of encrypted tags.
Description | List all the unique values given a specific tag | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/tag/:tag | ||||||
Permission | controllers.TagApi.getTagValues | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "values": [ "chassis tag abc" ] } }
IP Address Management
Collins provides a fairly robust IPAM system, complete with callbacks and hooks to drive automation for your networking devices. Address management comes in two forms, strict and non-strict. In strict mode, addresses can only by allocated or managed from predefined pools. The pool configuration is documented here. In non-strict mode, which is typically only suitable if you don't manage your own addresses, Collins will allow you to allocate any addresses, as long as they aren't in use.
In addition to address management (creates, deletes, etc), the Collins IPAM API allows you to easily query this information. You can find out which pools are in use as well as utilization statistics, you can find out which asset is using a particular address, you can find out which assets are in a particular pool.
Description | Create one or more addresses in a pool | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | PUT /api/asset/:tag/address | |||||||||||||||
Permission | controllers.IpAddressApi.allocateAddress | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:created", "data": { "ADDRESSES": [ { "ASSET_ID": 1, "ASSET_TAG": "tumblrtag1", "GATEWAY": "172.16.5.1", "ADDRESS": "172.16.5.4", "NETMASK": "255.255.255.0", "POOL": "DEV", "ID": 1 } ] } }
Description | Update IP address information | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag/address | ||||||||||||||||||||||||
Permission | controllers.IpAddressApi.updateAddress | ||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Delete all addresses associated with a given tag, optionally associated with a pool | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/asset/:tag/addresses | |||||||||
Permission | controllers.IpAddressApi.purgeAddresses | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "DELETED": 1 } }
Description | Return pools that are in use or configured | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/address/pools | ||||||
Permission | controllers.IpAddressApi.getAddressPools | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "POOLS": [ { "NAME": "ADMIN-OPS", "NETWORK": "172.16.56.0\/24", "START_ADDRESS": "172.16.56.5", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.56.1", "BROADCAST": "172.16.56.255", "POSSIBLE_ADDRESSES": 254 }, { "NAME": "WEB-EDIT", "NETWORK": "172.16.64.0\/24", "START_ADDRESS": "172.16.64.5", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.64.1", "BROADCAST": "172.16.64.255", "POSSIBLE_ADDRESSES": 254 }, { "NAME": "DEV", "NETWORK": "172.16.5.0\/24", "START_ADDRESS": "172.16.5.4", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.5.1", "BROADCAST": "172.16.5.255", "POSSIBLE_ADDRESSES": 254 }, { "NAME": "WEB-SECURE", "NETWORK": "172.16.73.0\/28", "START_ADDRESS": "172.16.73.5", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.73.1", "BROADCAST": "172.16.73.15", "POSSIBLE_ADDRESSES": 14 }, { "NAME": "AAA", "NETWORK": "172.16.4.0\/28", "START_ADDRESS": "172.16.4.4", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.4.1", "BROADCAST": "172.16.4.15", "POSSIBLE_ADDRESSES": 14 } ] } }
Description | Return addresses associated with an asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/addresses | ||||||
Permission | controllers.IpAddressApi.getForAsset | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "ADDRESSES": [ { "ASSET_ID": 1, "ASSET_TAG": "tumblrtag1", "GATEWAY": "172.16.5.1", "ADDRESS": "172.16.5.4", "NETMASK": "255.255.255.0", "POOL": "DEV", "ID": 2 } ] } }
Description | Get the asset associated with a specific address | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/with/address/:address | ||||||
Permission | controllers.IpAddressApi.assetFromAddress | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "ID": 1, "TAG": "tumblrtag1", "STATE": null, "STATUS": "Incomplete", "TYPE": "Server Node", "CREATED": "2012-09-17T14:07:19", "UPDATED": null, "DELETED": null } }
Description | Get the assets that are allocated in a specific pool | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/assets/with/addresses/in/:pool | ||||||
Permission | controllers.IpAddressApi.assetsFromPool | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "ASSETS": [ { "ID": 1, "TAG": "tumblrtag1", "STATE": null, "STATUS": "Incomplete", "TYPE": "Server Node", "CREATED": "2012-09-17T14:07:19", "UPDATED": null, "DELETED": null } ] } }
Asset state management and API driven state machines
Collins provides comprehensive support for API driven asset state management. There is more information about states and state management in the concepts documentation.
Description | Create a new asset state | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | PUT /api/state/:name | |||||||||||||||
Permission | controllers.AssetStateApi.createState | |||||||||||||||
Parameters |
|
|||||||||||||||
Response Codes |
|
{ "status": "success:created", "data": { "SUCCESS": true } }
Description | Update a state | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/state/:old_name | ||||||||||||||||||
Permission | controllers.AssetStateApi.updateState | ||||||||||||||||||
Parameters |
|
||||||||||||||||||
Response Codes |
|
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Delete a state | ||||||||
---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/state/:name | ||||||||
Permission | controllers.AssetStateApi.deleteState | ||||||||
Parameters |
|
||||||||
Response Codes |
|
{ "status": "success:accepted", "data": { "DELETED": 2 } }
Description | Get a state by name | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/state/:name | ||||||
Permission | controllers.AssetStateApi.getState | ||||||
Parameters |
|
||||||
Response Codes |
|
{ "status": "success:ok", "data": { "ID": 15, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "HW_ON_FIRE", "LABEL": "Hardware on Fire!", "DESCRIPTION": "Use this state if hardware has caught on fire" } }
Description | Get all available states | ||||
---|---|---|---|---|---|
Request | GET /api/states | ||||
Permission | controllers.AssetStateApi.getState | ||||
Parameters | None | ||||
Response Codes |
|
{ "status": "success:ok", "data": [ { "ID": 1, "STATUS": null, "NAME": "NEW", "LABEL": "New", "DESCRIPTION": "A service in this state is inactive. It does minimal work and consumes minimal resources." }, { "ID": 2, "STATUS": null, "NAME": "STARTING", "LABEL": "Starting", "DESCRIPTION": "A service in this state is transitioning to Running." }, { "ID": 3, "STATUS": null, "NAME": "RUNNING", "LABEL": "Running", "DESCRIPTION": "A service in this state is operational." }, { "ID": 4, "STATUS": null, "NAME": "STOPPING", "LABEL": "Stopping", "DESCRIPTION": "A service in this state is transitioning to Terminated." }, { "ID": 5, "STATUS": null, "NAME": "TERMINATED", "LABEL": "Terminated", "DESCRIPTION": "A service in this state has completed execution normally. It does minimal work and consumes minimal resources." }, { "ID": 6, "STATUS": null, "NAME": "FAILED", "LABEL": "Failed", "DESCRIPTION": "A service in this state has encountered a problem and may not be operational. It cannot be started nor stopped." }, { "ID": 7, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "RELOCATION", "LABEL": "Relocation", "DESCRIPTION": "An asset is being physically relocated." }, { "ID": 8, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "IPMI_PROBLEM", "LABEL": "IPMI Problem", "DESCRIPTION": "An asset is experiencing IPMI issues and needs to be examined. It needs investigation." }, { "ID": 9, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "HARDWARE_PROBLEM", "LABEL": "Hardware Problem", "DESCRIPTION": "An asset is experiencing a non-IPMI issue and needs to be examined. It needs investigation." }, { "ID": 10, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "NETWORK_PROBLEM", "LABEL": "Network Problem", "DESCRIPTION": "An asset is experiencing a network problem that may or may not be hardware related. It needs investigation." }, { "ID": 11, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "HARDWARE_UPGRADE", "LABEL": "Hardware Upgrade", "DESCRIPTION": "An asset is in need or in process of having hardware upgraded." }, { "ID": 12, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "HW_TESTING", "LABEL": "Hardware Testing", "DESCRIPTION": "Performing some testing that requires putting the asset into a maintenance state." }, { "ID": 13, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "MAINT_NOOP", "LABEL": "Maintenance NOOP", "DESCRIPTION": "Doing nothing, bouncing this through maintenance for my own selfish reasons." }, { "ID": 15, "STATUS": { "ID": 5, "NAME": "Maintenance", "DESCRIPTION": "Asset is scheduled for maintenance" }, "NAME": "HW_ON_FIRE", "LABEL": "Hardware on Fire", "DESCRIPTION": "Use this state if hardware has caught on fire" } ] }
Miscellaneous endpoints that don't belong anywhere else
A collection of miscellaneous API methods that may be useful to you.
Description | Fetch the current unix timestamp from this collins instance | ||||
---|---|---|---|---|---|
Request | GET /api/timestamp | ||||
Permission | None | ||||
Parameters | None | ||||
Response Codes |
|
||||
Note Output from this endpoint is only available as text |
1347919676
Description | Check if collins is alive | ||||
---|---|---|---|---|---|
Request | GET /api/ping | ||||
Permission | None | ||||
Parameters | None | ||||
Response Codes |
|
||||
Note Output from this endpoint is only available as text |
pong
Collins Administrative operations
The Admin API contains endpoints for Collins administrative tasks.
Description | Trigger repopulation of the Solr index. This does not normally need to be manually done, but useful for testing or after any database changes not done through Collins | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/admin/solr | ||||||
Permission | controllers.Admin.clearCache | ||||||
Parameters |
|
||||||
Response Codes |
|
OK