github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/api.md (about)

     1  # API Description
     2  
     3  The Unik daemon provides a RESTful interface. 
     4  
     5  * [Compilers](#Compilers)
     6  * [Providers](#Providers)
     7  * [Images](#Images)
     8  * [Instances](#Instances)
     9  * [Volumes](#Volumes)
    10  
    11  ## Compilers
    12  
    13  ### GET `/available_compilers`
    14  
    15  Get all compilers available to the targeted unik backend.
    16  
    17  Returns a list with the names of all compilers. 
    18  
    19  
    20  ### GET `/describe_compiler`
    21  
    22  Describes a compiler identified by provider, base and language.
    23  
    24  The fallowing query parameters are available to specify the compiler:
    25  
    26  Parameter | Description | Mandatory
    27  ----------| ----------- | :--------:
    28  provider  |  The (cloud/hypervisor) provider the image should be built for. Supported providers depend on the unikernel base.     | yes
    29  base      | The Unikernel Base to build the image on. These include different unikernel implementations, such as rumprun, IncludeOS, etc.          | yes
    30  lang      | The language/runtime the image should be built with. E.g. for a golang project, specify `go`. Languages supported depend on the unikernel base.        | yes
    31  
    32  A string describing the compiler is returned, or `<missing compiler description>` if no description is available. 
    33  
    34  ## Providers
    35  
    36  ### GET `/available_providers`
    37  
    38  Get all providers available to the targeted unik backend.
    39  
    40  Returns a list with the names of all providers. 
    41  
    42  
    43  ## Images
    44  
    45  ### GET `/images`
    46  
    47  Lists all available unikernel images across providers. Includes important information for running and managing instances, including the required mount points for the image.
    48  
    49  Returns a JSON list of objects, describing all images. 
    50  See description of the request for a single image for more [details](#GET-imagesimage_name) about the object.
    51  
    52  ### GET `/images/{image_name}`
    53  
    54  Describe one image identified by its name.
    55  
    56  A JSON of the following format is returned, describing the image: 
    57  
    58  ```javascript
    59  {
    60      "Id": string,
    61      "Name": string,
    62      "SizeMb": number,
    63      "Infrastructure": string,
    64      "Created": string,
    65      "StageSpec": {
    66          "ImageFormat": string,
    67          "XenVirtualizationType": string
    68      },
    69      "RunSpec": {
    70          "DeviceMappings": [
    71              {
    72                  "MountPoint": string,
    73                  "DeviceName": string
    74              },
    75              ...
    76          ],
    77          "DefaultInstanceMemory": number,
    78          "MinInstanceDiskMB": number,
    79          "StorageDriver": string,
    80          "VsphereNetworkType": string,
    81          "Compiler": string
    82      }
    83  }
    84  ```
    85  
    86  ### POST `/images/{image_name}/create`
    87  
    88  Builds  new image on the targeted unik backend, with the specified name.
    89  
    90  The body must be of the type `multipart/form-data` with the fallowing values:
    91  
    92  Parameter | Description | Mandatory
    93  ----------| ----------- | :--------:
    94  tarfile   | A file of the type tar.gz containing the application source. | yes
    95  provider  |  The (cloud/hypervisor) provider the image should be built for. Supported providers depend on the unikernel base.     | yes
    96  base      | The Unikernel Base to build the image on. These include different unikernel implementations, such as rumprun, IncludeOS, etc.          | yes
    97  lang      | The language/runtime the image should be built with. E.g. for a golang project, specify `go`. Languages supported depend on the unikernel base.        | yes
    98  force   | If set to true, the image creation is inforced | no
    99  no_cleanup   | If set to true, the files send to the server will not be removed after the image is created | no
   100  mounts   | A comma separated list of mountpoint where on runtime a volume is expected to be mounted | no
   101  args   | A list of arguments to be passed to the application at runtime  | no
   102  
   103  Returns a JSON object, describing the newly created image.
   104  See description of the request for a single image for more [details](#GET-imagesimage_name) about the object.
   105  
   106  
   107  ### DELETE `/images/{image_name}`
   108  
   109  Deletes an image identified by its name. 
   110  
   111  The fallowing query parameters are available:
   112  
   113  Parameter | Description | Mandatory
   114  ----------| ----------- | :--------:
   115  force   | If set to true, the image removal is enforced | no
   116  
   117  Returns HTTP Status `204` on success. 
   118  
   119  ### POST `/images/push/{image_name}`
   120  
   121  Pushes an image from the server to the specified hub. 
   122  
   123  The body must be of the type `application/json` with the fallowing format:
   124  
   125  ```javascript
   126  {
   127  	"url":string,
   128  	"user":string,
   129  	"pass":string
   130  }
   131  ```
   132  It describes the Hub configuration, which is the url and credentials for an AWS S3 instance. 
   133  
   134  Returns HTTP Status `202` on success. 
   135  
   136  ### POST `/images/pull/{image_name}`
   137  
   138  Pulls an image from the specified hub to the server.
   139  
   140  The fallowing query parameters are available:
   141  
   142  Parameter | Description | Mandatory
   143  ----------| ----------- | :--------:
   144  provider  |  The (cloud/hypervisor) provider the image should be built for. Supported providers depend on the unikernel base.     | yes
   145  force     | If set to true, a locally existing image might get overwritten | no
   146  
   147  The body must contain the description of the Hub, for more details [see](#POST-imagespushimage_name).
   148  
   149  Returns HTTP Status `202` on success. 
   150  
   151  ### POST `/images/remote-delete/{image_name}`
   152  
   153  Deletes an image from the specified hub. 
   154  
   155  The body must contain the description of the Hub, for more details [see](#POST-imagespushimage_name).
   156  
   157  Returns HTTP Status `202` on success. 
   158      
   159  ## Instances
   160  
   161  ### GET `/instances`
   162  
   163  Lists all available unikernel instances across providers. Includes important information about the state of the instances.
   164  
   165  Returns a JSON list of objects, describing all instances. 
   166  See description of the request for a single instance for more [details](#GET-instancesinstance_id) about the object.
   167  
   168  ### GET `/instances/{instance_id}`
   169  
   170  Describe an instance identified by its ID or name.
   171  
   172  A JSON of the following format is returned, describing the instance: 
   173  
   174  ```javascript
   175  {
   176      "Id":string,
   177      "Name":string,
   178      "State":string,
   179      "IpAddress":string,
   180      "ImageId":string,
   181      "Infrastructure":string,
   182      "Created":string
   183  }
   184  ```
   185  
   186  ### DELETE `/instances/{instance_id}`
   187  
   188  Deletes an instance identified by its ID or name. 
   189  
   190  The fallowing query parameters are available:
   191  
   192  Parameter | Description | Mandatory
   193  ----------| ----------- | :--------:
   194  force   | If set to true, the instance removal is enforced | no
   195  
   196  Returns HTTP Status `204` on success. 
   197  
   198  ### GET `/instances/{instance_id}/logs`
   199  
   200  Retrieves logs from a running unikernel instance. Cannot be used on an instance in powered-off state. 
   201  
   202  The fallowing query parameters are available:
   203  
   204  Parameter | Description | Mandatory
   205  ----------| ----------- | :--------:
   206  fallow   | If set to true, the logs will be continuously streamed to the client | no
   207  delete   | Only valid with fallow=true. If set to true, the instance will be removed as soon as the connection is terminated  | no
   208  
   209  Returns a string containing all available logs, or a stream if fallow=true. 
   210  
   211  ### POST `/instances/run`
   212  
   213  Deploys a running instance from a unik-compiled unikernel disk image. The instance will be deployed on the provider the image was compiled for. e.g. if the image was compiled for virtualbox, unik will attempt to deploy the image on the configured virtualbox environment.
   214  
   215  As body a JSON of the fallowing format is expected:
   216  
   217  ```javascript
   218  {
   219  	"InstanceName": string,
   220  	"ImageName": string,
   221  	"Mounts": {
   222          string:string,
   223          string:string,
   224          ...
   225      },
   226  	"Env": {
   227          string:string,
   228          string:string,
   229          ...
   230      },
   231  	"MemoryMb": number,
   232  	"NoCleanup": boolean,
   233  	"DebugMode": boolean
   234  }
   235  ```
   236  Returns a JSON object describing the newly created instance.
   237  See description of the request for a single instance for more [details](#GET-instancesinstance_id) about the object.
   238  
   239  ### POST `/instances/{instance_id}/start`
   240  
   241  Powers on an existing instance identified by its name.
   242  
   243  Returns HTTP Status `200` on success. 
   244  
   245  ### POST `/instances/{instance_id}/stop`
   246  
   247  Powers of an instance identified by its name. 
   248  
   249  Returns HTTP Status `200` on success. 
   250  
   251  ## Volumes
   252  
   253  ### GET `/volumes`
   254  
   255  Lists all available unik-managed volumes across providers.
   256  
   257  Returns a JSON list of objects, describing all volumes. 
   258  See description of the request for a single volume for more [details](#GET-volumesvolume_name) about the object.
   259  
   260  ### GET `/volumes/{volume_name}`
   261  
   262  Describes a volume identified by its name. 
   263  
   264  A JSON of the following format is returned, describing the volume: 
   265  
   266  ```javascript
   267  {
   268      "Id":string,
   269      "Name":string,
   270      "SizeMb":number,
   271      "Attachment":string,  //instanceId
   272      "Infrastructure":string,
   273      "Created":string
   274  }
   275  ```
   276  
   277  ### POST `/volumes/{volume_name}`
   278  
   279  Creates a data volume which can be attached to and detached from unik-managed instances.
   280  
   281  Every request must contain at least the fallowing form value in its body:
   282  
   283  Parameter | Description | Mandatory
   284  ----------| ----------- | :--------:
   285  type   | A docker image used for the creation of the volume (?)  | true
   286  
   287  If data for the volume is already send with the request, the body must be of the type `multipart/form-data` and must contain the rest of the parameters as well. 
   288  If no data is send with the request, the body can be simple url encoded and the rest of the parameters must be send as query parameters.
   289  
   290  Parameter | Description | In Body  | In Query |
   291  ----------| ----------- | -------- | -------- |
   292  tarfile   | The data added initially to the volume  | yes | no
   293  provider  |  The (cloud/hypervisor) provider the volume should be built for.   | yes | yes
   294  raw | If true, the data is send as raw bytes, otherwise as tar.gz | optional | no
   295  no_cleanup |  If set to true, the files send to the server will not be removed after the volume is created | optional | optional 
   296  size | The size of the volume in MB | no | yes 
   297  
   298  The size, unlike the other parameters, must be always send as query parameter. 
   299  
   300  Returns a JSON describing the newly created volume. 
   301  See description of the request for a single volume for more [details](#GET-volumesvolume_name) about the object.
   302  
   303  ### DELETE `/volumes/{volume_name}`
   304  
   305  Deletes a volume identified by its name.
   306  
   307  The fallowing query parameters are available:
   308  
   309  Parameter | Description | Mandatory
   310  ----------| ----------- | :--------:
   311  force   | If set to true, the volume removal is enforced | no
   312  
   313  Returns HTTP Status `204` on success. 
   314  
   315  ### POST `/volumes/{volume_name}/attach/{instance_id}`
   316  
   317  Attaches an existing volume, identified by its name, to a running instance, identified by its id. 
   318  
   319  The fallowing query parameters are available:
   320  
   321  Parameter | Description | Mandatory
   322  ----------| ----------- | :--------:
   323  mount   | The mount point of the instance for the volume | true
   324  
   325  Returns the name of the attached volume. 
   326  
   327  ### POST `/volumes/{volume_name}/detach`
   328  
   329  Detaches a volume from its instance.
   330  
   331  Returns the name of the detached volume.
   332  
   333  
   334  
   335  
   336