rest.rst 15.7 KB
Newer Older
1 2 3
SlapOS Master REST API (v1)
***************************

Łukasz Nowak's avatar
Łukasz Nowak committed
4 5
Authentication
--------------
6

Łukasz Nowak's avatar
Łukasz Nowak committed
7 8 9 10 11 12 13
In order to authenticate into API X509 key/certificate can be used. It is
possible to obtain them from SlapOS Master, like https:///www.vifib.net

As API is going to be used in environments which support TLS communication
channel, but do not, or support is cumbersome, support X509 keys OAuth-2 will
be proposed by library.

14 15
Internal authentication
+++++++++++++++++++++++
Łukasz Nowak's avatar
Łukasz Nowak committed
16

Łukasz Nowak's avatar
Łukasz Nowak committed
17 18
**Note**: This authentication mechanism will change. Avoid implementation for now.

Łukasz Nowak's avatar
Łukasz Nowak committed
19 20 21 22
In case if client of API does not fulfill X509 authentication it has a chance
to use token based authentication (after obtaining proper token).

Client application HAVE TO use ``"Authorization"`` header, even if OAuth-2
Łukasz Nowak's avatar
Łukasz Nowak committed
23
allows other ways (like having token in GET parameter or as form one).
Łukasz Nowak's avatar
Łukasz Nowak committed
24
They were not implemented as begin fragile from security point of view.
Łukasz Nowak's avatar
Łukasz Nowak committed
25 26 27

Example of using Bearer token::

28
  GET /api/v1/instance/{instance_id} HTTP/1.1
Łukasz Nowak's avatar
Łukasz Nowak committed
29 30 31
  Host: example.com
  Accept: application/json
  Authorization: Bearer 7Fjfp0ZBr1KtDRbnfVdmIw
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

Facebook authentication
+++++++++++++++++++++++

It is possible to use Facebook as Authorisation Server in Oauth 2.0
architecture. Client shall fetch `access_token` as described in
https://developers.facebook.com/docs/authentication/client-side/ and later use
it as in specially crafted `Authorization` header::

  GET /api/v1/instance/{instance_id} HTTP/1.1
  Host: example.com
  Accept: application/json
  Authorization: Facebook access_token_from_facebook

The client is responsible for having its own Facebook application ID and
configure it that user basic information and email will be available after
using `access_token`, for example by fetching token after query like::

  https://www.facebook.com/dialog/oauth?client_id=FB_ID&response_type=token&redirect_uri=APP_URL&scope=email

Server will contact with Facebook and use the logged in user profile. Facebook
is trusted by server.

56 57 58 59 60
Exchange format
---------------

SlapOS master will support both XML and JSON formats for input and output.

Łukasz Nowak's avatar
Łukasz Nowak committed
61
The Accept header is required and responsible for format selection.
62 63 64 65 66 67 68

Response status code
--------------------

Success
+++++++

Łukasz Nowak's avatar
Łukasz Nowak committed
69 70 71 72
``GET`` requests will return a ``"200 OK"`` response if the resource is
successfully retrieved. In case if client will set ``"If-Midified-Since"``
header the response could be ``"304 Not Modified"``. Also ``GET`` will return
``"Last-Modified"`` headers.
73

Łukasz Nowak's avatar
Łukasz Nowak committed
74 75
``POST`` requests which create a resource we will return a ``"201 Created"``
response if successful.
76 77 78 79

``POST`` requests which perform some other action such as sending a campaign
will return a ``"200 OK"`` response if successful.

Łukasz Nowak's avatar
Łukasz Nowak committed
80 81 82
``PUT`` requests will return a ``"200 OK"`` response if the resource is
successfully updated and ``"204 No Content"`` in case if no modification was
applied..
83

Łukasz Nowak's avatar
Łukasz Nowak committed
84 85
``OPTIONS`` requests will return ``"204 No Content"`` response with headers
informing about possible method usage.
Łukasz Nowak's avatar
Łukasz Nowak committed
86

Łukasz Nowak's avatar
Łukasz Nowak committed
87 88 89 90 91 92 93 94 95 96 97
``"202 Accepted"`` with json response with status can be returned in order to
indicate that request was correct, but some asynchronous opertions are disallow
to finish it, for example user being in creation process::

  HTTP/1.1 202 Accepted
  Content-Type: application/json; charset=utf-8

  {
    "status": "User under creation."
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
98 99
Common Error Responses
++++++++++++++++++++++
100

Łukasz Nowak's avatar
Łukasz Nowak committed
101 102
400 Bad Request
~~~~~~~~~~~~~~~
Łukasz Nowak's avatar
Łukasz Nowak committed
103 104
The request body does not follow the API (one argument is missing or
malformed). The full information is available as text body::
105

Łukasz Nowak's avatar
Łukasz Nowak committed
106
  HTTP/1.1 400 Bad Request
Łukasz Nowak's avatar
Łukasz Nowak committed
107
  Content-Type: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
108 109 110 111 112

  {
    "computer_id": "Parameter is missing"
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
113 114 115 116 117 118 119 120 121 122 123 124
401 Unauthorized
~~~~~~~~~~~~~~~~

The request is not authorised. The response will contain location to a server
which is capable to provide access credentials.

For servers using Bearer token authentication::

  HTTP/1.1 401 Unauthorized
  WWW-Authenticate: Bearer realm="example.com"
  Location: https://authserv.example.com/path-to-auth

Łukasz Nowak's avatar
Łukasz Nowak committed
125 126
402 Payment Required
~~~~~~~~~~~~~~~~~~~~
127

Łukasz Nowak's avatar
Łukasz Nowak committed
128
The request can not be fulfilled because account is locked.
129

Łukasz Nowak's avatar
Łukasz Nowak committed
130 131 132 133 134 135 136
404 Not Found
~~~~~~~~~~~~~
Request to non existing resource made.

500 Internal Server Error
~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected error.
137

Łukasz Nowak's avatar
Łukasz Nowak committed
138 139 140 141 142 143
Introsepcation Methods
**********************

Fetching list of access urls
----------------------------

Łukasz Nowak's avatar
Łukasz Nowak committed
144
Explain access points in dictionary.
Łukasz Nowak's avatar
Łukasz Nowak committed
145 146 147 148 149 150 151 152 153 154 155

Client is expected to ask about connection points before doing any request.

In case if required mapping is defined on client side, but server does not
expose this information, it means, that such capability is not available on
server side and should not be used.

In case if client does not support exposed mapping it is allowed to ignore
them.

Client shall be aware that one API can be spanned across many servers and that
Łukasz Nowak's avatar
Łukasz Nowak committed
156
all urls are given as absolute ones.
Łukasz Nowak's avatar
Łukasz Nowak committed
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

Endpoint to invoke required action is in ``url`` object, where values in
``{}`` shall be replaced with corresponding access urls. For example
``instance_url`` shall be replaced with obtained URL of instance (by request
or list).

``method`` is required method on URL.

All required parameters, if any, are in ``required`` object.

All optional understandable parameters, if any, are in ``optional`` object.

In case if access point requires authentication, then ``authentication`` will be set to ``true``.

`Request`::

  GET / HTTP/1.1
  Host: example.com
  Accept: application/json

`No Expected Request Body`

Extract of possible response::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8

  {
Łukasz Nowak's avatar
Łukasz Nowak committed
185 186 187 188 189 190
    "instance_bang": {
      "authentication": true,
      "url": "{instance_url}/bang",
      "method": "POST",
      "required": {
        "log": "unicode"
Łukasz Nowak's avatar
Łukasz Nowak committed
191
      },
Łukasz Nowak's avatar
Łukasz Nowak committed
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
      "optional": {}
    },
    "instance_list": {
      "authentication": true,
      "url": "http://three.example.com/instance",
      "method": "GET",
      "required": {},
      "optional": {}
    },
    "register_computer": {
      "authentication": true,
      "url": "http://two.example.com/computer",
      "method": "POST",
      "required": {
        "title": "unicode"
Łukasz Nowak's avatar
Łukasz Nowak committed
207
      },
Łukasz Nowak's avatar
Łukasz Nowak committed
208 209 210 211 212 213 214 215 216 217 218 219 220
    },
    "request_instance": {
      "authentication": true,
      "url": "http://one.example.com/instance",
      "method": "POST",
      "required": {
         "status": "unicode",
         "slave": "bool",
         "title": "unicode",
         "software_release": "unicode",
         "software_type": "unicode",
         "parameter": "object",
         "sla": "object"
Łukasz Nowak's avatar
Łukasz Nowak committed
221
      },
Łukasz Nowak's avatar
Łukasz Nowak committed
222 223
      "optional": {}
    }
Łukasz Nowak's avatar
Łukasz Nowak committed
224 225 226 227 228
  }

All documentation here will refer to named access points except otherwise
stated. The access point will appear in ``[]`` after method name.

229 230 231
Instance Methods
****************

232 233 234 235 236 237 238
Fetching list of instances
--------------------------

Ask for list of instances.

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
239
  GET [instance_list] HTTP/1.1
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
  Host: example.com
  Accept: application/json

`No Expected Request Body`

`Expected Response`::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8

  {
    "list": ["http://one.example.com/one", "http://two.example.com/something"]
  }

`Additional Responses`::

  HTTP/1.1 204 No Content

In case where not instances are available.

260 261 262
Requesting a new instance
-------------------------

Łukasz Nowak's avatar
Łukasz Nowak committed
263
Request a new instantiation of a software.
264 265 266

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
267
  POST [request_instance] HTTP/1.1
268
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
269
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
270
  Content-Type: application/json; charset=utf-8
271 272 273 274

`Expected Request Body`::

  {
Łukasz Nowak's avatar
Łukasz Nowak committed
275 276
    "status": "started",
    "slave": false,
277 278 279 280 281 282
    "title": "My unique instance",
    "software_release": "http://example.com/example.cfg",
    "software_type": "type_provided_by_the_software",
    "parameter": {
      "Custom1": "one string",
      "Custom2": "one float",
Łukasz Nowak's avatar
Łukasz Nowak committed
283 284 285 286 287
      "Custom3": [
        "abc",
        "def"
      ]
    },
288
    "sla": {
Łukasz Nowak's avatar
Łukasz Nowak committed
289 290
      "computer_id": "COMP-0"
    }
291 292 293 294 295 296
  }

`Expected Response`::

  HTTP/1.1 201 Created
  Content-Type: application/json; charset=utf-8
297
  Location: http://maybeother.example.com/some/url/instance_id
298 299 300 301 302 303 304 305 306

  {
    "status": "started",
    "connection": {
      "custom_connection_parameter_1": "foo",
      "custom_connection_parameter_2": "bar"
    }
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
307
`Additional Responses`::
308

Łukasz Nowak's avatar
Łukasz Nowak committed
309 310
  HTTP/1.1 202 Accepted
  Content-Type: application/json; charset=utf-8
311

Łukasz Nowak's avatar
Łukasz Nowak committed
312 313 314
  {
    "status": "processing"
  }
315

Łukasz Nowak's avatar
Łukasz Nowak committed
316
The request has been accepted for processing
317

Łukasz Nowak's avatar
Łukasz Nowak committed
318 319
`Error Responses`:

Łukasz Nowak's avatar
Łukasz Nowak committed
320 321 322
* ``409 Conflict`` The request can not be process because of the current
  status of the instance (sla changed, instance is under deletion, software
  release can not be changed, ...).
323 324 325 326 327


Get instance information
------------------------

Łukasz Nowak's avatar
Łukasz Nowak committed
328
Request all instance information.
329 330 331

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
332
  GET [instance_info] HTTP/1.1
333
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
334
  Accept: application/json
335 336 337 338 339 340 341 342 343 344 345

`Route values`:

* ``instance_id``: the ID of the instance

`No Expected Request Body`

`Expected Response`::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8
Łukasz Nowak's avatar
Łukasz Nowak committed
346

347
  {
Łukasz Nowak's avatar
Łukasz Nowak committed
348
    "title": "The Instance Title",
Łukasz Nowak's avatar
Łukasz Nowak committed
349
    "status": "start", # one of: start, stop, destroy
350 351
    "software_release": "http://example.com/example.cfg",
    "software_type": "type_provided_by_the_software",
Łukasz Nowak's avatar
Łukasz Nowak committed
352
    "slave": False, # one of: True, False
353 354 355 356 357 358 359 360 361 362 363 364 365 366
    "connection": {
      "custom_connection_parameter_1": "foo",
      "custom_connection_parameter_2": "bar"
    },
    "parameter": {
      "Custom1": "one string",
      "Custom2": "one float",
      "Custom3": ["abc", "def"],
      },
    "sla": {
      "computer_id": "COMP-0",
      }
    "children_id_list": ["subinstance1", "subinstance2"],
    "partition": {
Łukasz Nowak's avatar
Łukasz Nowak committed
367 368
      "public_ip": ["::1", "91.121.63.94"],
      "private_ip": ["127.0.0.1"],
369 370 371 372 373 374
      "tap_interface": "tap2",
    },
  }

`Error Responses`:

Łukasz Nowak's avatar
Łukasz Nowak committed
375 376
* ``409 Conflict`` The request can not be process because of the current
  status of the instance
377

Łukasz Nowak's avatar
Łukasz Nowak committed
378 379
Get instance authentication certificates
----------------------------------------
380 381 382 383 384

Request the instance certificates.

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
385
  GET [instance_certificate] HTTP/1.1
386
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
387
  Accept: application/json
388 389 390 391 392 393 394 395 396 397 398

`Route values`:

* ``instance_id``: the ID of the instance

`No Expected Request Body`

`Expected Response`::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8
Łukasz Nowak's avatar
Łukasz Nowak committed
399

400
  {
Łukasz Nowak's avatar
Łukasz Nowak committed
401 402
    "ssl_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADAN...h2VSZRlSN\n-----END PRIVATE KEY-----",
    "ssl_certificate": "-----BEGIN CERTIFICATE-----\nMIIEAzCCAuugAwIBAgICHQI...ulYdXJabLOeCOA=\n-----END CERTIFICATE-----",
403 404 405 406
  }

`Error Responses`:

Łukasz Nowak's avatar
Łukasz Nowak committed
407 408
* ``409 Conflict`` The request can not be process because of the current
  status of the instance
409 410 411 412

Bang instance
-------------

Łukasz Nowak's avatar
Łukasz Nowak committed
413
Trigger the re-instantiation of all partitions in the instance tree
414 415 416

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
417
  POST [instance_bang] HTTP/1.1
418
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
419
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
420
  Content-Type: application/json; charset=utf-8
421 422 423 424 425 426 427 428 429 430 431 432 433

`Route values`:

* ``instance_id``: the ID of the instance

`Expected Request Body`::

  {
    "log": "Explain why this method was called",
  }

`Expected Response`::

434
  HTTP/1.1 204 No Content
435

Łukasz Nowak's avatar
Łukasz Nowak committed
436 437
Modifying instance
------------------
438

Łukasz Nowak's avatar
Łukasz Nowak committed
439
Modify the instance information and status.
440 441 442

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
443
  PUT [instance_edit] HTTP/1.1
444
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
445
  Accept: application/json
446 447 448 449 450
  Content-Type: application/json; charset=utf-8

`Expected Request Body`::

  {
Łukasz Nowak's avatar
Łukasz Nowak committed
451
    "title": "The New Instance Title",
452 453 454
    "connection": {
      "custom_connection_parameter_1": "foo",
      "custom_connection_parameter_2": "bar"
Łukasz Nowak's avatar
Łukasz Nowak committed
455
    }
456 457
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
458
Where `connection` and `title` are optional.
Łukasz Nowak's avatar
Łukasz Nowak committed
459 460

Setting different.
Łukasz Nowak's avatar
Łukasz Nowak committed
461

462 463 464
`Expected Response`::

  HTTP/1.1 200 OK
Łukasz Nowak's avatar
Łukasz Nowak committed
465
  Content-Type: application/json; charset=utf-8
466

Łukasz Nowak's avatar
Łukasz Nowak committed
467
  {
Łukasz Nowak's avatar
Łukasz Nowak committed
468 469
    "connection": "Modified",
    "title": "Modified."
Łukasz Nowak's avatar
Łukasz Nowak committed
470 471 472 473 474 475 476 477
  }

`Additional Responses`::

  HTTP/1.1 204 No Content

When nothing was modified.

478 479
`Error Responses`:

Łukasz Nowak's avatar
Łukasz Nowak committed
480 481 482
* ``409 Conflict`` The request can not be process because of the current
  status of the instance (sla changed, instance is under deletion,
  software release can not be changed, ...).
483 484 485 486 487 488 489 490 491 492 493

Computer Methods
****************

Registering a new computer
--------------------------

Add a new computer in the system.

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
494
  POST [register_computer] HTTP/1.1
495
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
496
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
497
  Content-Type: application/json; charset=utf-8
498 499 500 501 502 503 504 505 506 507 508

`Expected Request Body`::

  {
    "title": "My unique computer",
  }

`Expected Response`::

  HTTP/1.1 201 Created
  Content-Type: application/json; charset=utf-8
509
  Location: http://maybeother.example.com/some/url/computer_id-0
Łukasz Nowak's avatar
Łukasz Nowak committed
510

511
  {
Łukasz Nowak's avatar
Łukasz Nowak committed
512 513
    "ssl_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADAN...h2VSZRlSN\n-----END PRIVATE KEY-----",
    "ssl_certificate": "-----BEGIN CERTIFICATE-----\nMIIEAzCCAuugAwIBAgICHQI...ulYdXJabLOeCOA=\n-----END CERTIFICATE-----",
514 515 516 517
  }

`Error Responses`:

Łukasz Nowak's avatar
Łukasz Nowak committed
518 519
* ``409 Conflict`` The request can not be process because of the existence of
  a computer with the same title
520 521 522 523 524 525 526 527

Getting computer information
----------------------------

Get the status of a computer

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
528
  GET [computer_info] HTTP/1.1
529
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
530
  Accept: application/json
531 532 533

`Route values`:

Łukasz Nowak's avatar
Łukasz Nowak committed
534
* ``computer_id``: the ID of the computer
535 536 537 538 539 540 541

`No Expected Request Body`

`Expected Response`::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8
Łukasz Nowak's avatar
Łukasz Nowak committed
542

543 544 545 546
  {
    "computer_id": "COMP-0",
    "software": [
      {
Łukasz Nowak's avatar
Łukasz Nowak committed
547 548
        "software_release": "http://example.com/example.cfg",
        "status": "install" # one of: install, uninstall
549 550 551 552
      },
    ],
    "partition": [
      {
Łukasz Nowak's avatar
Łukasz Nowak committed
553 554 555 556
        "title": "slapart1",
        "instance_id": "foo",
        "status": "start", # one of: start, stop, destroy
        "software_release": "http://example.com/example.cfg"
557 558
      },
      {
Łukasz Nowak's avatar
Łukasz Nowak committed
559 560 561 562
        "title": "slapart2",
        "instance_id": "bar",
        "status": "stop", # one of: start, stop, destroy
        "software_release": "http://example.com/example.cfg"
563 564 565 566
      },
    ],
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
567 568
Modifying computer
------------------
569

Łukasz Nowak's avatar
Łukasz Nowak committed
570
Modify computer information in the system
571 572 573

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
574
  PUT [computer_edit] HTTP/1.1
575
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
576
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
577
  Content-Type: application/json; charset=utf-8
578 579 580

`Route values`:

Łukasz Nowak's avatar
Łukasz Nowak committed
581
* ``computer_id``: the ID of the computer
582 583 584 585 586 587 588 589 590 591 592 593

`Expected Request Body`::

  {
    "partition": [
      {
        "title": "part1",
        "public_ip": "::1",
        "private_ip": "127.0.0.1",
        "tap_interface": "tap2",
      },
    ],
Łukasz Nowak's avatar
Łukasz Nowak committed
594 595
    "software": [
      {
Łukasz Nowak's avatar
Łukasz Nowak committed
596 597 598
        "software_release": "http://example.com/example.cfg",
        "status": "installed", # one of: installed, uninstalled, error
        "log": "Installation log"
Łukasz Nowak's avatar
Łukasz Nowak committed
599 600
      },
    ],
601 602
  }

Łukasz Nowak's avatar
Łukasz Nowak committed
603 604
Where ``partition`` and ``software`` keys are optional, but at least one is
required.
Łukasz Nowak's avatar
Łukasz Nowak committed
605

606 607
`Expected Response`::

Łukasz Nowak's avatar
Łukasz Nowak committed
608
  HTTP/1.1 204 No Content
609 610 611 612

Supplying new software
----------------------

Łukasz Nowak's avatar
Łukasz Nowak committed
613
Request to supply a new software release on a computer
614 615 616

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
617
  POST [computer_supply] HTTP/1.1
618
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
619
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
620
  Content-Type: application/json; charset=utf-8
621 622 623

`Route values`:

Łukasz Nowak's avatar
Łukasz Nowak committed
624
* ``computer_id``: the ID of the computer
625 626 627 628

`Expected Request Body`::

  {
Łukasz Nowak's avatar
Łukasz Nowak committed
629
    "software_release": "http://example.com/example.cfg"
630 631 632 633 634 635 636 637 638 639 640 641 642 643
  }

`Expected Response`::

  HTTP/1.1 200 OK
  Content-Type: application/json; charset=utf-8

Bang computer
-------------

Request update on all partitions

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
644
  POST [computer_bang] HTTP/1.1
645
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
646
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
647
  Content-Type: application/json; charset=utf-8
648 649 650

`Route values`:

Łukasz Nowak's avatar
Łukasz Nowak committed
651
* ``computer_id``: the ID of the computer
652 653 654 655 656 657 658 659 660

`Expected Request Body`::

  {
    "log": "Explain why this method was called",
  }

`Expected Response`::

661
  HTTP/1.1 204 No Content
662 663 664 665 666 667 668 669

Report usage
------------

Report computer usage

`Request`::

Łukasz Nowak's avatar
Łukasz Nowak committed
670
  POST [computer_report] HTTP/1.1
671
  Host: example.com
Łukasz Nowak's avatar
Łukasz Nowak committed
672
  Accept: application/json
Łukasz Nowak's avatar
Łukasz Nowak committed
673
  Content-Type: application/json; charset=utf-8
674 675 676

`Route values`:

Łukasz Nowak's avatar
Łukasz Nowak committed
677
* ``computer_id``: the ID of the computer
678 679 680 681

`Expected Request Body`::

  {
Łukasz Nowak's avatar
Łukasz Nowak committed
682 683 684 685 686 687 688 689 690 691 692
    "title": "Resource consumptions",
    "start_date": "2011/11/15",
    "stop_date": "2011/11/16",
    "movement": [
      {
        "resource": "CPU Consumption",
        "title": "line 1",
        "reference": "slappart0",
        "quantity": 42.42
      }
    ]
693 694 695 696 697
  }

`Expected Response`::

  HTTP/1.1 200 OK
Łukasz Nowak's avatar
Łukasz Nowak committed
698
  Content-Type: application/json; charset=utf-8