com.elastisys.scale.cloudpool.api.restapi

## Class CloudPoolHandler

- java.lang.Object
- - com.elastisys.scale.cloudpool.api.restapi.CloudPoolHandler

    @Path(value="/")
     @Consumes(value="application/json")
     @Produces(value="application/json")
    public class CloudPoolHandler
    extends Object

Implements the cloud pool REST API, which is fully covered in the elastisys:scale cloud pool REST API documentation.

### Constructor Summary

Constructors
Constructor and Description
`CloudPoolHandler(CloudPool cloudPool)`

### Method Summary

All Methods Instance Methods Concrete Methods
`javax.ws.rs.core.Response` `attachMachine(String machineId)` Attaches an already running machine instance to the pool, growing the pool with a new member.
`javax.ws.rs.core.Response` `detachMachine(String machineId, DetachMachineRequest request)` Removes a member from the pool without terminating it.
`javax.ws.rs.core.Response` `getMetadata()` Returns metadata about the cloud pool and the cloud infrastructure it manages.
`javax.ws.rs.core.Response` `getPool()` Retrieves the current machine pool members.
`javax.ws.rs.core.Response` `getPoolSize()` Returns the current size of the machine pool -- both in terms of the desired size and the actual size (as these may differ at any time).
`javax.ws.rs.core.Response` `setDesiredSize(SetDesiredSizeRequest request)` Sets the desired number of machines in the machine pool.
`javax.ws.rs.core.Response` `setMembershipStatus(String machineId, SetMembershipStatusRequest request)`
`javax.ws.rs.core.Response` `setServiceState(String machineId, SetServiceStateRequest request)` Sets the service state of a given machine pool member.
`javax.ws.rs.core.Response` `terminateMachine(String machineId, TerminateMachineRequest request)` Terminates a particular machine pool member.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CloudPoolHandler

    public CloudPoolHandler(CloudPool cloudPool)

### Method Detail

#### getPool

    @GET
     @Path(value="/pool")
    public javax.ws.rs.core.Response getPool()

Retrieves the current machine pool members.

Returns:
  A response message as per the cloud pool REST API.

#### setDesiredSize

    @POST
     @Path(value="/pool/size")
    public javax.ws.rs.core.Response setDesiredSize(SetDesiredSizeRequest request)

Sets the desired number of machines in the machine pool. This method is asynchronous in that the method returns immediately without having carried out any required changes to the machine pool.

Parameters:
  `request` - The desired number of machine in the pool.
Returns:
  A response message as per the cloud pool REST API.

#### getPoolSize

    @GET
     @Path(value="/pool/size")
    public javax.ws.rs.core.Response getPoolSize()

Returns the current size of the machine pool -- both in terms of the desired size and the actual size (as these may differ at any time).

Returns:
  A response message as per the cloud pool REST API.

#### getMetadata

    @GET
     @Path(value="/pool/metadata")
    public javax.ws.rs.core.Response getMetadata()

Returns metadata about the cloud pool and the cloud infrastructure it manages.

Returns:
  A response message as per the cloud pool REST API.

#### terminateMachine

    @POST
     @Path(value="/pool/{machine}/terminate")
    public javax.ws.rs.core.Response terminateMachine(@PathParam(value="machine")
                                                                                                      String machineId,
                                                                                                      TerminateMachineRequest request)

Terminates a particular machine pool member. The caller can control if a replacement machine is to be provisioned.

Parameters:
  `machineId` - The identifier of the machine to terminate.
  `request` - A `TerminateMachineRequest`.
Returns:
  A response message as per the cloud pool REST API.

#### detachMachine

    @POST
     @Path(value="/pool/{machine}/detach")
    public javax.ws.rs.core.Response detachMachine(@PathParam(value="machine")
                                                                                                String machineId,
                                                                                                DetachMachineRequest request)

Removes a member from the pool without terminating it. The machine keeps running but is no longer considered a pool member and, therefore, needs to be managed independently. The caller can control if a replacement machine is to be provisioned.

Parameters:
  `machineId` - The identifier of the machine to detach from the pool.
  `request` - A `DetachMachineRequest`.
Returns:
  A response message as per the cloud pool REST API.

#### attachMachine

    @POST
     @Path(value="/pool/{machine}/attach")
    public javax.ws.rs.core.Response attachMachine(@PathParam(value="machine")
                                                                                                String machineId)

Attaches an already running machine instance to the pool, growing the pool with a new member. This operation implies that the desired size of the pool is incremented by one.

Parameters:
  `machineId` - The identifier of the machine to attach to the pool.
Returns:
  A response message as per the cloud pool REST API.

#### setServiceState

    @POST
     @Path(value="/pool/{machine}/serviceState")
    public javax.ws.rs.core.Response setServiceState(@PathParam(value="machine")
                                                                                                        String machineId,
                                                                                                        SetServiceStateRequest request)

Sets the service state of a given machine pool member. Setting the service state does not have any functional implications on the pool member, but should be seen as way to supply operational information about the service running on the machine to third-party services (such as load balancers).

Parameters:
  `machineId` - The machine whose service state is to be set.
  `request` - A `SetServiceStateRequest`.
Returns:
  A response message as per the cloud pool REST API.

#### setMembershipStatus

    @POST
     @Path(value="/pool/{machine}/membershipStatus")
    public javax.ws.rs.core.Response setMembershipStatus(@PathParam(value="machine")
                                                                                                                String machineId,
                                                                                                                SetMembershipStatusRequest request)