com.microsoft.kiota.RequestAdapter Maven / Gradle / Ivy
package com.microsoft.kiota;
import com.microsoft.kiota.serialization.Parsable;
import com.microsoft.kiota.serialization.ParsableFactory;
import com.microsoft.kiota.serialization.SerializationWriterFactory;
import com.microsoft.kiota.serialization.ValuedEnumParser;
import com.microsoft.kiota.store.BackingStoreFactory;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
/** Service responsible for translating abstract Request Info into concrete native HTTP requests. */
public interface RequestAdapter {
/**
* Enables the backing store proxies for the SerializationWriters and ParseNodes in use.
* @param backingStoreFactory The backing store factory to use.
*/
void enableBackingStore(@Nullable final BackingStoreFactory backingStoreFactory);
/**
* Gets the serialization writer factory currently in use for the HTTP core service.
* @return the serialization writer factory currently in use for the HTTP core service.
*/
@Nonnull SerializationWriterFactory getSerializationWriterFactory();
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized response model.
* @param requestInfo the request info to execute.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param factory the factory to create the parsable object from the type discriminator.
* @param the type of the response model to deserialize the response into.
* @return the deserialized response model.
*/
@Nullable ModelType send(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final ParsableFactory factory);
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized response model collection.
* @param requestInfo the request info to execute.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param factory the factory to create the parsable object from the type discriminator.
* @param the type of the response model to deserialize the response into.
* @return the deserialized response model collection.
*/
@Nullable List sendCollection(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final ParsableFactory factory);
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model.
* @param requestInfo the request info to execute.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param targetClass the class of the response model to deserialize the response into.
* @param the type of the response model to deserialize the response into.
* @return the deserialized primitive response model.
*/
@Nullable ModelType sendPrimitive(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final Class targetClass);
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive collection response model.
* @param requestInfo the request info to execute.
* @param targetClass the class of the response model to deserialize the response into.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param the type of the response model to deserialize the response into.
* @return the deserialized primitive collection response model.
*/
@Nullable List sendPrimitiveCollection(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final Class targetClass);
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized enum value.
* @param requestInfo the request info to execute.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param enumParser a parser from string to enum instances.
* @param the type of the response model to deserialize the response into.
* @return the deserialized primitive response model.
*/
@Nullable > ModelType sendEnum(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final ValuedEnumParser enumParser);
/**
* Executes the HTTP request specified by the given RequestInformation and returns the deserialized enum collection value.
* @param requestInfo the request info to execute.
* @param errorMappings the error factories mapping to use in case of a failed request.
* @param enumParser a parser from string to enum instances.
* @param the type of the response model to deserialize the response into.
* @return the deserialized primitive response model.
*/
@Nullable > List sendEnumCollection(
@Nonnull final RequestInformation requestInfo,
@Nullable final HashMap> errorMappings,
@Nonnull final ValuedEnumParser enumParser);
/**
* Sets The base url for every request.
* @param baseUrl The base url for every request.
*/
void setBaseUrl(@Nonnull final String baseUrl);
/**
* Gets The base url for every request.
* @return The base url for every request.
*/
@Nonnull String getBaseUrl();
/**
* Converts the given RequestInformation into a native HTTP request.
* @param the type of the native HTTP request.
* @param requestInfo the request info to convert.
* @return the native HTTP request.
*/
@Nonnull T convertToNativeRequest(@Nonnull final RequestInformation requestInfo);
}