Package org.openstack4j.core.transport
Class HttpRequest<R>
- java.lang.Object
-
- org.openstack4j.core.transport.HttpRequest<R>
-
- Type Parameters:
R
- the entity return type
public class HttpRequest<R> extends Object
A Request Delegate which aids in building the request that is compatible with the OpenStack Rest API. The request is used to encoding as well as keeping reference to the return type- Author:
- Jeremy Unruh
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpRequest.RequestBuilder<R>
-
Constructor Summary
Constructors Constructor Description HttpRequest()
HttpRequest(String endpoint, String path, HttpMethod method, ModelEntity entity, Class<R> returnType)
Creates a new HttpRequest
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HttpRequest.RequestBuilder<Void>
builder()
A build for creating HttpRequest objectsstatic <R> HttpRequest.RequestBuilder<R>
builder(Class<R> returnType)
A build for creating HttpRequest objectsConfig
getConfig()
String
getContentType()
String
getEndpoint()
Object
getEntity()
Map<String,Object>
getHeaders()
String
getJson()
If JSON is explicitly set vs an entity then this method will return a JSON String otherwise EmptyHttpMethod
getMethod()
String
getPath()
Map<String,List<Object>>
getQueryParams()
Class<R>
getReturnType()
String
getUrl()
Append query parameters into the url.boolean
hasHeaders()
boolean
hasJson()
boolean
hasQueryParams()
HttpRequest.RequestBuilder<R>
toBuilder()
-
-
-
Constructor Detail
-
HttpRequest
public HttpRequest()
-
HttpRequest
public HttpRequest(String endpoint, String path, HttpMethod method, ModelEntity entity, Class<R> returnType)
Creates a new HttpRequest- Parameters:
endpoint
- the endpoint URIpath
- the path which will be appended to the endpoint URImethod
- the method the method type to invokeentity
- the entity (used for posts)returnType
- the expected return type
-
-
Method Detail
-
builder
public static HttpRequest.RequestBuilder<Void> builder()
A build for creating HttpRequest objects- Returns:
- the request builder
-
builder
public static <R> HttpRequest.RequestBuilder<R> builder(Class<R> returnType)
A build for creating HttpRequest objects- Type Parameters:
R
- the expected return type- Parameters:
returnType
- the return type- Returns:
- the request builder
-
getMethod
public HttpMethod getMethod()
- Returns:
- the method this request will use
-
getContentType
public String getContentType()
- Returns:
- the content type for the request
-
getEndpoint
public String getEndpoint()
- Returns:
- the endpoint URI
-
getPath
public String getPath()
- Returns:
- the http path
-
getJson
public String getJson()
If JSON is explicitly set vs an entity then this method will return a JSON String otherwise Empty- Returns:
- JSON String form or Empty
-
hasJson
public boolean hasJson()
- Returns:
- true, if a JSON Object has been set
-
getEntity
public Object getEntity()
- Returns:
- the entity to post
-
hasQueryParams
public boolean hasQueryParams()
- Returns:
- true, if query params have been added
-
hasHeaders
public boolean hasHeaders()
- Returns:
- true, if headers have been added
-
toBuilder
public HttpRequest.RequestBuilder<R> toBuilder()
-
getConfig
public Config getConfig()
- Returns:
- the client configuration associated with this request
-
getUrl
public String getUrl()
Append query parameters into the url.
-
-