Class HttpRequestContext
java.lang.Object
io.clientcore.annotation.processor.models.HttpRequestContext
Represents the context of an HTTP request, including its configuration, parameters, headers, and other details.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the body of an HTTP request.static classRepresents information about the exception body type used in the HTTP request context.static classRepresents a method parameter.static classRepresents a query parameter. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new HttpRequestContext with default values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExceptionBodyMapping(int statusCode, HttpRequestContext.ExceptionBodyTypeInfo exceptionBodyClassName) Adds an exception body mapping.voidAdds a header.voidaddParameter(HttpRequestContext.MethodParameter parameter) Adds a parameter to the method.voidaddQueryParam(String key, String value, boolean isMultiple, boolean shouldEncode, boolean isStatic) Adds a query parameter.voidaddStaticHeaders(String[] headers) Sets the static headers from an array of strings.voidaddStaticQueryParams(String[] queryParams) Sets the static query parameters from an array of strings.voidaddSubstitution(Substitution substitution) Adds a substitution.getBody()Gets the body.Gets the default exception body type.Gets the exception body mappings.Gets the expected status codes.Gets the headers.getHost()Gets the host.io.clientcore.core.http.models.HttpMethodGets the HTTP method.Gets the method name.Gets the method return type.Gets the list of parameters.getPath()Gets the path.Gets the query parameters.Gets the return value wire type.getSubstitution(String parameterName) Gets a substitution by parameter name.Gets the variable name that is used when creating the HttpRequest.uri.booleanGets the boolean to true if the provided method is a default methodbooleanIndicates whether the interface had a host configured.booleanChecks if the URI is a {nextlink}.voidSets the body.voidSets the default exception body type.voidsetExpectedStatusCodes(int[] expectedStatusCodes) Sets the expected status codes.voidSets the host.voidsetHttpMethod(io.clientcore.core.http.models.HttpMethod httpMethod) Sets the HTTP method.voidsetIsConvenience(boolean isConvenience) Sets the boolean to true if the provided method is a default methodvoidsetIsUriNextLink(boolean isUriNextLink) Sets whether the URI is a {nextlink}.voidsetMethodName(String methodName) Sets the method name.voidsetMethodReturnType(TypeMirror methodReturnType) Sets the method return type.voidSets the path.voidsetReturnValueWireType(TypeMirror returnValueWireType) Sets the return value wire type.voidsetTemplateHasHost(boolean templateHasHost) Sets whether the interface had a host configured.
-
Constructor Details
-
HttpRequestContext
public HttpRequestContext()Constructs a new HttpRequestContext with default values.
-
-
Method Details
-
getMethodName
Gets the method name.- Returns:
- the method name.
-
setMethodName
Sets the method name.- Parameters:
methodName- the method name to set.
-
getMethodReturnType
Gets the method return type.- Returns:
- the method return type.
-
setMethodReturnType
Sets the method return type.- Parameters:
methodReturnType- the method return type to set.
-
addParameter
Adds a parameter to the method.- Parameters:
parameter- the parameter to add.- Throws:
IllegalStateException- If the addition of the parameter caused there to be no availablegetUriParameterName()choice left.
-
getParameters
Gets the list of parameters.- Returns:
- the list of parameters.
-
getUriParameterName
Gets the variable name that is used when creating the HttpRequest.uri.- Returns:
- The variable name used when creating the HttpRequest.uri.
-
isTemplateHasHost
public boolean isTemplateHasHost()Indicates whether the interface had a host configured.- Returns:
- Whether the interface had a host configured.
-
setTemplateHasHost
public void setTemplateHasHost(boolean templateHasHost) Sets whether the interface had a host configured.- Parameters:
templateHasHost- Whether the interface had a host configured.
-
getHost
Gets the host.- Returns:
- the host.
-
setHost
Sets the host.- Parameters:
host- the host to set.
-
getPath
Gets the path.- Returns:
- the path.
-
setPath
Sets the path.- Parameters:
path- the path to set.
-
getHttpMethod
public io.clientcore.core.http.models.HttpMethod getHttpMethod()Gets the HTTP method.- Returns:
- the HTTP method.
-
setHttpMethod
public void setHttpMethod(io.clientcore.core.http.models.HttpMethod httpMethod) Sets the HTTP method.- Parameters:
httpMethod- the HTTP method to set.
-
getHeaders
Gets the headers.- Returns:
- the headers.
-
addHeader
Adds a header.- Parameters:
key- the header key.value- the header value.
-
getQueryParams
Gets the query parameters.- Returns:
- the query parameters.
-
addQueryParam
public void addQueryParam(String key, String value, boolean isMultiple, boolean shouldEncode, boolean isStatic) Adds a query parameter.- Parameters:
key- the query parameter key.value- the query parameter value.isMultiple- Whether this query parameter list values should be sent as individual query param.shouldEncode- Whether the query parameter value is URL encoded.isStatic- Whether the query parameter is a static value.
-
addSubstitution
Adds a substitution.- Parameters:
substitution- the substitution to add.- Throws:
IllegalArgumentException- if a duplicate substitution is added.
-
getSubstitution
Gets a substitution by parameter name.- Parameters:
parameterName- the parameter name.- Returns:
- the substitution.
-
setBody
Sets the body.- Parameters:
body- the body to set.
-
getBody
Gets the body.- Returns:
- the body.
-
setExpectedStatusCodes
public void setExpectedStatusCodes(int[] expectedStatusCodes) Sets the expected status codes.- Parameters:
expectedStatusCodes- the expected status codes to set.
-
getExpectedStatusCodes
Gets the expected status codes.- Returns:
- the expected status codes.
-
isConvenience
public boolean isConvenience()Gets the boolean to true if the provided method is a default method- Returns:
- the boolean to true if the provided method is a default method
-
setIsConvenience
public void setIsConvenience(boolean isConvenience) Sets the boolean to true if the provided method is a default method- Parameters:
isConvenience- the provided method is a default method
-
addStaticHeaders
Sets the static headers from an array of strings.- Parameters:
headers- the array of headers to set.
-
addStaticQueryParams
Sets the static query parameters from an array of strings.- Parameters:
queryParams- the array of query parameters to set.
-
addExceptionBodyMapping
public void addExceptionBodyMapping(int statusCode, HttpRequestContext.ExceptionBodyTypeInfo exceptionBodyClassName) Adds an exception body mapping.- Parameters:
statusCode- the status code.exceptionBodyClassName- the exception body class name.
-
getExceptionBodyMappings
Gets the exception body mappings.- Returns:
- the exception body mappings.
-
setDefaultExceptionBodyType
Sets the default exception body type.- Parameters:
type- the default exception body type to set.
-
getDefaultExceptionBodyType
Gets the default exception body type.- Returns:
- the default exception body type.
-
setIsUriNextLink
public void setIsUriNextLink(boolean isUriNextLink) Sets whether the URI is a {nextlink}.- Parameters:
isUriNextLink- true if it is a {nextlink}, false otherwise.
-
isUriNextLink
public boolean isUriNextLink()Checks if the URI is a {nextlink}.- Returns:
- true if it is a {nextlink}, false otherwise.
-
setReturnValueWireType
Sets the return value wire type.- Parameters:
returnValueWireType- the return value wire type to set.
-
getReturnValueWireType
Gets the return value wire type.- Returns:
- the return value wire type.
-