Skip to content
This repository
tree: 928975a8ac
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 582 lines (475 sloc) 20.802 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
<!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; Swarms
    </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="#add-resource">Add Resource</a></li>

            <li><a href="#remove-resource">Remove Resource</a></li>

            <li><a href="#list-resources">List Resources</a></li>
          </ul>
        </div>
      </div>
    </div><!-- Header-->

    <h1>Swarms</h1>

    <p>Create and manage your swarms.</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/swarms</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>Create a swarm by passing a JSON object representing the
        swarm to create. After creation, you may <a href=
        "restful_swarms.html#add-resource">add</a> resources to the
        swarm. Additionally, users may specify any of their own
        resources to add to the swarm by default upon creation.
        This is configured in the JSON object that gets passed.</p>
      </div>
    </div><!-- body--><strong>Body:</strong> The "name" and
    "description" fields are <strong>required</strong>. The
    "public" and "resources" fields are <strong>optional</strong>.
    The "public" field defaults to <strong>false</strong> if not
    specified.
    <pre class="prettyprint language-javascript">
{
    "name": "My Other Swarm",
    "description": "My Other Swarm Description",
    "public": false,
    "resources": [
        { "resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
          "resource_type": "consumer"
        }
    ]
}

</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>create_swarm.json</code> and matching the above
format. Then execute:
    <pre class="prettyprint language-javascript">
curl -X POST -d@create_swarm.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/swarms

</pre><!-- returns--><strong>Returns:</strong> The created swarm
and its configuration as a JSON object. The "resources" field will
exist as an empty array if no resources are given upon creation.
    <pre class="prettyprint language-javascript">
{
    "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><!-- 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/swarms/SWARM_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>Update a swarm by passing a JSON object containing the
        fields that the you wish to update.</p>
      </div>
    </div><!-- body--><strong>Body:</strong> All fields are
    <strong>optional</strong>.
    <pre class="prettyprint language-javascript">
{
    "name": "My Other Swarm updated",
    "description": "My Other Swarm description updated",
    "public": true
}

</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>update_swarm.json</code> and matching the above
format. Then execute:
    <pre class="prettyprint language-javascript">
curl -X PUT -d@update_swarm.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/swarms/SWARM_ID

</pre><!-- returns--><strong>Returns:</strong> The updated swarm as
a JSON object, including a "modified_at" field.
    <pre class="prettyprint language-javascript">
{
    "description": "My Other Swarm description updated",
    "modified_at": "2011-10-10T01:08:54.688Z",
    "id": "92236421f64633430baa54fd9848e03aa2696111",
    "name": "My Other Swarm"
    "user_id": "username",
    "created_at": "2011-08-29T20:17:08.676Z",
    "resources": [
        {
            "resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
            "resource_type": "consumer",
            "swarm_id": "92236421f64633430baa54fd9848e03aa2696111",
            "user_id": "username",
            "url": "http://api.bugswarm.net/resources/33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
            "member_since": "2011-10-10T01:01:55.184Z"
        }
    ],
    "public": true
}
</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/swarms/SWARM_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>Destroy a swarm. Destroying a swarm removes it
        completely from the user account. The method uses the
        unique swarm id specified in the URL to determine which
        swarm 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/swarms/SWARM_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/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> Resource
          type</li>
        </ul>
      </div>

      <div class="span8 columns">
        <p>List all of the swarms owned by the user. Each listed
        swarm will also contain the resources that are a member of
        that swarm.</p>
      </div>
    </div><!-- usage--><strong>Usage:</strong>
    <pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/swarms

</pre><!-- returns--><strong>Returns:</strong> A list of swarms 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",
                "member_since": "2011-10-10T01:01:55.184Z"
            },
            {
                "resource_id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
                "resource_type": "both",
                "user_id": "username",
                "url": "http://api.bugswarm.net/resources/4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
                "member_since": "2011-10-10T01:01:55.184Z"
            }
        ],
        "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",
                "member_since": "2011-10-10T01:01:55.184Z"
            }
        ],
        "public": false
    }
]

</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/swarms/SWARM_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 retrieves the information for a given swarm.
        The id of the swarm to retrieve the information from is
        given in the URL.</p>
      </div>
    </div><!-- usage--><strong>Usage:</strong>
    <pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/swarms/SWARM_ID

</pre><!-- returns--><strong>Returns:</strong> A swarm as a JSON
object.
    <pre class="prettyprint language-javascript">
{
    "description": "My Other Swarm description",
    "id": "92236421f64633430baa54fd9848e03aa2696111",
    "modified_at": "2011-10-10T01:08:54.688Z",
    "name": "My Other Swarm"
    "user_id": "username",
    "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",
            "member_since": "2011-10-10T01:01:55.184Z"
        }
    ],
    "public": true
}

</pre>

    <div class="page-header"></div><!-- Add Resource-->

    <h3 id="add-resource">Add Resource</h3><!-- description-->

    <div class="row">
      <div class="span8 columns">
        <ul class="unstyled">
          <li><strong>URL:</strong>
          <code>http://api.bugswarm.net/swarms/SWARM_ID/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>Each swarm is owned by a given user and can be
        configured to contain resources. Swarms can contain the
        resources of many members. This method adds a resource to a
        given swarm. The method passes a JSON file containing the
        swarm-relevant information regarding the resource to add.
        The "type" field passed in the JSON refers to whether the
        resource will act as a producer or a consumer. This method
        can only be used to add your resources to a swarm that you
        own. To add another member's resource(s) to your swarm or
        to join another member's swarm with your resources, please
        see the <a href="restfu_invitations.html">invitations</a>
        section of the API documentation.</p>
      </div>
    </div><!-- body --><strong>Body:</strong> A JSON file
    containing the information of the resource to add that is
    relevant to the context of a swarm.
    <pre class="prettyprint language-javascript">
{
    "resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
    "resource_type": "consumer"
}

</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>add_resource.json</code> and matching the above
format. Then execute:
    <pre class="prettyprint language-javascript">
curl -X POST -d@add_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/swarms/SWARM_ID/resources

</pre><!-- returns--><strong>Returns:</strong> <a href=
"http_response_codes.html">HTTP Response Codes</a><br>
    <br>

    <div class="page-header"></div><!-- Remove Resource-->

    <h3 id="remove-resource">Remove Resource</h3>
    <!-- description-->

    <div class="row">
      <div class="span8 columns">
        <ul class="unstyled">
          <li><strong>URL:</strong>
          <code>http://api.bugswarm.net/swarms/SWARM_ID/resources</code></li>

          <li><strong>Method:</strong> DELETE</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>Each swarm is owned by a given user and can be
        configured to contain resources. Swarms can contain the
        resources of many members. This method removes a resource
        from a given swarm. The method passes a JSON file
        containing the information regarding the resource to
        remove. Removing a resource from a swarm does not remove it
        from the user account. To perform this action, use the
        <a href="restful_user_resources.html#destroy">Destroy</a>
        method for user resources.</p>
      </div>
    </div><!-- body--><strong>Body:</strong> A JSON file containing
    the information of the resource to remove from the swarm.
    <pre class="prettyprint language-javascript">
{
    "resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
    "resource_type": "consumer"
}

</pre><!-- usage--><strong>Usage:</strong> Create a JSON file with
the name <code>remove_resource.json</code> and matching the above
format. Then execute:
    <pre class="prettyprint language-javascript">
curl -X DELETE -d@remove_resource.json --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" --header "content-type: application/json" http://api.bugswarm.net/swarms/SWARM_ID/resources

</pre><!-- returns--><strong>Returns:</strong> <a href=
"http_response_codes.html">HTTP Response Codes</a><br>
    <br>

    <div class="page-header"></div><!-- List Resources-->

    <h3 id="list-resources">List Resources</h3><!-- description-->

    <div class="row">
      <div class="span8 columns">
        <ul class="unstyled">
          <li><strong>URL:</strong>
          <code>http://api.bugswarm.net/swarms/SWARM_ID/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> Resource
          type</li>
        </ul>
      </div>

      <div class="span8 columns">
        <p>Users may list the resources that are members of a given
        swarm. The list will print each resource and its
        swarm-relevant information in JSON format.</p>
      </div>
    </div><!-- usage--><strong>Usage:</strong>
    <pre class="prettyprint language-javascript">
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/swarms/SWARM_ID/resources
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/swarms/SWARM_ID/resources?type=producer
curl -X GET --header "x-bugswarmapikey: 911cbc244827dba9c6dbdd09aff3e5e8fe5eee02" http://api.bugswarm.net/swarms/SWARM_ID/resources?type=consumer

</pre><!-- returns --><strong>Returns:</strong> A list of resources
as as JSON array.
    <pre class="prettyprint language-javascript">
[
    {
        "resource_id": "33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
        "resource_type": "producer",
        "swarm_id": "a16fb1d896817c58d4f4be9dea51e74b86519579",
        "user_id": "username",
        "url": "http://api.dev.bugswarm.net/resources/33e675f7888c1d7f6f5da41bcccdff7b67f6c9a0",
        "member_since": "2011-10-10T01:01:55.184Z"
    },
    {
        "resource_id": "4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
        "resource_type": "consumer",
        "swarm_id": "a16fb1d896817c58d4f4be9dea51e74b86519579",
        "user_id": "username",
        "url": "http://api.dev.bugswarm.net/resources/4735f4417f4fd2eb67ace9f2d2e7948e2d9f43f9",
        "member_since": "2011-10-10T02:13:08.537Z"
    }
]

</pre>

    <div class="page-header"></div>
  </div>
</body>
</html>
Something went wrong with that request. Please try again.