Table of Contents

Interface IOpenBiApiClient

Namespace
BiExcellence.OpenBi.Api
Assembly
BiExcellence.OpenBi.Api.Client.dll

Low-level HTTP transport shared by every OpenBI REST API domain's extension methods (see the BiExcellence.OpenBi.Api.* namespaces). Obtain an instance from OpenBiApiClient and authenticate it using the extension methods in BiExcellence.OpenBi.Api.Auth before calling any other domain operation.

public interface IOpenBiApiClient
Extension Methods

Properties

AccessToken

The bearer access token currently attached to outgoing requests, or null if none has been set.

string? AccessToken { get; }

Property Value

string

BaseAddress

The REST API's base address, e.g. https://myserver/openbi/api/.

Uri BaseAddress { get; }

Property Value

Uri

Methods

DeleteAsync(string, CancellationToken)

Sends a DELETE request.

Task DeleteAsync(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string
cancellationToken CancellationToken

Returns

Task

GetAsync<TResponse>(string, CancellationToken)

Sends a GET request and deserializes the JSON response body.

Task<TResponse?> GetAsync<TResponse>(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string
cancellationToken CancellationToken

Returns

Task<TResponse>

Type Parameters

TResponse

GetFileAsync(string, CancellationToken)

Sends a GET request and returns the response body as a file: the stream plus the media type and file name the server stated. Use this where the response is a document rather than JSON.

Task<OpenBiApiFile> GetFileAsync(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative request URI.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<OpenBiApiFile>

The file. Disposing it disposes the underlying response.

GetListAsync<TItem>(string, CancellationToken)

Sends a GET request against a list endpoint and returns its items together with the X-Total-Count response header, when present.

Task<OpenBiListResult<TItem>> GetListAsync<TItem>(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string
cancellationToken CancellationToken

Returns

Task<OpenBiListResult<TItem>>

Type Parameters

TItem

GetStreamAsync(string, CancellationToken)

Sends a GET request and returns the raw response stream (e.g. for file downloads). The caller owns and must dispose the returned stream.

Task<Stream> GetStreamAsync(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string
cancellationToken CancellationToken

Returns

Task<Stream>

PostAsync(string, CancellationToken)

Sends a POST request with no body.

Task PostAsync(string requestUri, CancellationToken cancellationToken = default)

Parameters

requestUri string
cancellationToken CancellationToken

Returns

Task

PostAsync<TRequest>(string, TRequest?, CancellationToken)

Sends a POST request with a JSON body and no response body.

Task PostAsync<TRequest>(string requestUri, TRequest? body, CancellationToken cancellationToken = default)

Parameters

requestUri string
body TRequest
cancellationToken CancellationToken

Returns

Task

Type Parameters

TRequest

PostAsync<TRequest, TResponse>(string, TRequest?, CancellationToken)

Sends a POST request with a JSON body and deserializes the JSON response body.

Task<TResponse?> PostAsync<TRequest, TResponse>(string requestUri, TRequest? body, CancellationToken cancellationToken = default)

Parameters

requestUri string
body TRequest
cancellationToken CancellationToken

Returns

Task<TResponse>

Type Parameters

TRequest
TResponse

PostFileAsync<TResponse>(string, Stream, string, IEnumerable<KeyValuePair<string, string>>?, CancellationToken)

Sends a multipart/form-data POST carrying one file plus optional text fields, and deserializes the JSON response body. The file is streamed rather than buffered.

Task<TResponse?> PostFileAsync<TResponse>(string requestUri, Stream stream, string fileName, IEnumerable<KeyValuePair<string, string>>? fields = null, CancellationToken cancellationToken = default)

Parameters

requestUri string
stream Stream
fileName string
fields IEnumerable<KeyValuePair<string, string>>
cancellationToken CancellationToken

Returns

Task<TResponse>

Type Parameters

TResponse

PostFormAsync(string, IEnumerable<KeyValuePair<string, string>>, CancellationToken)

Sends a POST request with an application/x-www-form-urlencoded body and no response body (used by /oauth/revoke).

Task PostFormAsync(string requestUri, IEnumerable<KeyValuePair<string, string>> form, CancellationToken cancellationToken = default)

Parameters

requestUri string
form IEnumerable<KeyValuePair<string, string>>
cancellationToken CancellationToken

Returns

Task

PostFormAsync<TResponse>(string, IEnumerable<KeyValuePair<string, string>>, CancellationToken)

Sends a POST request with an application/x-www-form-urlencoded body (used by the /oauth/token and /oauth/revoke endpoints) and deserializes the JSON response body.

Task<TResponse?> PostFormAsync<TResponse>(string requestUri, IEnumerable<KeyValuePair<string, string>> form, CancellationToken cancellationToken = default)

Parameters

requestUri string
form IEnumerable<KeyValuePair<string, string>>
cancellationToken CancellationToken

Returns

Task<TResponse>

Type Parameters

TResponse

PostServerSentEventsAsync<TRequest, TItem>(string, TRequest?, CancellationToken)

Sends a POST request with a JSON body, asking the server for a server-sent event stream, and yields each event's deserialized payload as it arrives. The stream stays open until the server closes it, so enumeration lasts as long as the operation being reported on.

IAsyncEnumerable<TItem> PostServerSentEventsAsync<TRequest, TItem>(string requestUri, TRequest? body, CancellationToken cancellationToken = default)

Parameters

requestUri string
body TRequest
cancellationToken CancellationToken

Returns

IAsyncEnumerable<TItem>

Type Parameters

TRequest
TItem

QueryListAsync<TRequest, TItem>(string, TRequest?, CancellationToken)

Sends a QUERY request with a JSON body and reads the response as a list. The QUERY-method form of a list route takes the same options as the query string does, for filters that do not fit in a URL.

Task<OpenBiListResult<TItem>> QueryListAsync<TRequest, TItem>(string requestUri, TRequest? body, CancellationToken cancellationToken = default)

Parameters

requestUri string

The relative request URI.

body TRequest

The query options.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<OpenBiListResult<TItem>>

Type Parameters

TRequest

The request body type.

TItem

The item type to deserialize each entry into.

SetAccessToken(string?)

Attaches (or clears, when accessToken is null) the bearer access token used to authorize subsequent requests.

void SetAccessToken(string? accessToken)

Parameters

accessToken string