Package zowe.client.sdk.rest
Class ZosmfRequest
- java.lang.Object
-
- zowe.client.sdk.rest.ZosmfRequest
-
- Direct Known Subclasses:
DeleteJsonZosmfRequest,GetJsonZosmfRequest,GetStreamZosmfRequest,GetTextZosmfRequest,PostJsonZosmfRequest,PutJsonZosmfRequest,PutStreamZosmfRequest,PutTextZosmfRequest
public abstract class ZosmfRequest extends Object
Base abstract class that conforms to Http CRUD operations- Version:
- 3.0
- Author:
- Frank Giordano
-
-
Field Summary
Fields Modifier and Type Field Description protected ZosConnectionconnectionprotected kong.unirest.core.Cookiecookieprotected Map<String,String>headersprotected Stringurlstatic StringX_CSRF_ZOSMF_HEADER_KEYstatic StringX_CSRF_ZOSMF_HEADER_VALUE
-
Constructor Summary
Constructors Constructor Description ZosmfRequest(ZosConnection connection)ZosmfRequest constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> ResponsebuildResponse(kong.unirest.core.HttpResponse<T> reply)Build Response object from given HttpResponse replyabstract ResponseexecuteRequest()Perform the http rest requestabstract voidsetBody(Object body)Set the body information for the http requestvoidsetCookie(kong.unirest.core.Cookie cookie)Set a cookie token for this request.voidsetHeaders(Map<String,String> headers)Set any headers needed for the http requestabstract voidsetStandardHeaders()Set the standard headers for the http requestvoidsetUrl(String url)Set the url needed for the http request
-
-
-
Field Detail
-
X_CSRF_ZOSMF_HEADER_KEY
public static final String X_CSRF_ZOSMF_HEADER_KEY
-
X_CSRF_ZOSMF_HEADER_VALUE
public static final String X_CSRF_ZOSMF_HEADER_VALUE
-
connection
protected final ZosConnection connection
-
url
protected String url
-
cookie
protected kong.unirest.core.Cookie cookie
-
-
Constructor Detail
-
ZosmfRequest
public ZosmfRequest(ZosConnection connection)
ZosmfRequest constructor- Parameters:
connection- connection information, see ZosConnection object
-
-
Method Detail
-
buildResponse
public <T> Response buildResponse(kong.unirest.core.HttpResponse<T> reply) throws ZosmfRequestException
Build Response object from given HttpResponse reply- Type Parameters:
T- either JsonNode, String or byte[] type- Parameters:
reply- HttpResponse object- Returns:
- Response object
- Throws:
ZosmfRequestException- request error state
-
executeRequest
public abstract Response executeRequest() throws ZosmfRequestException
Perform the http rest request- Returns:
- Response object
- Throws:
ZosmfRequestException- request error state
-
setBody
public abstract void setBody(Object body)
Set the body information for the http request- Parameters:
body- object value
-
setHeaders
public void setHeaders(Map<String,String> headers)
Set any headers needed for the http request- Parameters:
headers- headers to add to the request
-
setStandardHeaders
public abstract void setStandardHeaders()
Set the standard headers for the http request
-
setUrl
public void setUrl(String url) throws IllegalArgumentException
Set the url needed for the http request- Parameters:
url- rest url end point- Throws:
IllegalArgumentException- error setting valid url string
-
setCookie
public void setCookie(kong.unirest.core.Cookie cookie)
Set a cookie token for this request. This is optional for most requests and not needed. Setting the cookie will remove the HTTP header authentication. Setting the cookie value as null after giving it a value will revert/enable the HTTP header authentication for future requests.- Parameters:
cookie- object
-
-