# README #

This README would normally document whatever steps are necessary to get your application up and running.

### How to set it up###

You will need to add cloudml-library.jar to local maven repository. To do this you need to execute (for current version 1.5.1) 


```
#!maven

mvn install:install-file -Dfile=<path-to-file> -DgroupId=cloudml -DartifactId=cloudml-library -Dversion=1.5.1 -Dpackaging=jar
```

,where is <path-to-file> path to jar.

As well you will need to add Amazon credentials. Call file AwsCredentials.properties, it should contain secretKey and accessKey in format like this (no spaces between)

```
#!file

secretKey=....
accessKey=....
```
You should put it in package **org.ut.cmldep.amazon.request**. Last step is to import project into Eclipse as a Maven project.

### How to use ###

To start a REST server you just need to execute Application.java as a Java Application. Then you will need to initiate **Initial Model** to deploy. To do this just send a **GET** request to **server_ip:8080/rest**

### How to scale-up ###

You can only scale up components that are already in **Initial Model**. To do so just send **PUT** request to **server_ip:8080/rest**. Here is an example of content that should be send with the request


```
#!json

{
  "config": [
    {
      "name": "ngnix--1",
      "instances": [
        {
          "size": "T1Micro",
          "amount": 2
        },
        {
          "size": "M1Small",
          "amount": 1
        }
      ]
    }
  ]
}
```
where **name** is taken from **Initial Model**, amount is number of that should be running, and size is type of Amazon instance. Because I use AWS SDK 1.7.3 by default, so some new types on instances might be unavailable. List of available types you can find   

### How to scale down ###

Scaling down will basically shut down Instance by ids. To scale down you need to send **DELETE** request to **server_ip:8080/rest** with content :


```
#!json

{
  "instances": [
    "id1",
    "id2",
    "id3"
  ]
}
```

### Response to request ###

You will get response:

```
#!json
{
    "status": "Done"
}
```

and response code **200** to each request, if it was successful. Revising the answer mean that CloudML has finished deployment of current model.