Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions arangodb-net-standard/AdminApi/AdminApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public virtual async Task<GetLogsResponse> GetLogsAsync(GetLogsQuery query = nul
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetLogsResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetLogsResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -96,7 +96,7 @@ public virtual async Task<bool> PostReloadRoutingInfoAsync(CancellationToken tok
{
return true;
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -119,9 +119,9 @@ public virtual async Task<GetServerIdResponse> GetServerIdAsync(CancellationToke
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetServerIdResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetServerIdResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -143,9 +143,9 @@ public virtual async Task<GetServerRoleResponse> GetServerRoleAsync(Cancellation
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetServerRoleResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetServerRoleResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -167,9 +167,9 @@ public virtual async Task<GetServerEngineTypeResponse> GetServerEngineTypeAsync(
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetServerEngineTypeResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetServerEngineTypeResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -196,9 +196,9 @@ public virtual async Task<GetServerVersionResponse> GetServerVersionAsync(GetSer
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetServerVersionResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetServerVersionResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -220,9 +220,9 @@ public virtual async Task<GetLicenseResponse> GetLicenseAsync(CancellationToken
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetLicenseResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetLicenseResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -245,15 +245,15 @@ public virtual async Task<PutLicenseResponse> PutLicenseAsync(string licenseKey,
{
uri += '?' + query.ToQueryString();
}
var content = GetContent(licenseKey, new ApiClientSerializationOptions(true, true));
var content = await GetContentAsync(licenseKey, new ApiClientSerializationOptions(true, true));
using (var response = await _client.PutAsync(uri, content, token: token).ConfigureAwait(false))
{
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<PutLicenseResponse>(stream);
return await DeserializeJsonFromStreamAsync<PutLicenseResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public virtual async Task<GetAllAnalyzersResponse> GetAllAnalyzersAsync(Cancella
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetAllAnalyzersResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetAllAnalyzersResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -82,15 +82,15 @@ public virtual async Task<Analyzer> PostAnalyzerAsync(Analyzer body, Cancellatio
throw new ArgumentException("body is required", nameof(body));
}
var uri = _analyzerApiPath;
var content = GetContent(body, new ApiClientSerializationOptions(true, true));
var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false);
using (var response = await _client.PostAsync(uri, content, null, token).ConfigureAwait(false))
{
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<Analyzer>(stream);
return await DeserializeJsonFromStreamAsync<Analyzer>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -113,9 +113,9 @@ public virtual async Task<GetAnalyzerResponse> GetAnalyzerAsync(string analyzerN
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<GetAnalyzerResponse>(stream);
return await DeserializeJsonFromStreamAsync<GetAnalyzerResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}

Expand All @@ -138,9 +138,9 @@ public virtual async Task<DeleteAnalyzerResponse> DeleteAnalyzerAsync(string ana
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
return DeserializeJsonFromStream<DeleteAnalyzerResponse>(stream);
return await DeserializeJsonFromStreamAsync<DeleteAnalyzerResponse>(stream).ConfigureAwait(false);
}
throw await GetApiErrorException(response).ConfigureAwait(false);
throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions arangodb-net-standard/ApiClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public ApiClientBase(IApiClientSerialization serialization)
/// </summary>
/// <param name="response">The error response from ArangoDB.</param>
/// <returns></returns>
protected async Task<ApiErrorException> GetApiErrorException(IApiClientResponse response)
protected async Task<ApiErrorException> GetApiErrorExceptionAsync(IApiClientResponse response)
{
var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
try
{
var error = _serialization.DeserializeFromStream<ApiErrorResponse>(stream);
var error = await _serialization.DeserializeFromStreamAsync<ApiErrorResponse>(stream).ConfigureAwait(false);
return new ApiErrorException(error);
}
catch (Exception e)
Expand All @@ -54,35 +54,35 @@ protected void ValidateDocumentId(string documentId)
}
}

protected T DeserializeJsonFromStream<T>(Stream stream)
protected async Task<T> DeserializeJsonFromStreamAsync<T>(Stream stream)
{
try
{
return _serialization.DeserializeFromStream<T>(stream);
return await _serialization.DeserializeFromStreamAsync<T>(stream).ConfigureAwait(false);
}
catch (Exception e)
{
throw new SerializationException($"An error occured while Deserializing the data response from Arango. See InnerException for more details.", e);
}
}

protected byte[] GetContent<T>(T item, ApiClientSerializationOptions serializationOptions)
protected async Task<byte[]> GetContentAsync<T>(T item, ApiClientSerializationOptions serializationOptions)
{
try
{
return _serialization.Serialize(item, serializationOptions);
return await _serialization.SerializeAsync(item, serializationOptions).ConfigureAwait(false);
}
catch (Exception e)
{
throw new SerializationException($"A serialization error occured while preparing a request for Arango. See InnerException for more details.", e);
}
}

protected string GetContentString<T>(T item, ApiClientSerializationOptions serializationOptions)
protected async Task<string> GetContentStringAsync<T>(T item, ApiClientSerializationOptions serializationOptions)
{
try
{
return _serialization.SerializeToString(item, serializationOptions);
return await _serialization.SerializeToStringAsync(item, serializationOptions).ConfigureAwait(false);
}
catch (Exception e)
{
Expand Down
Loading