Class RequestInformation

java.lang.Object
com.microsoft.kiota.RequestInformation

public class RequestInformation extends Object
This class represents an abstract HTTP request.
  • Field Details

    • urlTemplate

      @Nullable public String urlTemplate
      The url template for the current request
    • pathParameters

      @Nullable public Map<String,Object> pathParameters
      The path parameters for the current request
    • httpMethod

      @Nullable public HttpMethod httpMethod
      The HTTP method for the request
    • headers

      @Nonnull public final RequestHeaders headers
      The request headers
    • content

      @Nullable public InputStream content
      The Request Body.
  • Constructor Details

    • RequestInformation

      public RequestInformation()
      Creates a new instance of the request information class.
    • RequestInformation

      public RequestInformation(@Nonnull HttpMethod method, @Nonnull String urlTemplate, @Nonnull Map<String,Object> pathParameters)
      Creates a new instance of the request information class.
      Parameters:
      method - The HTTP method for the request.
      urlTemplate - The url template for the request.
      pathParameters - The path parameters for the request.
  • Method Details

    • configure

      public <T extends BaseRequestConfiguration> void configure(@Nullable Consumer<T> requestConfiguration, @Nonnull Supplier<T> configurationFactory)
      Configures the request information based on the request configuration and the query parameters getter.
      Type Parameters:
      T - The type of the request configuration.
      Parameters:
      requestConfiguration - The request configuration to apply to the request information.
      configurationFactory - The factory to create the request configuration from.
    • configure

      public <T extends BaseRequestConfiguration> void configure(@Nullable Consumer<T> requestConfiguration, @Nonnull Supplier<T> configurationFactory, @Nullable Function<T,QueryParameters> queryParametersGetter)
      Configures the request information based on the request configuration and the query parameters getter.
      Type Parameters:
      T - The type of the request configuration.
      Parameters:
      requestConfiguration - The request configuration to apply to the request information.
      configurationFactory - The factory to create the request configuration from.
      queryParametersGetter - The function to get the query parameters from the request configuration.
    • getUri

      @Nullable public URI getUri() throws URISyntaxException, IllegalStateException
      Gets the URI of the request.
      Returns:
      the URI of the request.
      Throws:
      URISyntaxException - when the uri template is invalid.
      IllegalStateException - when the baseurl template parameter is missing from the path parameters.
    • setUri

      public void setUri(@Nonnull URI uri)
      Sets the URI of the request.
      Parameters:
      uri - the URI of the request.
    • addQueryParameters

      public void addQueryParameters(@Nullable QueryParameters parameters)
      Adds query parameters to the request based on the object passed in and its fields.
      Parameters:
      parameters - The object to add the query parameters from.
    • addQueryParameter

      public void addQueryParameter(@Nonnull String name, @Nullable Object value)
      Adds query parameters to the request.
      Parameters:
      name - The name of the query parameter.
      value - The value to add the query parameters.
    • removeQueryParameter

      public void removeQueryParameter(@Nonnull String name)
      Removes a query parameter from the request.
      Parameters:
      name - The name of the query parameter to remove.
    • getQueryParameters

      @Nonnull public Map<String,Object> getQueryParameters()
      Gets the query parameters for the request.
      Returns:
      The query parameters for the request.
    • getRequestOptions

      @Nonnull public Collection<RequestOption> getRequestOptions()
      Gets the request options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins.
      Returns:
      the request options for this request.
    • addRequestOptions

      public void addRequestOptions(@Nullable Collection<RequestOption> options)
      Adds request options to this request.
      Parameters:
      options - the request options to add.
    • removeRequestOptions

      public void removeRequestOptions(@Nullable RequestOption... options)
      Removes a request option from this request.
      Parameters:
      options - the request option to remove.
    • setResponseHandler

      public void setResponseHandler(@Nonnull ResponseHandler responseHandler)
      Adds a response handler as a RequestOption.
      Parameters:
      responseHandler - the response handler to add to the request.
    • setStreamContent

      @Deprecated public void setStreamContent(@Nonnull InputStream value)
      Deprecated.
      Sets the request body to be a binary stream.
      Parameters:
      value - the binary stream
    • setStreamContent

      public void setStreamContent(@Nonnull InputStream value, @Nonnull String contentType)
      Sets the request body to be a binary stream.
      Parameters:
      value - the binary stream
      contentType - the content type of the stream.
    • setContentFromParsable

      public <T extends Parsable> void setContentFromParsable(@Nonnull RequestAdapter requestAdapter, @Nonnull String contentType, @Nonnull T[] values)
      Sets the request body from a model with the specified content type.
      Type Parameters:
      T - the model type.
      Parameters:
      requestAdapter - The adapter service to get the serialization writer from.
      contentType - the content type.
      values - the models.
    • setContentFromParsable

      public <T extends Parsable> void setContentFromParsable(@Nonnull RequestAdapter requestAdapter, @Nonnull String contentType, @Nonnull T value)
      Sets the request body from a model with the specified content type.
      Type Parameters:
      T - the model type.
      Parameters:
      requestAdapter - The adapter service to get the serialization writer from.
      contentType - the content type.
      value - the model.
    • setContentFromScalar

      public <T> void setContentFromScalar(@Nonnull RequestAdapter requestAdapter, @Nonnull String contentType, @Nonnull T value)
      Sets the request body from a scalar value with the specified content type.
      Type Parameters:
      T - the model type.
      Parameters:
      requestAdapter - The adapter service to get the serialization writer from.
      contentType - the content type.
      value - the scalar values to serialize.
    • setContentFromScalarCollection

      public <T> void setContentFromScalarCollection(@Nonnull RequestAdapter requestAdapter, @Nonnull String contentType, @Nonnull T[] values)
      Sets the request body from a scalar value with the specified content type.
      Type Parameters:
      T - the model type.
      Parameters:
      requestAdapter - The adapter service to get the serialization writer from.
      contentType - the content type.
      values - the scalar values to serialize.