Getting RESTful with your assets
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.
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 |
|
collins-shell asset create --tag=TAG [--ipmi=(true|false) --status=STATUS --type=TYPE]
curl --basic -u blake:admin:first -X PUT http://localhost:9000/api/asset/tumblrtag30
c.create!('test01', generate_ipmi: true) # default IPMI pool c.create!('test02', generate_ipmi: true, ipmi_pool: 'OOB-POD03') c.create!('config_vip', type: :configuration, generate_ipmi: false, status: :allocated)
{ "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 | ||||||||||||||||||||||||
NoteIf you are setting an encrypted tag, you must also have the feature.canWriteEncryptedTags permission. See the features documentation for more information. | |||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||
Response Codes |
|
collins-shell asset set_attribute TAG_NAME TAG_VALUE --tag=TAG
curl --basic -u blake:admin:first \ --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 |
|
collins-shell asset set_status --reason=REASON [--state=STATE --status=STATUS]
curl --basic -u blake:admin:first \ -d status=Unallocated \ -d state=Running \ -d reason='Ready for action' \ http://localhost:9000/api/asset/tumblrtag30/status
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Get an asset by tag | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag | ||||||
Permission | controllers.AssetApi.getAsset | ||||||
NoteIf the asset has encrypted tags, they will be hidden unless you have the feature.canSeeEncryptedTags permission. See the features documentation for more information. | |||||||
Parameters |
|
||||||
Response Codes |
|
collins-shell asset get TAG
curl --basic -u blake:admin:first http://localhost:9000/api/asset/tumblrtag30
{ "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": "" } ] }, "CLASSIFICATION": { "ID": 3, "TAG": "dell_r610", "STATE": null, "STATUS": "Incomplete", "TYPE": "CONFIGURATION", "CREATED": "2017-04-21T14:47:37", "UPDATED": "2017-04-21T14:48:08", "DELETED": null }, "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 |
|
collins-shell asset find --selector=NODECLASS:web status:Unallocated
curl --basic -u blake:admin:first 'http://localhost:9000/api/assets?attribute=NODECLASS%3Bweb&status=Unallocated'
{ "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 | |||||||||
NoteThis depends on having a proper nodeclassifer setup. See the nodeclassifier section of the configuration documentation. | ||||||||||
Parameters Paginated |
|
|||||||||
Response Codes |
|
collins-shell asset find_similar 001367
curl --basic -u blake:admin:first 'http://localhost:9000/api/asset/001367/similar'
{ "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 |
|
collins-shell asset delete_attribute NODECLASS --tag=tumblrtag30
curl --basic -u blake:admin:first -X DELETE http://localhost:9000/api/asset/tumblrtag30/attribute/NODECLASS
{ "status": "success:accepted", "data": { "SUCCESS": true } }
Description | Permanently delete the specified asset | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/asset/:tag | ||||||||||||
Permission | controllers.AssetApi.deleteAsset | ||||||||||||
Parameters |
|
||||||||||||
Response Codes |
|
collins-shell asset delete --reason='Done with you' --tag=tumblrtag30 --nuke=true
curl --basic -u blake:admin:first -d nuke=true -X DELETE http://localhost:9000/api/asset/tumblrtag30
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Decommission the specified asset | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag | |||||||||
Permission | controllers.AssetApi.updateAssetStatus | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
collins-shell asset set_status --status='Decommissioned' --reason='Done with you' --tag=tumblrtag30
curl --basic -u blake:admin:first -d status="Decommissioned" -X POST http://localhost:9000/api/asset/tumblrtag30
{ "status": "success:ok", "data": { "SUCCESS": true } }
The Asset Type API allows you to create and manage new types of assets, aside from the built in asset types (i.e. SERVER_NODE, CONFIGURATION, SWITCH). This provides a CRUD interface to defining new asset types for your own use.
Description | Create a new asset type | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | PUT /api/assettype/:name | |||||||||
Permission | controllers.AssetTypeApi.createAssetType | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
collins-shell asset_type create --name=NAME --label=LABEL
curl -XPUT -u blake:admin:first --basic \ -d label='Service Asset Type' \ http://localhost:9000/api/assettype/SERVICE
{"status"=>"success:created", "data"=>{"SUCCESS"=>true}}
SUCCESS=true;
SUCCESS true
Description | Update an asset type | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/assettype/:tag | |||||||||
Permission | controllers.AssetTypeApi.updateAssetType | |||||||||
Parameters |
|
|||||||||
Response Codes |
|
collins-shell asset_type update OLDNAME [--name=NAME --label=LABEL]
curl -v -u blake:admin:first --basic -d name='NEW_NAME' http://localhost:9000/api/assettype/OLD_NAME
{ "status": "success:ok", "data": { "SUCCESS": true } }
SUCCESS=true;
SUCCESS=true;
Description | Get an asset type by name | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/assettype/:name | ||||||
Permission | controllers.AssetTypeApi.getAssetType | ||||||
Parameters |
|
||||||
Response Codes |
|
collins-shell asset_type get NAME
curl --basic -u blake:admin:first http://localhost:9000/api/assettype/tumblrtag30
{ "status":"success:ok", "data":{ "ID":1, "NAME":"SERVER_NODE", "LABEL":"Server Node" } }
Description | Get all asset types | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/assettypes | ||||||
Permission | controllers.AssetTypeApi.getAssetType | ||||||
Response Codes |
|
collins-shell asset_type list
curl --basic -u blake:admin:first http://localhost:9000/api/assettypes
{ "status":"success:ok", "data":[ { "ID":1, "NAME":"SERVER_NODE", "LABEL":"Server Node" }, { "ID":2, "NAME":"SERVER_CHASSIS", "LABEL":"Server Chassis" }, { "ID":3, "NAME":"RACK", "LABEL":"Rack" }, { "ID":4, "NAME":"SWITCH", "LABEL":"Switch" }, { "ID":5, "NAME":"ROUTER", "LABEL":"Router" }, { "ID":6, "NAME":"POWER_CIRCUIT", "LABEL":"Power Circuit" }, { "ID":7, "NAME":"POWER_STRIP", "LABEL":"Power Strip" }, { "ID":8, "NAME":"DATA_CENTER", "LABEL":"Data Center" }, { "ID":9, "NAME":"CONFIGURATION", "LABEL":"Configuration" } ] }
Description | Delete the specified asset type | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/assettype/:name | ||||||||||
Permission | controllers.AssetTypeApi.deleteAssetType | ||||||||||
Parameters |
|
||||||||||
Response Codes |
|
collins-shell asset_type delete NAME
curl --basic -u blake:admin:first -X DELETE http://localhost:9000/api/assettype/NAME
{ "status": "success:ok", "data": { "DELETED": 1 } }
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 | Generate IPMI configuration on an asset without IPMI details | ||||||
---|---|---|---|---|---|---|---|
Request | PUT /api/asset/:tag/ipmi | ||||||
Permission | controllers.IpmiApi.generateIpmi | ||||||
NotePool is an optional parameter. If not specified, this behaves identically to how the asset create endpoint works when generate_ipmi is enabled. | |||||||
Parameters |
|
||||||
Response Codes |
|
collins-shell ipmi generate --pool=OOB-POD02 --tag=tumblrtag2
collins.ipmi_allocate('tumblrtag2', pool: 'OOB-POD02')
curl --basic -u blake:admin:first http://localhost:9000/api/asset/tumblrtag3/ipmi curl --basic -u blake:admin:first -d pool=OOB-POD02 http://localhost:9000/api/asset/tumblrtag2/ipmi
Description | Update IPMI configuration on an asset | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/asset/:tag/ipmi | ||||||||||||||||||
Permission | controllers.IpmiApi.updateIpmi | ||||||||||||||||||
NoteThis 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 |
|
collins-shell ipmi create \ --address=172.168.0.33 \ --gateway=172.168.0.1 \ --netmask=255.255.255.0 \ --ipmi-username=root \ --ipmi-password=fizzbuzz \ --tag=tumblrtag2 collins-shell ipmi update --ipmi-password=fizzbuzz23 --tag=tumblrtag2
curl --basic -u blake:admin:first \ -d address=172.168.0.34 \ -d gateway=172.168.0.1 \ -d netmask=255.255.255.0 \ -d username=root \ -d password=fizzbuzz http://localhost:9000/api/asset/tumblrtag3/ipmi curl --basic -u blake:admin:first \ -d password=fizzbuzz23 \ http://localhost:9000/api/asset/tumblrtag3/ipmi
{ "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 |
|
|||||||||||||||||||||||||||
Response Codes |
|
collins-shell power rebootSoft --reason='Need to restart for maintenance' --tag=tumblrtag1
curl -v -u blake:admin:first --basic -d action=rebootSoft http://localhost:9000/api/asset/tumblrtag1/power
{ "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 |
|
collins-shell power_status --tag=tumblrtag1
curl -v -u blake:admin:first --basic http://localhost:9000/api/asset/tumblrtag1/power
{ "status": "success:ok", "data": { "MESSAGE": "on" } }
Description | Get the available profiles for provisioning | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/provision/profiles | ||||||
Permission | controllers.AssetManagementApi.getProvisioningProfiles | ||||||
Response Codes |
|
collins-shell provision list
curl -v -u blake:admin:first --basic http://localhost:9000/api/provision/profiles
{ "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 } ] } }
Description | Provision the specified asset using the specified parameters. | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/provision/:tag | |||||||||||||||||||||||||||
Permission | controllers.AssetManagementApi.provisionAsset | |||||||||||||||||||||||||||
NoteThis 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 |
|
collins-shell provision host tumblrtag1 devnode blake --suffix=blake
curl -v -u blake:admin:first --basic \ -d profile=devnode \ -d contact=blake \ -d suffix=blake \ http://localhost:9000/api/provision/tumblrtag1
{ "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 } ] } }
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 | ||||||||||||
NoteIt is also possible to specify these parameters as the body of the PUT request with a Content-Type header of application/json . In this case, the body is a JSON encoded object with the keys Message (arbitrary JSON value) and Type (one of the strings specified above). This is useful for logging structured data. | |||||||||||||
Parameters |
|
||||||||||||
Response Codes |
|
collins-shell log 'Hello World' --severity=DEBUG --tag=tumblrtag1
curl --basic -u blake:admin:first -X PUT -d message='Hello World' -d type=DEBUG http://localhost:9000/api/asset/tumblrtag1/log
{ "status": "success:created", "data": { "SUCCESS": true, "Data": { "ID": 2, "ASSET_TAG": "tumblrtag1", "CREATED": "2016-09-16T16:48:40", "CREATED_BY": "blake", "FORMAT": "text/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "Hello World" } } }
Description | Get logs associated with an asset | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/logs | |||||||||
Permission | controllers.AssetLogApi.getLogData | |||||||||
Parameters Paginated |
|
|||||||||
Response Codes |
|
collins-shell logs tumblrtag1
curl --basic -u blake:admin:first http://localhost:9000/api/asset/tumblrtag1/logs
{ "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", "CREATED_BY": "blake", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User blake: Hello World" }, { "ID": 2, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:15", "CREATED_BY": "blake", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User blake: Hello World" }, { "ID": 1, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:07", "CREATED_BY": "blake", "FORMAT": "text\/plain", "SOURCE": "INTERNAL", "TYPE": "INFORMATIONAL", "MESSAGE": "Automatically created by database migration" } ] } }
Description | Get a log by its ID number | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/log/:id | ||||||
Permission | |||||||
Parameters |
|
||||||
Response Codes |
|
curl --basic -u blake:admin:first http://localhost:9000/api/log/42
{ "status": "success:ok", "data": { "Pagination": { "PreviousPage": 0, "CurrentPage": 0, "NextPage": 1, "TotalResults": 1 }, "Data": [ { "ID": 42, "ASSET_TAG": "sl-102313", "CREATED": "2012-02-08T04:05:06", "FORMAT": "text/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "hello world log" } ]} }
Description | Get all log data, not bound to a specific asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/assets/logs | ||||||
Permission | controllers.AssetLogApi.getAllLogData | ||||||
Parameters Paginated |
|
||||||
Response Codes |
|
collins-shell logs all
curl --basic -u blake:admin:first http://localhost:9000/api/assets/logs
{ "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 blake: Hello World" }, { "ID": 2, "ASSET_TAG": "tumblrtag1", "CREATED": "2012-09-17T12:53:15", "FORMAT": "text\/plain", "SOURCE": "API", "TYPE": "DEBUG", "MESSAGE": "User blake: 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" } ] } }
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 |
|
collins-shell tag values CHASSIS_TAG
curl --basic -u blake:admin:first http://localhost:9000/api/tag/CHASSIS_TAG
{ "status": "success:ok", "data": { "values": [ "chassis", "tag", "abc" ] } }
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 | ||||||||||||
NoteBy default no pools are configured. Your Collins administrator must tell you what pools are available for allocation or you can use the pools API endpoint. | |||||||||||||
Parameters |
|
||||||||||||
Response Codes |
|
collins-shell ip_address allocate DEV --tag=tumblrtag1
curl --basic -u blake:admin:first -X PUT -d pool=DEV http://localhost:9000/api/asset/tumblrtag1/address
{ "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 | |||||||||||||||||||||
NoteIf all address information is supplied (address, gateway, and netmask), but no old_address is specified, Collins will attempt to create the address. | ||||||||||||||||||||||
Parameters |
|
|||||||||||||||||||||
Response Codes |
|
collins-shell ip_address update 172.16.5.4 --tag=tumblrtag1 --address=172.16.5.5
curl --basic -u blake:admin:first -X POST \ -d address=172.16.5.5 \ -d old_address=172.16.5.4 \ http://localhost:9000/api/asset/tumblrtag1/address
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Delete addresses associated with a given tag: either all addresses, those associated with a specified pool, or a single address. If this endpoint is called with no parameters all addresses will be deleted. Both pool and address can't be set in a single request. | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/asset/:tag/addresses | ||||||||||||
Permission | controllers.IpAddressApi.purgeAddresses | ||||||||||||
Parameters |
|
||||||||||||
Response Codes |
|
collins-shell ip_address delete DEV --tag=tumblrtag1
curl --basic -u blake:admin:first -X DELETE \ -d pool=DEV \ http://localhost:9000/api/asset/tumblrtag1/addresses
{ "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 |
|
collins-shell ip_address pools
curl --basic -u blake:admin:first http://localhost:9000/api/address/pools
{ "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 ipmi pools that are configured | ||||
---|---|---|---|---|---|
Request | GET /api/ipmi/pools | ||||
Permission | controllers.IpmiApi.GetAddressPools | ||||
NoteIf no IPMI pools are configured the parent level ipmi block settings are returned with a pool name of default. In the case of the parent level IPMI block being set as well pools defined only the pools will be returned due to some legacy code around ipmi pool loading. | |||||
Response Codes |
|
collins-shell ipmi pools
curl --basic -u blake:admin:first http://localhost:9000/api/ipmi/pools
{ "status": "success:ok", "data": { "POOLS": [ { "NAME": "OOB-POD01", "NETWORK": "172.16.32.0/20", "START_ADDRESS": "172.16.32.20", "SPECIFIED_GATEWAY": "Unspecified", "GATEWAY": "172.16.32.1", "BROADCAST": "172.16.47.255", "POSSIBLE_ADDRESSES": 4094 } ] } }
Description | Return addresses associated with an asset | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/asset/:tag/addresses | ||||||
Permission | controllers.IpAddressApi.getForAsset | ||||||
Parameters |
|
||||||
Response Codes |
|
collins-shell asset get tumblrtag1
curl --basic -u blake:admin:first http://localhost:9000/api/asset/tumblrtag1/addresses
{ "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 |
|
collins-shell ip_address find 172.16.5.4
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 |
|
collins-shell state create --name=HW_ON_FIRE \ --label='Hardware on Fire' \ --description='Use this state if hardware has caught on fire' \ --status=Maintenance
curl --basic -u blake:admin:first \ -X PUT \ -d label='Hardware on Fire' \ -d description='Use this state if hardware has caught on fire' \ -d status=Maintenance \ http://localhost:9000/api/state/HW_ON_FIRE
{ "status": "success:created", "data": { "SUCCESS": true } }
Description | Update a state | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Request | POST /api/state/:old_name | ||||||||||||||||||
Permission | controllers.AssetStateApi.updateState | ||||||||||||||||||
Parameters |
|
||||||||||||||||||
Response Codes |
|
collins-shell state update HW_ON_FIRE --label='Hardware on Fire!'
curl -v --basic -u blake:admin:first -d label='Hardware on Fire!' http://localhost:9000/api/state/HW_ON_FIRE
{ "status": "success:ok", "data": { "SUCCESS": true } }
Description | Delete a state | ||||||||
---|---|---|---|---|---|---|---|---|---|
Request | DELETE /api/state/:name | ||||||||
Permission | controllers.AssetStateApi.deleteState | ||||||||
Parameters |
|
||||||||
Response Codes |
|
collins-shell state delete HW_ON_FIRE
curl -v --basic -u blake:admin:first -X DELETE http://localhost:9000/api/state/HW_ON_FIRE
{ "status": "success:accepted", "data": { "DELETED": 2 } }
Description | Get a state by name | ||||||
---|---|---|---|---|---|---|---|
Request | GET /api/state/:name | ||||||
Permission | controllers.AssetStateApi.getState | ||||||
Parameters |
|
||||||
Response Codes |
|
collins-shell state get HW_ON_FIRE
curl -v --basic -u blake:admin:first http://localhost:9000/api/state/HW_ON_FIRE
{ "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 | ||||
Response Codes |
|
collins-shell state list
curl -v --basic -u blake:admin:first http://localhost:9000/api/states
{ "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" } ] }
Collins provides a simple firehose that clients can use to get near real-time notifications about updates to assets. Updates are pushed using server-sent events, and contains information about the type of update, which asset was updated and information about the asset in JSON format.
Description | Open a connection to receive server-sent events about asset updates | ||||
---|---|---|---|---|---|
Request | GET /api/firehose | ||||
Permission | controllers.Firehose.stream | ||||
NoteOutput from this endpoint is only available as content type text/event-stream in SSE format | |||||
Response Codes |
|
curl --basic -u blake:admin:first http://localhost:9000/api/firehose
event: asset_update data: {"name":"asset_update","tag":"tumblrtag30","category":"Asset","data":{"ASSET":{"ID":1,"TAG":"tumblrtag30","STATE":{"ID":3,"STATUS":null,"NAME":"RUNNING","LABEL":"Running","DESCRIPTION":"A service in this state is operational."},"STATUS":"Allocated","TYPE":"SERVER_NODE","CREATED":"2013-08-28T12:51:00","UPDATED":"2015-12-05T19:53:27","DELETED":null}}} event: asset_create data: {"name":"asset_create","tag":"tumblrtag31","category":"Asset","data":{"ASSET":{"ID":2,"TAG":"tumblrtag31","STATE":null,"STATUS":"Incomplete","TYPE":"SERVER_NODE","CREATED":"2016-01-13T11:30:37","UPDATED":null,"DELETED":null}}} event: asset_delete data: {"name":"asset_delete","tag":"tumblrtag32","category":"Asset","data":{"ASSET":{"ID":3,"TAG":"tumblrtag32","STATE":{"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."},"STATUS":"Decommissioned","TYPE":"SERVER_NODE","CREATED":"2016-01-13T11:38:25","UPDATED":"2016-01-13T11:38:50","DELETED":"2016-01-13T11:39:06"}}} event: ipAddresses_create data: {"name":"ipAddresses_create","tag":"tumblrtag30","category":"IpAddress","data":{"ASSET":{"ID":1,"TAG":"tumblrtag30","STATE":null,"STATUS":"Incomplete","TYPE":"SERVER_NODE","CREATED":"2016-01-13T11:41:26","UPDATED":null,"DELETED":null},"ADDRESSES":[{"ASSET_ID":1,"ASSET_TAG":"tumblrtag30","GATEWAY":"172.16.5.1","ADDRESS":"172.16.5.4","NETMASK":"255.255.255.0","POOL":"DEV","ID":1}]}}
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 |
|
curl --basic -u blake:admin:first http://localhost:9000/api/admin/solr
OK
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 | ||||
NoteOutput from this endpoint is only available as text | |||||
Response Codes |
|
curl http://localhost:9000/api/timestamp
1347919676
Description | Check if collins is alive | ||
---|---|---|---|
Request | GET /api/ping | ||
Permission | None | ||
NoteOutput from this endpoint is only available as text | |||
Response Codes |
|
curl http://localhost:9000/api/ping
pong