# Projects API

## Get project types [GET /v3/project_types]
> Get project types list

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  "general"
]
```

## Get projects list [GET /v3/projects]
> Get projects list

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * archived - get only archived projects (true, false)

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {
    "id" : "project id",
    "description" : "",
    "owner": "owner"
  }
]
```

## Create project [POST /v3/project]
> Create new project

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json
  * Body:
```json
{
  "id": "project id",
  "description" : "project description"
}
```

### Response
**Status: 201**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "project_id"
  "message" : "Created"
}
```

## Show project [GET /v3/project/:project]
> Get project with id ':project'

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id" : "project id",
  "description" : "",
  "owner": "owner",
  "project_users": [],
  "run_list": [],
  "environments": []
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Update project [PUT /v3/project/:project]
> Update project with id ':project'

### Request
  * Policy: create_projects
  * Method: PUT
  * Headers:
    *  Accept: application/json
  * Body:
```json
{}
```
### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "description" : "",
  "project_users": [],
  "run_list": []
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Delete project [DELETE /v3/project/:project]
> Delete project with id ':project'

### Request
  * Policy: delete_projects
  * Method: DELETE
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "project id"
  "message": "Deleted"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Set project run list [POST /v3/project/:project/run_list]
> Set run_list for project with id ':project'

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json
  * Body:
```json
[
 "role"
]
```

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "Updated"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Show project servers [GET /v3/project/:project/servers]
> Get servers list for project with id ':project'

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {}
]
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Delete project servers [DELETE /v3/project/:project/servers]
> Delete servers for project with id ':project'

### Request
  * Policy: delete_projects
  * Method: DELETE
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "project id"
  "message": "Deleted"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Deploy project servers [POST /v3/project/:project/servers/deploy]
> Deploy all server for project with id ':project'

### Request
  * Policy: deploy_project
  * Method: POST
  * Headers:
    *  Accept: application/json
  * Body:
```json
{
 "servers": [
   "server id"
 ],
 "environment": "deploy env"
}
```

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "Updated"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Archive project [POST /v3/project/:project/archive]
> Archive project with id ':project'

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "Updated"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Unarchive project [POST /v3/project/:project/unarchive]
> unarchive project with id ':project'

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "Updated"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Show project stacks [GET /v3/project/:project/stacks]
> Get stacks list for project with id ':project'

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {}
]
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Delete project stacks [DELETE /v3/project/:project/stacks]
> Delete stacks for project with id ':project'

### Request
  * Policy: delete_projects
  * Method: DELETE
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "project id"
  "message": "Deleted"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Show project environments [GET /v3/project/:project/environments]
> Get environments list for project with id ':project'

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {}
]
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```

## Add environment [POST /v3/project/:project/environment]
> Add new environment to project with id ':project'

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "deploy env id",
  "run_list": [],
  "categories": [
    {
      "id" : "category id",
      "provider": {
        "name": "provider name",
        "account": "provider account",
        "flavor": "provider flavor",
        "image": "image id",
        "security_groups": [
          "default"
        ],
        "stack_template": "stack template id",
        "subnet": "subnet id (aws only)",
        "vpc_id": "vpc id (aws only)",
        "subnets": [
          "subnet id"
        ] (openstack only)
      },
      "cm_tool": {
        "name": "cm tool name",
        "bootstrap_template": ""
      }
    }
  ],
  "users": [
    "user1"
  ],
  "expires": null
}
```

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
    "message" : "Added"
}
```

## Show environment [GET /v3/project/:project/environment/:env]
> Show environment ':env' for project with id ':project'

### Request
  * Policy: read_projects
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * :project - project id
    * :env - deploy environment identifier

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "id": "deploy env id",
  "run_list": [],
  "categories": [
    {
      "id" : "category id",
      "provider": {
        "name": "provider name",
        "account": "provider account",
        "flavor": "provider flavor",
        "image": "image id",
        "security_groups": [
          "default"
        ],
        "stack_template": "stack template id",
        "subnet": "subnet id (aws only)",
        "vpc_id": "vpc id (aws only)",
        "subnets": [
          "subnet id"
        ] (openstack only)
      },
      "cm_tool": {
        "name": "cm tool name",
        "bootstrap_template": ""
      }
    }
  ],
  "users": [
    "user1"
  ],
  "expires": null
}
```

## Update environment [PUT /v3/project/:project/environment/:env]
> Update environment ':env' for project with id ':project'

### Request
  * Policy: create_project
  * Method: PUT
  * Headers:
    *  Accept: application/json
  * Params:
    * :project - project id
    * :env - deploy environment identifier
  * Body
```json
{
  "id": "deploy env id",
  "run_list": [],
  "categories": [
    {
      "id" : "category id",
      "provider": {
        "name": "provider name",
        "account": "provider account",
        "flavor": "provider flavor",
        "image": "image id",
        "security_groups": [
          "default"
        ],
        "stack_template": "stack template id",
        "subnet": "subnet id (aws only)",
        "vpc_id": "vpc id (aws only)",
        "subnets": [
          "subnet id"
        ] (openstack only)
      },
      "cm_tool": {
        "name": "cm tool name",
        "bootstrap_template": ""
      }
    }
  ],
  "users": [
    "user1"
  ],
  "expires": null
}
```

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{

    "message" : "Updated"
}
```
**Status: 422**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
}
```

## Delete environment [DELETE /v3/project/:project/environment/:env]
> Delete environment ':env' for project with id ':project'

### Request
  * Policy: delete_project
  * Method: DELETE
  * Headers:
    *  Accept: application/json
  * Params:
    * :project - project id
    * :env - deploy environment identifier

### Response
**Status: 204**

## Add category to environment [POST /v3/project/:project/environment/:env/category]
> Add new category to environment ':env' for project with id ':project'

### Request
  * Policy: update_project
  * Method: POST
  * Headers:
    *  Accept: application/json
  * Params:
    * :project - project id
    * :env - environment identifier

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "",
  "category": {}
}
```

## Delete category from environment [DELETE /v3/project/:project/environment/:env/category/:id]
> Delete category from environment ':env' for project with id ':project'

### Request
  * Policy: update_project
  * Method: DELETE
  * Headers:
    *  Accept: application/json
  * Params:
    * :project - project id
    * :env - deploy environment identifier
    * :id - category id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "",
  "category": {}
}
```


## Set environment run list [POST /v3/project/:project/environment/:env/run_list]
> Set run_list for environment ':env' in project with id ':project'

### Request
  * Policy: create_project
  * Method: POST
  * Headers:
    *  Accept: application/json
  * Body:
```json
[
 "role"
]
```

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{
  "message": "Updated"
}
```
**Status: 404**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
{}
```
