Class HttpRequestContext

java.lang.Object
io.clientcore.annotation.processor.models.HttpRequestContext

public final class HttpRequestContext extends Object
Represents the context of an HTTP request, including its configuration, parameters, headers, and other details.
  • Constructor Details

    • HttpRequestContext

      public HttpRequestContext()
      Constructs a new HttpRequestContext with default values.
  • Method Details

    • getMethodName

      public String getMethodName()
      Gets the method name.
      Returns:
      the method name.
    • setMethodName

      public void setMethodName(String methodName)
      Sets the method name.
      Parameters:
      methodName - the method name to set.
    • getMethodReturnType

      public TypeMirror getMethodReturnType()
      Gets the method return type.
      Returns:
      the method return type.
    • setMethodReturnType

      public void setMethodReturnType(TypeMirror methodReturnType)
      Sets the method return type.
      Parameters:
      methodReturnType - the method return type to set.
    • addParameter

      public void addParameter(HttpRequestContext.MethodParameter parameter)
      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 available getUriParameterName() choice left.
    • getParameters

      public List<HttpRequestContext.MethodParameter> getParameters()
      Gets the list of parameters.
      Returns:
      the list of parameters.
    • getUriParameterName

      public String 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

      public String getHost()
      Gets the host.
      Returns:
      the host.
    • setHost

      public void setHost(String host)
      Sets the host.
      Parameters:
      host - the host to set.
    • getPath

      public String getPath()
      Gets the path.
      Returns:
      the path.
    • setPath

      public void setPath(String path)
      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

      public Map<String,List<String>> getHeaders()
      Gets the headers.
      Returns:
      the headers.
    • addHeader

      public void addHeader(String key, String value)
      Adds a header.
      Parameters:
      key - the header key.
      value - the header value.
    • getQueryParams

      public Map<String,HttpRequestContext.QueryParameter> 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

      public void addSubstitution(Substitution substitution)
      Adds a substitution.
      Parameters:
      substitution - the substitution to add.
      Throws:
      IllegalArgumentException - if a duplicate substitution is added.
    • getSubstitution

      public Substitution getSubstitution(String parameterName)
      Gets a substitution by parameter name.
      Parameters:
      parameterName - the parameter name.
      Returns:
      the substitution.
    • setBody

      public void setBody(HttpRequestContext.Body body)
      Sets the body.
      Parameters:
      body - the body to set.
    • getBody

      public HttpRequestContext.Body 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

      public List<Integer> 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

      public void addStaticHeaders(String[] headers)
      Sets the static headers from an array of strings.
      Parameters:
      headers - the array of headers to set.
    • addStaticQueryParams

      public void addStaticQueryParams(String[] queryParams)
      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

      public Map<Integer,HttpRequestContext.ExceptionBodyTypeInfo> getExceptionBodyMappings()
      Gets the exception body mappings.
      Returns:
      the exception body mappings.
    • setDefaultExceptionBodyType

      public void setDefaultExceptionBodyType(TypeMirror type)
      Sets the default exception body type.
      Parameters:
      type - the default exception body type to set.
    • getDefaultExceptionBodyType

      public TypeMirror 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

      public void setReturnValueWireType(TypeMirror returnValueWireType)
      Sets the return value wire type.
      Parameters:
      returnValueWireType - the return value wire type to set.
    • getReturnValueWireType

      public TypeMirror getReturnValueWireType()
      Gets the return value wire type.
      Returns:
      the return value wire type.