Class OpenBiApiClientApiKeyExtensions
Extension methods for the /apikeys REST API. Callers see and manage their own keys; holders of
openbi.user.write see and manage everyone's. A key is used with
CreateAccessTokenAsync(IOpenBiApiClient, string, string, string?, CancellationToken).
public static class OpenBiApiClientApiKeyExtensions
- Inheritance
-
objectOpenBiApiClientApiKeyExtensions
Methods
CreateApiKeyAsync(IOpenBiApiClient, ApiKey, CancellationToken)
Creates a new API key and returns it with its id - generated where it is left unset - and its secret, always
generated, which is not returned again. The key belongs to - and acts as - the calling user;
only a caller holding openbi.user.write may create one for someone else with
UserId.
public static Task<ApiKey?> CreateApiKeyAsync(this IOpenBiApiClient client, ApiKey apiKey, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientapiKeyApiKeycancellationTokenCancellationToken
Returns
- Task<ApiKey>
CreateApiKeySecretAsync(IOpenBiApiClient, string, CancellationToken)
Replaces the secret of an API key and returns the key with the new one (POST apikeys/{id}/secret), the
only time it can be read. The old secret stops working at once. A caller without openbi.user.write can
only do this for its own keys; anyone else's throws OpenBiApiException (404).
public static Task<ApiKey?> CreateApiKeySecretAsync(this IOpenBiApiClient client, string id, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientidstringcancellationTokenCancellationToken
Returns
- Task<ApiKey>
DeleteApiKeyAsync(IOpenBiApiClient, string, CancellationToken)
Deletes an API key, and with it the access tokens issued for it. A caller without
openbi.user.write can only delete its own keys; deleting a key that is not there is not an error.
public static Task DeleteApiKeyAsync(this IOpenBiApiClient client, string id, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientidstringcancellationTokenCancellationToken
Returns
- Task
GetApiKeyAsync(IOpenBiApiClient, string, CancellationToken)
Reads one API key by id. Secret is always null.
Throws OpenBiApiException (404) when there is no such key - or, for a caller without
openbi.user.write, when the key belongs to someone else.
public static Task<ApiKey> GetApiKeyAsync(this IOpenBiApiClient client, string id, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientidstringcancellationTokenCancellationToken
Returns
- Task<ApiKey>
GetApiKeysAsync(IOpenBiApiClient, OpenBiListRequest?, CancellationToken)
Lists API keys (GET apikeys), with the shared list options of request: the caller's
own, or every key when the caller holds openbi.user.write. Secret is always
null.
public static Task<OpenBiListResult<ApiKey>> GetApiKeysAsync(this IOpenBiApiClient client, OpenBiListRequest? request = null, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientrequestOpenBiListRequestcancellationTokenCancellationToken
Returns
- Task<OpenBiListResult<ApiKey>>
UpdateApiKeyAsync(IOpenBiApiClient, string, ApiKey, CancellationToken)
Updates an API key. Unlike the other Update*Async methods this does not create a missing key: an
unknown id - or, for a caller without openbi.user.write, someone else's key - throws
OpenBiApiException (404). An unset UserId keeps the key's owner,
and only a caller holding openbi.user.write can change it.
public static Task<ApiKey?> UpdateApiKeyAsync(this IOpenBiApiClient client, string id, ApiKey apiKey, CancellationToken cancellationToken = default)
Parameters
clientIOpenBiApiClientidstringapiKeyApiKeycancellationTokenCancellationToken
Returns
- Task<ApiKey>