Class OkHttpRequestAdapter

java.lang.Object
com.microsoft.kiota.http.OkHttpRequestAdapter
All Implemented Interfaces:
com.microsoft.kiota.RequestAdapter

public class OkHttpRequestAdapter extends Object implements com.microsoft.kiota.RequestAdapter
RequestAdapter implementation for OkHttp
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Key used for events when an authentication challenge is returned by the API
    static final String
    Key used for the attribute when an error response body is found
    static final String
    key used for the attribute when the error response has models mappings provided
    static final String
    The key used for the event when a custom response handler is invoked.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OkHttpRequestAdapter(com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider)
    Instantiates a new OkHttp request adapter with the provided authentication provider.
    OkHttpRequestAdapter(com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory)
    Instantiates a new OkHttp request adapter with the provided authentication provider, and the parse node factory.
    OkHttpRequestAdapter(com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory)
    Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, and the serialization writer factory.
    OkHttpRequestAdapter(com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory, okhttp3.Call.Factory client)
    Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, serialization writer factory, and the http client.
    OkHttpRequestAdapter(com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory, okhttp3.Call.Factory client, ObservabilityOptions observabilityOptions)
    Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, serialization writer factory, http client and observability options.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    convertToNativeRequest(com.microsoft.kiota.RequestInformation requestInfo)
    void
    enableBackingStore(com.microsoft.kiota.store.BackingStoreFactory backingStoreFactory)
     
     
    protected okhttp3.Request
    getRequestFromRequestInformation(com.microsoft.kiota.RequestInformation requestInfo, io.opentelemetry.api.trace.Span parentSpan, io.opentelemetry.api.trace.Span spanForAttributes)
    Creates a new request from the request information instance.
    com.microsoft.kiota.serialization.SerializationWriterFactory
     
    <ModelType extends com.microsoft.kiota.serialization.Parsable>
    ModelType
    send(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, com.microsoft.kiota.serialization.ParsableFactory<ModelType> factory)
     
    <ModelType extends com.microsoft.kiota.serialization.Parsable>
    List<ModelType>
    sendCollection(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, com.microsoft.kiota.serialization.ParsableFactory<ModelType> factory)
     
    <ModelType extends Enum<ModelType>>
    ModelType
    sendEnum(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, com.microsoft.kiota.serialization.ValuedEnumParser<ModelType> enumParser)
     
    <ModelType extends Enum<ModelType>>
    List<ModelType>
    sendEnumCollection(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, com.microsoft.kiota.serialization.ValuedEnumParser<ModelType> enumParser)
     
    <ModelType>
    ModelType
    sendPrimitive(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, Class<ModelType> targetClass)
     
    <ModelType>
    List<ModelType>
    sendPrimitiveCollection(com.microsoft.kiota.RequestInformation requestInfo, HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, Class<ModelType> targetClass)
     
    void
    setBaseUrl(String baseUrl)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • eventResponseHandlerInvokedKey

      @Nonnull public static final String eventResponseHandlerInvokedKey
      The key used for the event when a custom response handler is invoked.
      See Also:
    • errorMappingFoundAttributeName

      @Nonnull public static final String errorMappingFoundAttributeName
      key used for the attribute when the error response has models mappings provided
      See Also:
    • errorBodyFoundAttributeName

      @Nonnull public static final String errorBodyFoundAttributeName
      Key used for the attribute when an error response body is found
      See Also:
    • authenticateChallengedEventKey

      @Nonnull public static final String authenticateChallengedEventKey
      Key used for events when an authentication challenge is returned by the API
      See Also:
  • Constructor Details

    • OkHttpRequestAdapter

      public OkHttpRequestAdapter(@Nonnull com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider)
      Instantiates a new OkHttp request adapter with the provided authentication provider.
      Parameters:
      authenticationProvider - the authentication provider to use for authenticating requests.
    • OkHttpRequestAdapter

      public OkHttpRequestAdapter(@Nonnull com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, @Nullable com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory)
      Instantiates a new OkHttp request adapter with the provided authentication provider, and the parse node factory.
      Parameters:
      authenticationProvider - the authentication provider to use for authenticating requests.
      parseNodeFactory - the parse node factory to use for parsing responses.
    • OkHttpRequestAdapter

      public OkHttpRequestAdapter(@Nonnull com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, @Nullable com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, @Nullable com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory)
      Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, and the serialization writer factory.
      Parameters:
      authenticationProvider - the authentication provider to use for authenticating requests.
      parseNodeFactory - the parse node factory to use for parsing responses.
      serializationWriterFactory - the serialization writer factory to use for serializing requests.
    • OkHttpRequestAdapter

      public OkHttpRequestAdapter(@Nonnull com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, @Nullable com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, @Nullable com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory, @Nullable okhttp3.Call.Factory client)
      Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, serialization writer factory, and the http client.
      Parameters:
      authenticationProvider - the authentication provider to use for authenticating requests.
      parseNodeFactory - the parse node factory to use for parsing responses.
      serializationWriterFactory - the serialization writer factory to use for serializing requests.
      client - the http client to use for sending requests.
    • OkHttpRequestAdapter

      public OkHttpRequestAdapter(@Nonnull com.microsoft.kiota.authentication.AuthenticationProvider authenticationProvider, @Nullable com.microsoft.kiota.serialization.ParseNodeFactory parseNodeFactory, @Nullable com.microsoft.kiota.serialization.SerializationWriterFactory serializationWriterFactory, @Nullable okhttp3.Call.Factory client, @Nullable ObservabilityOptions observabilityOptions)
      Instantiates a new OkHttp request adapter with the provided authentication provider, parse node factory, serialization writer factory, http client and observability options.
      Parameters:
      authenticationProvider - the authentication provider to use for authenticating requests.
      parseNodeFactory - the parse node factory to use for parsing responses.
      serializationWriterFactory - the serialization writer factory to use for serializing requests.
      client - the http client to use for sending requests.
      observabilityOptions - the observability options to use for sending requests.
  • Method Details

    • setBaseUrl

      public void setBaseUrl(@Nonnull String baseUrl)
      Specified by:
      setBaseUrl in interface com.microsoft.kiota.RequestAdapter
    • getBaseUrl

      @Nonnull public String getBaseUrl()
      Specified by:
      getBaseUrl in interface com.microsoft.kiota.RequestAdapter
    • getSerializationWriterFactory

      @Nonnull public com.microsoft.kiota.serialization.SerializationWriterFactory getSerializationWriterFactory()
      Specified by:
      getSerializationWriterFactory in interface com.microsoft.kiota.RequestAdapter
    • enableBackingStore

      public void enableBackingStore(@Nullable com.microsoft.kiota.store.BackingStoreFactory backingStoreFactory)
      Specified by:
      enableBackingStore in interface com.microsoft.kiota.RequestAdapter
    • sendCollection

      @Nullable public <ModelType extends com.microsoft.kiota.serialization.Parsable> List<ModelType> sendCollection(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull com.microsoft.kiota.serialization.ParsableFactory<ModelType> factory)
      Specified by:
      sendCollection in interface com.microsoft.kiota.RequestAdapter
    • send

      @Nullable public <ModelType extends com.microsoft.kiota.serialization.Parsable> ModelType send(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull com.microsoft.kiota.serialization.ParsableFactory<ModelType> factory)
      Specified by:
      send in interface com.microsoft.kiota.RequestAdapter
    • sendPrimitive

      @Nullable public <ModelType> ModelType sendPrimitive(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull Class<ModelType> targetClass)
      Specified by:
      sendPrimitive in interface com.microsoft.kiota.RequestAdapter
    • sendEnum

      @Nullable public <ModelType extends Enum<ModelType>> ModelType sendEnum(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull com.microsoft.kiota.serialization.ValuedEnumParser<ModelType> enumParser)
      Specified by:
      sendEnum in interface com.microsoft.kiota.RequestAdapter
    • sendEnumCollection

      @Nullable public <ModelType extends Enum<ModelType>> List<ModelType> sendEnumCollection(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull com.microsoft.kiota.serialization.ValuedEnumParser<ModelType> enumParser)
      Specified by:
      sendEnumCollection in interface com.microsoft.kiota.RequestAdapter
    • sendPrimitiveCollection

      @Nullable public <ModelType> List<ModelType> sendPrimitiveCollection(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nullable HashMap<String,com.microsoft.kiota.serialization.ParsableFactory<? extends com.microsoft.kiota.serialization.Parsable>> errorMappings, @Nonnull Class<ModelType> targetClass)
      Specified by:
      sendPrimitiveCollection in interface com.microsoft.kiota.RequestAdapter
    • convertToNativeRequest

      @Nonnull public <T> T convertToNativeRequest(@Nonnull com.microsoft.kiota.RequestInformation requestInfo)
      Specified by:
      convertToNativeRequest in interface com.microsoft.kiota.RequestAdapter
    • getRequestFromRequestInformation

      @Nonnull protected okhttp3.Request getRequestFromRequestInformation(@Nonnull com.microsoft.kiota.RequestInformation requestInfo, @Nonnull io.opentelemetry.api.trace.Span parentSpan, @Nonnull io.opentelemetry.api.trace.Span spanForAttributes) throws URISyntaxException, IOException
      Creates a new request from the request information instance.
      Parameters:
      requestInfo - request information instance.
      parentSpan - the parent span for telemetry.
      spanForAttributes - the span for the attributes.
      Returns:
      the created request instance.
      Throws:
      URISyntaxException - if the URI is invalid.
      IOException - if the URL is invalid.