Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: gh-pages
Fetching contributors…

Cannot retrieve contributors at this time

460 lines (375 sloc) 14.942 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
<title>BUGswarm Developers</title>
<link rel="stylesheet" href="bootstrap/bootstrap.css" type=
"text/css">
<link rel="stylesheet" href="css/this.css" type="text/css">
<link rel="stylesheet" href=
"js/google-code-prettify/prettify.css" type="text/css">
<script src="http://code.jquery.com/jquery-1.5.2.js" type=
"text/javascript">
</script>
<script src="js/google-code-prettify/prettify.js" type=
"text/javascript">
</script>
<script src="js/application.js" type="text/javascript">
</script>
<script src="js/google-analytics.js" type="text/javascript">
</script>
</head>
<body>
<!-- NAVIGATION-->
<div class="topbar">
<div class="topbar-inner">
<div class="container">
<h3><a id="banner" href="index.html" name=
"banner"><img src="images/bs_logo.png"></a></h3>
<ul class="nav">
<li class="dropdown nav-dropdown">
<a href="documentation.html" class=
"dropdown-toggle">Documentation</a>
<ul class="dropdown-menu">
<li><a href=
"configuration_api.html">Configuration</a></li>
<li><a href=
"participation_api.html">Participation</a></li>
</ul>
</li>
<li><a href="tools.html">Tools</a></li>
<li><a href="libraries.html">Libraries</a></li>
<li><a href="tutorial.html">Tutorial</a></li>
<li><a href="applications.html">Applications</a></li>
<li><a href="hardware.html">Hardware</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
</div>
</div><!-- CONTAINER-->
<div class="container">
<!-- Path-->
<div class="page-header">
<a href="index.html">Home</a> &rarr; <a href=
"documentation.html">Documentation</a> &rarr; <a href=
"configuration_api.html">Configuration API</a> &rarr;
Resources
</div><!-- Jump to dropdown-->
<div class="topbar-inner jump-bar">
<div class="nav jump-nav">
<div class="dropdown jump-dropdown">
<a href="documentation.html" class=
"jump-header dropdown-toggle">Jump to</a>
<ul class="dropdown-menu jump-menu">
<li><a href="#create">Create</a></li>
<li><a href="#update">Update</a></li>
<li><a href="#destroy">Destroy</a></li>
<li><a href="#list">List</a></li>
<li><a href="#get-info">Get Info</a></li>
<li><a href="#list-swarms">List Swarms</a></li>
</ul>
</div>
</div>
</div><!-- Header-->
<h1>Resources</h1>
<p>Create and manage your resources.</p>
<div class="page-header"></div><!-- Create-->
<h3 id="create">Create</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources</code></li>
<li><strong>Method:</strong> POST</li>
<li><strong>Headers:</strong><br>
<code>"x-bugswarmapikey: ${API_KEY}"</code>,<br>
<code>"content-type: application/json"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>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 <a href=
"restful_swarms.html#add-resource">add</a> that resource to
the swarm. Creating a resource involves passing a JSON
object containing the resource's meta-data.</p>
</div>
</div><!-- body--><strong>Body:</strong> The "name", and
"machine_type" fields are <strong>required</strong>. The
"description" and "position" fields are
<strong>optional</strong>.
<pre class="prettyprint language-javascript">
{
"name": "My resource",
"machine_type": "pc", # current valid types are "pc", "bug", and "smartphone"
"description": "My Resource description",
"position": {
"longitude": 0,
"latitude": 0
}
}
</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>create_resource.json</code> and matching the above
format. Then execute:
<pre class="prettyprint language-javascript">
curl -X POST -d@create_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/resources
</pre><!-- returns--><strong>Returns:</strong> The created resource
as a JSON object.<br>
<pre class="prettyprint language-javascript">
{
"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
}
}
</pre>
<div class="page-header"></div><!-- Update-->
<h3 id="update">Update</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources/RESOURCE_ID</code></li>
<li><strong>Method:</strong> PUT</li>
<li><strong>Headers:</strong><br>
<code>"x-bugswarmapikey: ${API_KEY}"</code>,<br>
<code>"content-type: application/json"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>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.</p>
</div>
</div><!-- body--><strong>Body:</strong> All fields are
<strong>optional</strong>.
<pre class="prettyprint language-javascript">
{
"name": "My Resource Updated",
"machine_type": "bug",
"description": "My Resource description updated",
"position": {
"longitude": 1,
"latitude": 1
}
}
</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>update_resource.json</code> and matching the above
format. Then execute:
<pre class="prettyprint language-javascript">
curl -X PUT -d@update_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/resources/RESOURCE_ID
</pre><!-- returns--><strong>Returns:</strong> The updated resource
as a JSON object, including a "modified_at" field.<br>
<pre class="prettyprint language-javascript">
{
"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
}
}
</pre>
<div class="page-header"></div><!-- Destroy-->
<h3 id="destroy">Destroy</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources/RESOURCE_ID</code></li>
<li><strong>Method:</strong> DELETE</li>
<li><strong>Headers:</strong> <code>"x-bugswarmapikey:
${API_KEY}"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>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.</p>
</div>
</div><!-- usage--><strong>Usage:</strong>
<pre class="prettyprint language-javascript">
curl -X DELETE --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_ID
</pre><!-- returns--><strong>Returns:</strong> <a href=
"http_response_codes.html">HTTP Response Codes</a><br>
<br>
<div class="page-header"></div><!-- List-->
<h3 id="list">List</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources</code></li>
<li><strong>Method:</strong> GET</li>
<li><strong>Headers:</strong><br>
<code>"x-bugswarmapikey: ${API_KEY}"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>List all of the resources belonging to the user.</p>
</div>
</div><!-- usage--><strong>Usage:</strong>
<pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources
</pre><!-- returns--><strong>Returns:</strong> A list of resources
as a JSON array.
<pre class="prettyprint language-javascript">
[
{
"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
}
}
]
</pre>
<div class="page-header"></div><!-- Get Info-->
<h3 id="get-info">Get Info</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources/RESOURCE_ID</code></li>
<li><strong>Method:</strong> GET</li>
<li><strong>Headers:</strong><br>
<code>"x-bugswarmapikey: ${API_KEY}"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>This method returns the given resource and its meta-data
as a JSON object.</p>
</div>
</div><!-- usage--><strong>Usage:</strong>
<pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_ID
</pre><!-- returns--><strong>Returns:</strong> A resource as a JSON
object.
<pre class="prettyprint language-javascript">
{
"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
}
}
</pre>
<div class="page-header"></div><!-- List Swarms-->
<h3 id="list-swarms">List Swarms</h3><!-- description-->
<div class="row">
<div class="span8 columns">
<ul class="unstyled">
<li><strong>URL:</strong>
<code>http://api.bugswarm.net/resources/RESOURCE_ID/swarms</code></li>
<li><strong>Method:</strong> GET</li>
<li><strong>Headers:</strong><br>
<code>"x-bugswarmapikey: ${API_KEY}"</code></li>
<li><strong>Parameters (Required):</strong> None</li>
<li><strong>Parameters (Optional):</strong> None</li>
</ul>
</div>
<div class="span8 columns">
<p>Resources can be <a href=
"restful_swarms.html#add-resource">added</a> 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.</p>
</div>
</div><!-- usage--><strong>Usage:</strong>
<pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/resources/RESOURCE_ID/swarms
</pre><!-- returns--><strong>Returns:</strong> A list of swarms
that the given resource is a member as a JSON array.
<pre class="prettyprint language-javascript">
[
{
"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
}
]
</pre>
<div class="page-header"></div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.