# Nodes Controller Resource

The API allows you to list, view, edit and register nodes.

### GET /nodes

Request Parameters
name | type | description
--- | --- | ---
direction | query |
filter | query |
nameLike | query |
nodeConfigGuid | query |
orderBy | query |
page | query |
size | query |

Response Body
media type | data type | description
--- | --- | ---
application/json | array of NodeListRecord (JSON) |

#### Example

##### Request

    GET /nodes
    Content-Type: */*
    Accept: application/json

    ...

##### Response

    HTTP/1.1 200 OK
    Content-Type: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "nodeIp" : "https://some.host:8181/api",
      "state" : {
        "name" : "ENUM_NAME",
        "description" : "Enum description"
      }
    } ]

### POST /nodes

Create a node.

Request Parameters
name | type | description | constraints
--- | --- | --- | ---
existing | query | specify whether node exists | boolean

Request Body
media type | data type | description
--- | --- | ---
application/json | NodeRegistrationRequest (JSON) | specify details for new node

Response Body
media type | data type | description
--- | --- | ---
application/json | NodeRegistrationResponse (JSON) | details of newly created node

#### Example

##### Request

    POST /nodes
    Content-Type: application/json
    Accept: application/json

    { }

##### Response

    HTTP/1.1 201 Created
    Content-Type: application/json

    {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67"
    }

### GET /nodes/for-restore

Request Parameters
name | type | description | constraints
--- | --- | --- | ---
backup-to-be-restored | query |  | required, not empty

Response Body
media type | data type | description
--- | --- | ---
application/json | array of NodeListRecord (JSON) |

#### Example

##### Request

    GET /nodes/for-restore
    Content-Type: */*
    Accept: application/json

    ...

##### Response

    HTTP/1.1 200 OK
    Content-Type: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "nodeIp" : "https://some.host:8181/api",
      "state" : {
        "name" : "ENUM_NAME",
        "description" : "Enum description"
      }
    } ]

### GET /nodes/reduced

Request Parameters
name | type | description
--- | --- | ---
direction | query |
filter | query |
nameLike | query |
nodeConfigGuid | query |
orderBy | query |
page | query |
size | query |

Response Body
media type | data type | description
--- | --- | ---
application/json | array of NodeReducedListRecord (JSON) |

#### Example

##### Request

    GET /nodes/reduced
    Content-Type: */*
    Accept: application/json

    ...

##### Response

    HTTP/1.1 200 OK
    Content-Type: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67"
    } ]

### DELETE /nodes/{guid}

Remove node.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

#### Example

##### Request

    DELETE /nodes/{guid}
    Content-Type: */*

    ...

##### Response

    HTTP/1.1 204 No Content

### GET /nodes/{guid}

Get a single node.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

Response Body
media type | data type | description
--- | --- | ---
application/json | NodeDetails (JSON) | a singe node details

#### Example

##### Request

    GET /nodes/{guid}
    Content-Type: */*
    Accept: application/json

    ...

##### Response

    HTTP/1.1 200 OK
    Content-Type: application/json

    {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "lastSeen" : 1451649601000
    }

### PUT /nodes/{guid}

Change node details.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

Request Body
media type | data type | description
--- | --- | ---
application/json | NodeUpdateRequest (JSON) | specify node details to update

#### Example

##### Request

    PUT /nodes/{guid}
    Content-Type: application/json

    { }

##### Response

    HTTP/1.1 204 No Content

### PUT /nodes/{guid}/hypervisor-managers

Assign hypervisor managers to specified node.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

Request Body
media type | data type | description
--- | --- | ---
application/json | array of NameAndGuid (JSON) | specify list of hypervisor managers that will be assigned to node

Response Body
media type | data type | description
--- | --- | ---
application/json | array of HypervisorManagerListRecord (JSON) | list of assigned hypervisor managers to node

#### Example

##### Request

    PUT /nodes/{guid}/hypervisor-managers
    Content-Type: application/json
    Accept: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "name" : "Entity name"
    } ]

##### Response

    HTTP/1.1 204 No Content
    Content-Type: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "type" : {
        "name" : "ENUM_NAME",
        "description" : "Enum description"
      }
    } ]

### PUT /nodes/{guid}/hypervisors

Assign hypervisors to specified node.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

Request Body
media type | data type | description
--- | --- | ---
application/json | array of NameAndGuid (JSON) | specify list of hypervisors that will be assigned to node

Response Body
media type | data type | description
--- | --- | ---
application/json | array of HypervisorListRecord (JSON) | list of assigned hypervisors to node

#### Example

##### Request

    PUT /nodes/{guid}/hypervisors
    Content-Type: application/json
    Accept: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "name" : "Entity name"
    } ]

##### Response

    HTTP/1.1 204 No Content
    Content-Type: application/json

    [ {
      "guid" : "f8f73bf9-2445-4bce-a7dd-753be3b40a67",
      "type" : {
        "name" : "ENUM_NAME",
        "description" : "Enum description"
      }
    } ]

### PUT /nodes/{guid}/state

Change node state.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

Request Body
media type | data type | description
--- | --- | ---
application/json | NodeState (JSON) | specify node state to change

#### Example

##### Request

    PUT /nodes/{guid}/state
    Content-Type: application/json

    "RUNNING"

##### Response

    HTTP/1.1 204 No Content

### PUT /nodes/{guid}/stop

Request Node stop.

Request Parameters
name | type | description
--- | --- | ---
guid | path | specify local unique identifier for node (use by vProtect)

#### Example

##### Request

    PUT /nodes/{guid}/stop
    Content-Type: application/json

    ...

##### Response

    HTTP/1.1 204 No Content