com.elastisys.scale.cloudpool.openstack.requests

## Class AbstractOpenstackRequest<R>

- java.lang.Object
- - com.elastisys.scale.cloudpool.openstack.requests.AbstractOpenstackRequest<R>

Type Parameters:
  `R` - the response type

All Implemented Interfaces:
  Callable<R>

Direct Known Subclasses:
  AssignFloatingIpRequest, CreateServerRequest, DeleteServerMetadataRequest, DeleteServerRequest, GetServerRequest, ListImagesRequest, ListNetworksRequest, ListServersWithTagRequest, ListSizesRequest, ServerExistsRequest, UpdateServerMetadataRequest

    public abstract class AbstractOpenstackRequest<R>
    extends Object
    implements Callable<R>

An abstract base class for implementing OpenStack request clients.

Sub-classes need to implement `doRequest(OSClient)`.

### Constructor Summary

Constructors
Constructor and Description
`AbstractOpenstackRequest(com.elastisys.scale.commons.openstack.OSClientFactory clientFactory)` Constructs a new `AbstractOpenstackRequest` with a given `OSClientFactory`.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`R` `call()`
`abstract R` `doRequest(org.openstack4j.api.OSClient api)` Carries out the request and returns the response.
`com.elastisys.scale.commons.openstack.ApiAccessConfig` `getApiAccessConfig()` Returns the API access configuration that describes how to authenticate with and communicate over the OpenStack API.
`com.elastisys.scale.commons.openstack.OSClientFactory` `getClientFactory()` Returns the OpenStack API client factory.

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

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

### Constructor Detail

#### AbstractOpenstackRequest

    public AbstractOpenstackRequest(com.elastisys.scale.commons.openstack.OSClientFactory clientFactory)

Constructs a new `AbstractOpenstackRequest` with a given `OSClientFactory`.

Parameters:
  `clientFactory` - OpenStack API client factory

### Method Detail

#### call

    public R call()
           throws RuntimeException

Specified by:
  `call` in interface `Callable<R>`
Throws:
  `RuntimeException`

#### getClientFactory

    public com.elastisys.scale.commons.openstack.OSClientFactory getClientFactory()

Returns the OpenStack API client factory.

Returns:

#### getApiAccessConfig

    public com.elastisys.scale.commons.openstack.ApiAccessConfig getApiAccessConfig()

Returns the API access configuration that describes how to authenticate with and communicate over the OpenStack API.

Returns:

#### doRequest

    public abstract R doRequest(org.openstack4j.api.OSClient api)
                         throws RuntimeException

Carries out the request and returns the response.

Parameters:
  `api` - An authenticated OpenStack API client that is instructed to operate against the configured region.
Returns:
  The response.
Throws:
  `RuntimeException` - if the request failed.