Package com.microsoft.kiota.http
Class OkHttpRequestAdapter
java.lang.Object
com.microsoft.kiota.http.OkHttpRequestAdapter
- All Implemented Interfaces:
com.microsoft.kiota.RequestAdapter
RequestAdapter implementation for OkHttp
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey used for events when an authentication challenge is returned by the APIstatic final StringKey used for the attribute when an error response body is foundstatic final Stringkey used for the attribute when the error response has models mappings providedstatic final StringThe key used for the event when a custom response handler is invoked. -
Constructor Summary
ConstructorsConstructorDescriptionOkHttpRequestAdapter(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 TypeMethodDescription<T> TconvertToNativeRequest(com.microsoft.kiota.RequestInformation requestInfo) voidenableBackingStore(com.microsoft.kiota.store.BackingStoreFactory backingStoreFactory) protected okhttp3.RequestgetRequestFromRequestInformation(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>
ModelTypesend(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>>
ModelTypesendEnum(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) 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>
ModelTypesendPrimitive(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) voidsetBaseUrl(String baseUrl)
-
Field Details
-
eventResponseHandlerInvokedKey
The key used for the event when a custom response handler is invoked.- See Also:
-
errorMappingFoundAttributeName
key used for the attribute when the error response has models mappings provided- See Also:
-
errorBodyFoundAttributeName
Key used for the attribute when an error response body is found- See Also:
-
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
- Specified by:
setBaseUrlin interfacecom.microsoft.kiota.RequestAdapter
-
getBaseUrl
- Specified by:
getBaseUrlin interfacecom.microsoft.kiota.RequestAdapter
-
getSerializationWriterFactory
@Nonnull public com.microsoft.kiota.serialization.SerializationWriterFactory getSerializationWriterFactory()- Specified by:
getSerializationWriterFactoryin interfacecom.microsoft.kiota.RequestAdapter
-
enableBackingStore
public void enableBackingStore(@Nullable com.microsoft.kiota.store.BackingStoreFactory backingStoreFactory) - Specified by:
enableBackingStorein interfacecom.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:
sendCollectionin interfacecom.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:
sendin interfacecom.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:
sendPrimitivein interfacecom.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:
sendEnumin interfacecom.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:
sendEnumCollectionin interfacecom.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:
sendPrimitiveCollectionin interfacecom.microsoft.kiota.RequestAdapter
-
convertToNativeRequest
@Nonnull public <T> T convertToNativeRequest(@Nonnull com.microsoft.kiota.RequestInformation requestInfo) - Specified by:
convertToNativeRequestin interfacecom.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.
-