Class RestServiceClient
- java.lang.Object
-
- com.smartgridready.communicator.rest.http.client.RestServiceClient
-
public class RestServiceClient extends java.lang.ObjectImplements an HTTP / REST client.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRestServiceClient(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)Constructs a new instance with empty substitution properties.protectedRestServiceClient(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory, java.util.Map<java.lang.String,java.lang.String> substitutions)Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHeader(java.lang.String key, java.lang.String value)Adds a new request header.com.smartgridready.driver.api.http.GenHttpResponsecallService()Executes the HTTP request.java.lang.StringgetBaseUri()Gets the request's base URI.com.smartgridready.ns.v0.RestApiServiceCallgetRestServiceCall()Gets the SGr specification of the service call.booleanisVerifyCertificate()Tells if SSL certificates are to be verified.static RestServiceClientof(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)Creates a new instance.static RestServiceClientof(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory, java.util.Map<java.lang.String,java.lang.String> substitutions)Creates a new instance.
-
-
-
Constructor Detail
-
RestServiceClient
protected RestServiceClient(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory) throws java.io.IOExceptionConstructs a new instance with empty substitution properties.- Parameters:
baseUri- the base URI for all service callsverifyCertificate- enables or disables SSL certificate validationserviceCall- the service call specificationhttpClientFactory- the HTTP client factory implementation- Throws:
java.io.IOException- when the specification contains errors
-
RestServiceClient
protected RestServiceClient(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory, java.util.Map<java.lang.String,java.lang.String> substitutions) throws java.io.IOExceptionConstructs a new instance.- Parameters:
baseUri- the base URI for all service callsverifyCertificate- enables or disables SSL certificate validationserviceCall- the service call specificationhttpClientFactory- the HTTP client factory implementationsubstitutions- the parameter substitutions- Throws:
java.io.IOException- when the specification contains errors
-
-
Method Detail
-
addHeader
public void addHeader(java.lang.String key, java.lang.String value)Adds a new request header.- Parameters:
key- the header namevalue- the header value
-
getBaseUri
public java.lang.String getBaseUri()
Gets the request's base URI.- Returns:
- a string
-
isVerifyCertificate
public boolean isVerifyCertificate()
Tells if SSL certificates are to be verified.- Returns:
- a boolean
-
getRestServiceCall
public com.smartgridready.ns.v0.RestApiServiceCall getRestServiceCall()
Gets the SGr specification of the service call.- Returns:
- an instance of
RestApiServiceCall
-
callService
public com.smartgridready.driver.api.http.GenHttpResponse callService() throws java.io.IOExceptionExecutes the HTTP request.- Returns:
- an instance of
GenHttpResponse - Throws:
java.io.IOException- when an error occurred
-
of
public static RestServiceClient of(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory) throws java.io.IOException
Creates a new instance.- Parameters:
baseUri- the base URIverifyCertificate- SSL certificate will be verified when trueserviceCall- the SGr specification of the service callhttpClientFactory- the SGr HTTP client factory- Returns:
- a new instance of
RestServiceClient - Throws:
java.io.IOException- when an error occurred
-
of
public static RestServiceClient of(java.lang.String baseUri, boolean verifyCertificate, com.smartgridready.ns.v0.RestApiServiceCall serviceCall, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory, java.util.Map<java.lang.String,java.lang.String> substitutions) throws java.io.IOException
Creates a new instance.- Parameters:
baseUri- the base URIverifyCertificate- SSL certificate will be verified when trueserviceCall- the SGr specification of the service callhttpClientFactory- the SGr HTTP client factorysubstitutions- substitutions of dynamic request parameters- Returns:
- a new instance of
RestServiceClient - Throws:
java.io.IOException- when an error occurred
-
-