Create and manage your resources.
http://api.bugswarm.net/resources"x-bugswarmapikey: ${API_KEY}","content-type: application/json"Resources belong to users and may be created using this method. In order for a user's resource to participate in a swarm, however, the user must first add that resource to the swarm. Creating a resource involves passing a JSON object containing the resource's meta-data.
{
"name": "My resource",
"machine_type": "pc", # current valid types are "pc", "bug", and "smartphone"
"description": "My Resource description",
"position": {
"longitude": 0,
"latitude": 0
}
}
Usage: Create a JSON file with
the name create_resource.json and matching the above
format. Then execute:
curl -X POST -d@create_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/resourcesReturns: The created resource as a JSON object.
{
"id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
"user_id": "username",
"description": "My Resource description",
"machine_type": "pc",
"name": "My resource",
"created_at": "2011-10-09T22:58:39.710Z",
"position": {
"longitude": 0,
"latitude": 0
}
}
http://api.bugswarm.net/resources/RESOURCE_ID"x-bugswarmapikey: ${API_KEY}","content-type: application/json"Resources belonging to a given user can have some of their information updated after creation. Updating a resource involves passing a JSON object containing the fields that the user wishes to update.
{
"name": "My Resource Updated",
"machine_type": "bug",
"description": "My Resource description updated",
"position": {
"longitude": 1,
"latitude": 1
}
}
Usage: Create a JSON file with
the name update_resource.json and matching the above
format. Then execute:
curl -X PUT -d@update_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/resources/RESOURCE_IDReturns: The updated resource as a JSON object, including a "modified_at" field.
{
"modified_at": "2011-10-10T00:12:58.354Z",
"id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
"user_id": "username",
"description": "My Resource description updated",
"machine_type": "bug",
"name": "My Resource Updated",
"created_at": "2011-10-09T22:58:39.710Z",
"position": {
"longitude": 1,
"latitude": 1
}
}
http://api.bugswarm.net/resources/RESOURCE_ID"x-bugswarmapikey:
${API_KEY}"Destroying a resource removes it completely from the user account and any swarms of which it is a member. The method uses the unique resource id specified in the URL to determine which resource to destroy.
curl -X DELETE --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_IDReturns: HTTP Response Codes
http://api.bugswarm.net/resources"x-bugswarmapikey: ${API_KEY}"List all of the resources belonging to the user.
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resourcesReturns: A list of resources as a JSON array.
[
{
"id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0"
"user_id": "username",
"description": "My Resource description",
"machine_type": "pc",
"name": "My resource",
"created_at": "2011-10-09T22:58:39.710Z",
"position": {
"longitude": 0,
"latitude": 0
}
},
{
"id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
"user_id": "username",
"description": "My Other Resource description",
"machine_type": "bug",
"name": "My other resource",
"created_at": "2011-10-09T22:58:39.710Z",
"position": {
"longitude": 0,
"latitude": 0
}
}
]
http://api.bugswarm.net/resources/RESOURCE_ID"x-bugswarmapikey: ${API_KEY}"This method returns the given resource and its meta-data as a JSON object.
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_IDReturns: A resource as a JSON object.
{
"id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
"user_id": "username",
"description": "My Resource description",
"machine_type": "pc",
"name": "My resource",
"created_at": "2011-10-09T22:58:39.710Z",
"position": {
"longitude": 0,
"latitude": 0
}
}
http://api.bugswarm.net/resources/RESOURCE_ID/swarms"x-bugswarmapikey: ${API_KEY}"Resources can be added to one or many swarms. This method takes a unique resource id and lists all of the swarms of which that resource is a member. A JSON array of the swarm(s) and their resources is printed.
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_ID/swarmsReturns: A list of swarms that the given resource is a member as a JSON array.
[
{
"id": "a16fb1d896817c58d4f4be9dea51e74b86519579",
"user_id": "username",
"description": "My Swarm description",
"name": "My Swarm",
"created_at": "2011-08-29T20:17:08.676Z",
"resources": [
{
"resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
"resource_type": "producer",
"user_id": "username",
"url": "http://api.bugswarm.net/resources/33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0"
},
{
"resource_id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
"resource_type": "both",
"user_id": "username",
"url": "http://api.bugswarm.net/resources/4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9"
}
],
"public": true
},
{
"id": "92236421f64633430baa54fd9848e03aa2696111",
"user_id": "username",
"description": "My Other Swarm description",
"name": "My Other Swarm",
"created_at": "2011-08-29T20:17:08.676Z",
"resources": [
{
"resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
"resource_type": "consumer",
"user_id": "username",
"url": "http://api.bugswarm.net/resources/33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0"
}
],
"public": false
}
]