github.com/misfo/deis@v1.0.1-0.20141111224634-e0eee0392b8a/docs/reference/api-v1.rst (about)

     1  :title: Controller API v1.0
     2  :description: The v1 REST API for Deis' Controller
     3  
     4  .. _controller_api_v1:
     5  
     6  Controller API v1.0
     7  ===================
     8  
     9  This is the v1.0 REST API for the :ref:`Controller`.
    10  
    11  
    12  Authentication
    13  --------------
    14  
    15  
    16  Register a New User
    17  ```````````````````
    18  
    19  Example Request:
    20  
    21  .. code-block:: console
    22  
    23      POST /v1/auth/register/ HTTP/1.1
    24      Host: deis.example.com
    25      Content-Type: application/json
    26  
    27      {
    28          "username": "test",
    29          "password": "opensesame"
    30      }
    31  
    32  Optional Parameters:
    33  
    34  .. code-block:: console
    35  
    36      {
    37          "email": "test@example.com",
    38          "first_name": "test",
    39          "last_name": "testerson"
    40      }
    41  
    42  Example Response:
    43  
    44  .. code-block:: console
    45  
    46  
    47      HTTP/1.1 201 CREATED
    48      Content-Type: application/json
    49  
    50      {
    51          "id": 1,
    52          "last_login": "2014-10-19T22:01:00.601Z",
    53          "is_superuser": true,
    54          "username": "test",
    55          "first_name": "test",
    56          "last_name": "testerson",
    57          "email": "test@example.com",
    58          "is_staff": true,
    59          "is_active": true,
    60          "date_joined": "2014-10-19T22:01:00.601Z",
    61          "groups": [],
    62          "user_permissions": []
    63      }
    64  
    65  
    66  Log in
    67  ``````
    68  
    69  Example Request:
    70  
    71  .. code-block:: console
    72  
    73      POST /v1/auth/login/ HTTP/1.1
    74      Host: deis.example.com
    75      Content-Type: application/json
    76  
    77      {"username": "test", "password": "opensesame"}
    78  
    79  Example Response:
    80  
    81  .. code-block:: console
    82  
    83      HTTP/1.1 200 OK
    84      Content-Type: application/json
    85  
    86      {"token": "abc123"}
    87  
    88  
    89  Cancel Account
    90  ``````````````
    91  
    92  Example Request:
    93  
    94  .. code-block:: console
    95  
    96      DELETE /v1/auth/cancel/ HTTP/1.1
    97      Host: deis.example.com
    98      Authorization: token abc123
    99  
   100  Example Response:
   101  
   102  .. code-block:: console
   103  
   104      HTTP/1.1 204 NO CONTENT
   105  
   106  
   107  Applications
   108  ------------
   109  
   110  
   111  List all Applications
   112  `````````````````````
   113  
   114  Example Request:
   115  
   116  .. code-block:: console
   117  
   118      GET /v1/apps HTTP/1.1
   119      Host: deis.example.com
   120      Authorization: token abc123
   121  
   122  Example Response:
   123  
   124  .. code-block:: console
   125  
   126      HTTP/1.1 200 OK
   127      Content-Type: application/json
   128  
   129      {
   130          "count": 1,
   131          "next": null,
   132          "previous": null,
   133          "results": [
   134              {
   135                  "created": "2014-01-01T00:00:00UTC",
   136                  "id": "example-go",
   137                  "owner": "test",
   138                  "structure": {},
   139                  "updated": "2014-01-01T00:00:00UTC",
   140                  "url": "example-go.example.com",
   141                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   142              }
   143          ]
   144      }
   145  
   146  
   147  Create an Application
   148  `````````````````````
   149  
   150  Example Request:
   151  
   152  .. code-block:: console
   153  
   154      POST /v1/apps/ HTTP/1.1
   155      Host: deis.example.com
   156      Content-Type: application/json
   157      Authorization: token abc123
   158  
   159  Optional parameters:
   160  
   161  .. code-block:: console
   162  
   163      {"id": "example-go"}
   164  
   165  
   166  Example Response:
   167  
   168  .. code-block:: console
   169  
   170      HTTP/1.1 201 CREATED
   171      Content-Type: application/json
   172  
   173      {
   174          "created": "2014-01-01T00:00:00UTC",
   175          "id": "example-go",
   176          "owner": "test",
   177          "structure": {},
   178          "updated": "2014-01-01T00:00:00UTC",
   179          "url": "example-go.example.com",
   180          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   181      }
   182  
   183  
   184  Destroy an Application
   185  ``````````````````````
   186  
   187  Example Request:
   188  
   189  .. code-block:: console
   190  
   191      DELETE /v1/apps/example-go/ HTTP/1.1
   192      Host: deis.example.com
   193      Authorization: token abc123
   194  
   195  Example Response:
   196  
   197  .. code-block:: console
   198  
   199      HTTP/1.1 204 NO CONTENT
   200  
   201  
   202  List Application Details
   203  ````````````````````````
   204  
   205  Example Request:
   206  
   207  .. code-block:: console
   208  
   209      GET /v1/apps/example-go/ HTTP/1.1
   210      Host: deis.example.com
   211      Authorization: token abc123
   212  
   213  Example Response:
   214  
   215  .. code-block:: console
   216  
   217      HTTP/1.1 200 OK
   218      Content-Type: application/json
   219  
   220      {
   221          "created": "2014-01-01T00:00:00UTC",
   222          "id": "example-go",
   223          "owner": "test",
   224          "structure": {},
   225          "updated": "2014-01-01T00:00:00UTC",
   226          "url": "example-go.example.com",
   227          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   228      }
   229  
   230  
   231  Retrieve Application Logs
   232  `````````````````````````
   233  
   234  Example Request:
   235  
   236  .. code-block:: console
   237  
   238      GET /v1/apps/example-go/logs/ HTTP/1.1
   239      Host: deis.example.com
   240      Authorization: token abc123
   241  
   242  Example Response:
   243  
   244  .. code-block:: console
   245  
   246      HTTP/1.1 200 OK
   247      Content-Type: text/plain
   248  
   249      "16:51:14 deis[api]: test created initial release\n"
   250  
   251  
   252  Run one-off Commands
   253  ````````````````````
   254  
   255  .. code-block:: console
   256  
   257      POST /v1/apps/example-go/run/ HTTP/1.1
   258      Host: deis.example.com
   259      Content-Type: application/json
   260      Authorization: token abc123
   261  
   262      {"command": "echo hi"}
   263  
   264  Example Response:
   265  
   266  .. code-block:: console
   267  
   268      HTTP/1.1 200 OK
   269      Content-Type: application/json
   270  
   271      {"rc": 0, "output": "hi"}
   272  
   273  
   274  Containers
   275  ----------
   276  
   277  
   278  List all Containers
   279  ```````````````````
   280  
   281  Example Request:
   282  
   283  .. code-block:: console
   284  
   285      GET /v1/apps/example-go/containers/ HTTP/1.1
   286      Host: deis.example.com
   287      Authorization: token abc123
   288  
   289  Example Response:
   290  
   291  .. code-block:: console
   292  
   293      HTTP/1.1 200 OK
   294      Content-Type: application/json
   295  
   296      {
   297          "count": 1,
   298          "next": null,
   299          "previous": null,
   300          "results": [
   301              {
   302                  "owner": "test",
   303                  "app": "example-go",
   304                  "release": "v2",
   305                  "created": "2014-01-01T00:00:00UTC",
   306                  "updated": "2014-01-01T00:00:00UTC",
   307                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   308                  "type": "web",
   309                  "num": 1,
   310                  "state": "up"
   311              }
   312          ]
   313      }
   314  
   315  
   316  List all Containers by Type
   317  ```````````````````````````
   318  
   319  Example Request:
   320  
   321  .. code-block:: console
   322  
   323      GET /v1/apps/example-go/containers/web/ HTTP/1.1
   324      Host: deis.example.com
   325      Authorization: token abc123
   326  
   327  Example Response:
   328  
   329  .. code-block:: console
   330  
   331      HTTP/1.1 200 OK
   332      Content-Type: application/json
   333  
   334      {
   335          "count": 1,
   336          "next": null,
   337          "previous": null,
   338          "results": [
   339              {
   340                  "owner": "test",
   341                  "app": "example-go",
   342                  "release": "v2",
   343                  "created": "2014-01-01T00:00:00UTC",
   344                  "updated": "2014-01-01T00:00:00UTC",
   345                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   346                  "type": "web",
   347                  "num": 1,
   348                  "state": "up"
   349              }
   350          ]
   351      }
   352  
   353  
   354  Scale Containers
   355  ````````````````
   356  
   357  Example Request:
   358  
   359  .. code-block:: console
   360  
   361      POST /v1/apps/example-go/scale/ HTTP/1.1
   362      Host: deis.example.com
   363      Content-Type: application/json
   364      Authorization: token abc123
   365  
   366      {"web": 3}
   367  
   368  Example Response:
   369  
   370  .. code-block:: console
   371  
   372      HTTP/1.1 204 NO CONTENT
   373  
   374  
   375  Configuration
   376  -------------
   377  
   378  
   379  List Application Configuration
   380  ``````````````````````````````
   381  
   382  Example Request:
   383  
   384  .. code-block:: console
   385  
   386      GET /v1/apps/example-go/config/ HTTP/1.1
   387      Host: deis.example.com
   388      Authorization: token abc123
   389  
   390  Example Response:
   391  
   392  .. code-block:: console
   393  
   394      HTTP/1.1 200 OK
   395      Content-Type: application/json
   396  
   397      {
   398          "owner": "test",
   399          "app": "example-go",
   400          "values": {},
   401          "memory": {},
   402          "cpu": {},
   403          "tags": {},
   404          "created": "2014-01-01T00:00:00UTC",
   405          "updated": "2014-01-01T00:00:00UTC",
   406          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   407      }
   408  
   409  
   410  Create new Config
   411  `````````````````
   412  
   413  Example Request:
   414  
   415  .. code-block:: console
   416  
   417      POST /v1/apps/example-go/config/ HTTP/1.1
   418      Host: deis.example.com
   419      Content-Type: application/json
   420      Authorization: token abc123
   421  
   422      {"values": {"HELLO": "world"}}
   423  
   424  Example Response:
   425  
   426  .. code-block:: console
   427  
   428      HTTP/1.1 201 CREATED
   429      Content-Type: application/json
   430      X-Deis-Release: 3
   431  
   432      {
   433          "owner": "test",
   434          "app": "example-go",
   435          "values": {
   436              "DEIS_APP": "example-go",
   437              "DEIS_RELEASE": "v3",
   438              "HELLO": "world"
   439          },
   440          "memory": {},
   441          "cpu": {},
   442          "tags": {},
   443          "created": "2014-01-01T00:00:00UTC",
   444          "updated": "2014-01-01T00:00:00UTC",
   445          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   446      }
   447  
   448  
   449  Unset Config Variable
   450  `````````````````````
   451  
   452  Example Request:
   453  
   454  .. code-block:: console
   455  
   456      POST /v1/apps/example-go/config/ HTTP/1.1
   457      Host: deis.example.com
   458      Content-Type: application/json
   459      Authorization: token abc123
   460  
   461      {"values": {"HELLO": null}}
   462  
   463  Example Response:
   464  
   465  .. code-block:: console
   466  
   467      HTTP/1.1 201 CREATED
   468      Content-Type: application/json
   469      X-Deis-Release: 4
   470  
   471      {
   472          "owner": "test",
   473          "app": "example-go",
   474          "values": {
   475              "DEIS_APP": "example-go",
   476              "DEIS_RELEASE": "v4"
   477          },
   478          "memory": {},
   479          "cpu": {},
   480          "tags": {},
   481          "created": "2014-01-01T00:00:00UTC",
   482          "updated": "2014-01-01T00:00:00UTC",
   483          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   484      }
   485  
   486  
   487  Domains
   488  -------
   489  
   490  
   491  List Application Domains
   492  ````````````````````````
   493  
   494  Example Request:
   495  
   496  .. code-block:: console
   497  
   498      GET /v1/apps/example-go/domains/ HTTP/1.1
   499      Host: deis.example.com
   500      Authorization: token abc123
   501  
   502  Example Response:
   503  
   504  .. code-block:: console
   505  
   506      HTTP/1.1 200 OK
   507      Content-Type: application/json
   508  
   509      {
   510          "count": 1,
   511          "next": null,
   512          "previous": null,
   513          "results": [
   514              {
   515                  "app": "example-go",
   516                  "created": "2014-01-01T00:00:00UTC",
   517                  "domain": "example.example.com",
   518                  "owner": "test",
   519                  "updated": "2014-01-01T00:00:00UTC"
   520              }
   521          ]
   522      }
   523  
   524  
   525  Add Domain
   526  ``````````
   527  
   528  Example Request:
   529  
   530  .. code-block:: console
   531  
   532      POST /v1/apps/example-go/domains/ HTTP/1.1
   533      Host: deis.example.com
   534      Authorization: token abc123
   535  
   536      {'domain': 'example.example.com'}
   537  
   538  Example Response:
   539  
   540  .. code-block:: console
   541  
   542      HTTP/1.1 201 CREATED
   543      Content-Type: application/json
   544  
   545      {
   546          "app": "example-go",
   547          "created": "2014-01-01T00:00:00UTC",
   548          "domain": "example.example.com",
   549          "owner": "test",
   550          "updated": "2014-01-01T00:00:00UTC"
   551      }
   552  
   553  
   554  
   555  Remove Domain
   556  `````````````
   557  
   558  Example Request:
   559  
   560  .. code-block:: console
   561  
   562      DELETE /v1/apps/example-go/domains/example.example.com HTTP/1.1
   563      Host: deis.example.com
   564      Authorization: token abc123
   565  
   566  Example Response:
   567  
   568  .. code-block:: console
   569  
   570      HTTP/1.1 204 NO CONTENT
   571  
   572  
   573  Builds
   574  ------
   575  
   576  
   577  List Application Builds
   578  ```````````````````````
   579  
   580  Example Request:
   581  
   582  .. code-block:: console
   583  
   584      GET /v1/apps/example-go/builds/ HTTP/1.1
   585      Host: deis.example.com
   586      Authorization: token abc123
   587  
   588  Example Response:
   589  
   590  .. code-block:: console
   591  
   592      HTTP/1.1 200 OK
   593      Content-Type: application/json
   594  
   595      {
   596          "count": 1,
   597          "next": null,
   598          "previous": null,
   599          "results": [
   600              {
   601                  "app": "example-go",
   602                  "created": "2014-01-01T00:00:00UTC",
   603                  "dockerfile": "FROM deis/slugrunner RUN mkdir -p /app WORKDIR /app ENTRYPOINT [\"/runner/init\"] ADD slug.tgz /app ENV GIT_SHA 060da68f654e75fac06dbedd1995d5f8ad9084db",
   604                  "image": "example-go",
   605                  "owner": "test",
   606                  "procfile": {
   607                      "web": "example-go"
   608                  },
   609                  "sha": "060da68f",
   610                  "updated": "2014-01-01T00:00:00UTC",
   611                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   612              }
   613          ]
   614      }
   615  
   616  
   617  Create Application Build
   618  ````````````````````````
   619  
   620  Example Request:
   621  
   622  .. code-block:: console
   623  
   624      POST /v1/apps/example-go/builds/ HTTP/1.1
   625      Host: deis.example.com
   626      Content-Type: application/json
   627      Authorization: token abc123
   628  
   629      {"image": "deis/example-go:latest"}
   630  
   631  Example Response:
   632  
   633  .. code-block:: console
   634  
   635      HTTP/1.1 201 CREATED
   636      Content-Type: application/json
   637      X-Deis-Release: 4
   638  
   639      {
   640          "app": "example-go",
   641          "created": "2014-01-01T00:00:00UTC",
   642          "dockerfile": "",
   643          "image": "deis/example-go:latest",
   644          "owner": "test",
   645          "procfile": {},
   646          "sha": "",
   647          "updated": "2014-01-01T00:00:00UTC",
   648          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   649      }
   650  
   651  
   652  Releases
   653  --------
   654  
   655  
   656  List Application Releases
   657  `````````````````````````
   658  
   659  Example Request:
   660  
   661  .. code-block:: console
   662  
   663      GET /v1/apps/example-go/releases/ HTTP/1.1
   664      Host: deis.example.com
   665      Authorization: token abc123
   666  
   667  Example Response:
   668  
   669  .. code-block:: console
   670  
   671      HTTP/1.1 200 OK
   672      Content-Type: application/json
   673  
   674      {
   675          "count": 3,
   676          "next": null,
   677          "previous": null,
   678          "results": [
   679              {
   680                  "app": "example-go",
   681                  "build": "202d8e4b-600e-4425-a85c-ffc7ea607f61",
   682                  "config": "ed637ceb-5d32-44bd-9406-d326a777a513",
   683                  "created": "2014-01-01T00:00:00UTC",
   684                  "owner": "test",
   685                  "summary": "test changed nothing",
   686                  "updated": "2014-01-01T00:00:00UTC",
   687                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   688                  "version": 3
   689              },
   690              {
   691                  "app": "example-go",
   692                  "build": "202d8e4b-600e-4425-a85c-ffc7ea607f61",
   693                  "config": "95bd6dea-1685-4f78-a03d-fd7270b058d1",
   694                  "created": "2014-01-01T00:00:00UTC",
   695                  "owner": "test",
   696                  "summary": "test deployed 060da68",
   697                  "updated": "2014-01-01T00:00:00UTC",
   698                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   699                  "version": 2
   700              },
   701              {
   702                  "app": "example-go",
   703                  "build": null,
   704                  "config": "95bd6dea-1685-4f78-a03d-fd7270b058d1",
   705                  "created": "2014-01-01T00:00:00UTC",
   706                  "owner": "test",
   707                  "summary": "test created initial release",
   708                  "updated": "2014-01-01T00:00:00UTC",
   709                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   710                  "version": 1
   711              }
   712          ]
   713      }
   714  
   715  
   716  List Release Details
   717  ````````````````````
   718  
   719  Example Request:
   720  
   721  .. code-block:: console
   722  
   723      GET /v1/apps/example-go/releases/v1/ HTTP/1.1
   724      Host: deis.example.com
   725      Authorization: token abc123
   726  
   727  Example Response:
   728  
   729  .. code-block:: console
   730  
   731      HTTP/1.1 200 OK
   732      Content-Type: application/json
   733  
   734      {
   735          "app": "example-go",
   736          "build": null,
   737          "config": "95bd6dea-1685-4f78-a03d-fd7270b058d1",
   738          "created": "2014-01-01T00:00:00UTC",
   739          "owner": "test",
   740          "summary": "test created initial release",
   741          "updated": "2014-01-01T00:00:00UTC",
   742          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
   743          "version": 1
   744      }
   745  
   746  
   747  Rollback Release
   748  ````````````````
   749  
   750  Example Request:
   751  
   752  .. code-block:: console
   753  
   754      POST /v1/apps/example-go/releases/rollback/ HTTP/1.1
   755      Host: deis.example.com
   756      Content-Type: application/json
   757      Authorization: token abc123
   758  
   759      {"version": 1}
   760  
   761  Example Response:
   762  
   763  .. code-block:: console
   764  
   765      HTTP/1.1 201 CREATED
   766      Content-Type: application/json
   767      
   768      {"version": 5}
   769  
   770  
   771  Keys
   772  ----
   773  
   774  
   775  List Keys
   776  `````````
   777  
   778  Example Request:
   779  
   780  .. code-block:: console
   781  
   782      GET /v1/keys/ HTTP/1.1
   783      Host: deis.example.com
   784      Authorization: token abc123
   785  
   786  Example Response:
   787  
   788  .. code-block:: console
   789  
   790      {
   791          "count": 1,
   792          "next": null,
   793          "previous": null,
   794          "results": [
   795              {
   796                  "created": "2014-01-01T00:00:00UTC",
   797                  "id": "test@example.com",
   798                  "owner": "test",
   799                  "public": "ssh-rsa <...>",
   800                  "updated": "2014-01-01T00:00:00UTC",
   801                  "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   802              }
   803          ]
   804      }
   805  
   806  
   807  Add Key to User
   808  ```````````````
   809  
   810  Example Request:
   811  
   812  .. code-block:: console
   813  
   814      POST /v1/keys/ HTTP/1.1
   815      Host: deis.example.com
   816      Authorization: token abc123
   817  
   818      {
   819          "id": "example",
   820          "public": "ssh-rsa <...>"
   821      }
   822  
   823  Example Response:
   824  
   825  .. code-block:: console
   826  
   827      HTTP/1.1 201 CREATED
   828      Content-Type: application/json
   829  
   830      {
   831          "created": "2014-01-01T00:00:00UTC",
   832          "id": "example",
   833          "owner": "example",
   834          "public": "ssh-rsa <...>",
   835          "updated": "2014-01-01T00:00:00UTC",
   836          "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
   837      }
   838  
   839  
   840  Remove Key from User
   841  ````````````````````
   842  
   843  Example Request:
   844  
   845  .. code-block:: console
   846  
   847      DELETE /v1/keys/example HTTP/1.1
   848      Host: deis.example.com
   849      Authorization: token abc123
   850  
   851  Example Response:
   852  
   853  .. code-block:: console
   854  
   855      HTTP/1.1 204 NO CONTENT
   856  
   857  
   858  Permissions
   859  -----------
   860  
   861  
   862  List Application Permissions
   863  ````````````````````````````
   864  
   865  Example Request:
   866  
   867  .. code-block:: console
   868  
   869      GET /v1/apps/example-go/perms/ HTTP/1.1
   870      Host: deis.example.com
   871      Authorization: token abc123
   872  
   873  Example Response:
   874  
   875  .. code-block:: console
   876  
   877      HTTP/1.1 200 OK
   878      Content-Type: application/json
   879  
   880      {
   881          "users": []
   882      }
   883  
   884  
   885  Create Application Permission
   886  `````````````````````````````
   887  
   888  Example Request:
   889  
   890  .. code-block:: console
   891  
   892      POST /v1/apps/example-go/perms/ HTTP/1.1
   893      Host: deis.example.com
   894      Authorization: token abc123
   895  
   896      {"username": "example"}
   897  
   898  Example Response:
   899  
   900  .. code-block:: console
   901  
   902      HTTP/1.1 201 CREATED
   903  
   904  
   905  Remove Application Permission
   906  `````````````````````````````
   907  
   908  Example Request:
   909  
   910  .. code-block:: console
   911  
   912      POST /v1/apps/example-go/perms/example HTTP/1.1
   913      Host: deis.example.com
   914      Authorization: token abc123
   915  
   916  Example Response:
   917  
   918  .. code-block:: console
   919  
   920      HTTP/1.1 204 NO CONTENT
   921  
   922  Grant User Administrative Privileges
   923  ````````````````````````````````````
   924  
   925  .. note::
   926  
   927      This command requires administrative privileges
   928  
   929  Example Request:
   930  
   931  .. code-block:: console
   932  
   933      POST /v1/admin/perms HTTP/1.1
   934      Host: deis.example.com
   935      Authorization: token abc123
   936  
   937      {"username": "example"}
   938  
   939  Example Response:
   940  
   941  .. code-block:: console
   942  
   943      HTTP/1.1 201 CREATED