Package com.softlayer.api
Class RestApiClient
- java.lang.Object
-
- com.softlayer.api.RestApiClient
-
-
Constructor Summary
Constructors Constructor Description RestApiClient()
RestApiClient(String baseUrl)
Create a Rest client with a custom URL.
-
Method Summary
Modifier and Type Method Description <S extends Service>
ScreateService(Class<S> serviceClass, String id)
Get a service for the given sets of classes and optional ID.String
getBaseUrl()
HttpBasicAuthCredentials
getCredentials()
protected String
getFullUrl(String serviceName, String methodName, String id, ResultLimit resultLimit, String maskString)
Get the full REST URL required to make a request.HttpClientFactory
getHttpClientFactory()
protected String
getHttpMethodFromMethodName(String methodName)
JsonMarshallerFactory
getJsonMarshallerFactory()
boolean
isLoggingEnabled()
protected void
logRequest(String httpMethod, String url, Object[] params)
protected void
logResponse(String url, int statusCode, String body)
void
setHttpClientFactory(HttpClientFactory httpClientFactory)
void
setJsonMarshallerFactory(JsonMarshallerFactory jsonMarshallerFactory)
void
setLoggingEnabled(boolean loggingEnabled)
RestApiClient
withCredentials(String username, String apiKey)
Set the username and API key credentials.RestApiClient
withHttpClientFactory(HttpClientFactory httpClientFactory)
RestApiClient
withJsonMarshallerFactory(JsonMarshallerFactory jsonMarshallerFactory)
RestApiClient
withLoggingEnabled()
protected void
writeParameterHttpBody(Object[] params, OutputStream out)
-
-
-
Field Detail
-
BASE_URL
public static final String BASE_URL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RestApiClient
public RestApiClient()
-
RestApiClient
public RestApiClient(String baseUrl)
Create a Rest client with a custom URL.- Parameters:
baseUrl
- The custom URL the REST client will use.
-
-
Method Detail
-
getBaseUrl
public String getBaseUrl()
-
getHttpClientFactory
public HttpClientFactory getHttpClientFactory()
-
setHttpClientFactory
public void setHttpClientFactory(HttpClientFactory httpClientFactory)
-
withHttpClientFactory
public RestApiClient withHttpClientFactory(HttpClientFactory httpClientFactory)
-
isLoggingEnabled
public boolean isLoggingEnabled()
-
setLoggingEnabled
public void setLoggingEnabled(boolean loggingEnabled)
-
withLoggingEnabled
public RestApiClient withLoggingEnabled()
-
getJsonMarshallerFactory
public JsonMarshallerFactory getJsonMarshallerFactory()
-
setJsonMarshallerFactory
public void setJsonMarshallerFactory(JsonMarshallerFactory jsonMarshallerFactory)
-
withJsonMarshallerFactory
public RestApiClient withJsonMarshallerFactory(JsonMarshallerFactory jsonMarshallerFactory)
-
withCredentials
public RestApiClient withCredentials(String username, String apiKey)
Description copied from interface:ApiClient
Set the username and API key credentials. This is required for most service methods.- Specified by:
withCredentials
in interfaceApiClient
- Returns:
- This instance
-
getCredentials
public HttpBasicAuthCredentials getCredentials()
-
writeParameterHttpBody
protected void writeParameterHttpBody(Object[] params, OutputStream out)
-
getFullUrl
protected String getFullUrl(String serviceName, String methodName, String id, ResultLimit resultLimit, String maskString)
Get the full REST URL required to make a request.- Parameters:
serviceName
- The name of the API service.methodName
- The name of the method on the service to call.id
- The identifier of the object to make a call to, otherwise null if not making a request to a specific object.resultLimit
- The number of results to limit the request to.maskString
- The mask, in string form, to use on the request.- Returns:
- String
-
createService
public <S extends Service> S createService(Class<S> serviceClass, String id)
Description copied from interface:ApiClient
Get a service for the given sets of classes and optional ID. It is not recommended to call this directly, but rather invoke the service method on the type class. E.g.Account.service(ApiClient)
.- Specified by:
createService
in interfaceApiClient
-
-