diff --git a/arangodb-net-standard/AdminApi/AdminApiClient.cs b/arangodb-net-standard/AdminApi/AdminApiClient.cs index 5e710714..02e2e895 100644 --- a/arangodb-net-standard/AdminApi/AdminApiClient.cs +++ b/arangodb-net-standard/AdminApi/AdminApiClient.cs @@ -70,9 +70,9 @@ public virtual async Task GetLogsAsync(GetLogsQuery query = nul if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -96,7 +96,7 @@ public virtual async Task PostReloadRoutingInfoAsync(CancellationToken tok { return true; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -119,9 +119,9 @@ public virtual async Task GetServerIdAsync(CancellationToke if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -143,9 +143,9 @@ public virtual async Task GetServerRoleAsync(Cancellation if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -167,9 +167,9 @@ public virtual async Task GetServerEngineTypeAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -196,9 +196,9 @@ public virtual async Task GetServerVersionAsync(GetSer if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -220,9 +220,9 @@ public virtual async Task GetLicenseAsync(CancellationToken if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -245,15 +245,15 @@ public virtual async Task 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(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs b/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs index 5ea10d02..ecb2558a 100644 --- a/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs +++ b/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs @@ -62,9 +62,9 @@ public virtual async Task GetAllAnalyzersAsync(Cancella if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -82,15 +82,15 @@ public virtual async Task 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(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -113,9 +113,9 @@ public virtual async Task GetAnalyzerAsync(string analyzerN if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -138,9 +138,9 @@ public virtual async Task DeleteAnalyzerAsync(string ana if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/ApiClientBase.cs b/arangodb-net-standard/ApiClientBase.cs index 7e912379..dba79340 100644 --- a/arangodb-net-standard/ApiClientBase.cs +++ b/arangodb-net-standard/ApiClientBase.cs @@ -25,12 +25,12 @@ public ApiClientBase(IApiClientSerialization serialization) /// /// The error response from ArangoDB. /// - protected async Task GetApiErrorException(IApiClientResponse response) + protected async Task GetApiErrorExceptionAsync(IApiClientResponse response) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); try { - var error = _serialization.DeserializeFromStream(stream); + var error = await _serialization.DeserializeFromStreamAsync(stream).ConfigureAwait(false); return new ApiErrorException(error); } catch (Exception e) @@ -54,11 +54,11 @@ protected void ValidateDocumentId(string documentId) } } - protected T DeserializeJsonFromStream(Stream stream) + protected async Task DeserializeJsonFromStreamAsync(Stream stream) { try { - return _serialization.DeserializeFromStream(stream); + return await _serialization.DeserializeFromStreamAsync(stream).ConfigureAwait(false); } catch (Exception e) { @@ -66,11 +66,11 @@ protected T DeserializeJsonFromStream(Stream stream) } } - protected byte[] GetContent(T item, ApiClientSerializationOptions serializationOptions) + protected async Task GetContentAsync(T item, ApiClientSerializationOptions serializationOptions) { try { - return _serialization.Serialize(item, serializationOptions); + return await _serialization.SerializeAsync(item, serializationOptions).ConfigureAwait(false); } catch (Exception e) { @@ -78,11 +78,11 @@ protected byte[] GetContent(T item, ApiClientSerializationOptions serializati } } - protected string GetContentString(T item, ApiClientSerializationOptions serializationOptions) + protected async Task GetContentStringAsync(T item, ApiClientSerializationOptions serializationOptions) { try { - return _serialization.SerializeToString(item, serializationOptions); + return await _serialization.SerializeToStringAsync(item, serializationOptions).ConfigureAwait(false); } catch (Exception e) { diff --git a/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs b/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs index 0ec57180..66d8626e 100644 --- a/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs +++ b/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs @@ -59,16 +59,16 @@ public virtual async Task PostAqlFunctionAsync( PostAqlFunctionBody body, CancellationToken token = default) { - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PostAsync(_apiPath, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -97,9 +97,9 @@ public virtual async Task DeleteAqlFunctionAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -125,9 +125,9 @@ public virtual async Task GetAqlFunctionsAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -149,15 +149,15 @@ public virtual async Task PostExplainAqlQueryAsync( string uri = "_api/explain"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -179,15 +179,15 @@ public virtual async Task PostParseAqlQueryAsync( string uri = "_api/query"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -232,9 +232,9 @@ public virtual async Task DeleteKillRunningAqlQueryAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -267,9 +267,9 @@ public virtual async Task DeleteClearSlowAqlQueriesAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -310,9 +310,9 @@ public virtual async Task> GetSlowAqlQueriesAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -334,9 +334,9 @@ public virtual async Task DeleteClearAqlQueryCacheAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -359,9 +359,9 @@ public virtual async Task> GetCachedAqlQueryResultsAs if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -382,9 +382,9 @@ public virtual async Task GetQueryCacheGlobalPropert if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -411,15 +411,15 @@ public virtual async Task PutAdjustQueryCacheGlobalP string uri = "_api/query-cache/properties"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -438,9 +438,9 @@ public virtual async Task GetQueryTrackingConfigurat if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -466,15 +466,15 @@ public virtual async Task PutChangeQueryTrackingConf string uri = "_api/query/properties"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -503,9 +503,9 @@ public virtual async Task> GetCurrentlyRunningAqlQueriesAs if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -528,9 +528,9 @@ public virtual async Task> GetQueryRulesAsync(CancellationTok if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/AuthApi/AuthApiClient.cs b/arangodb-net-standard/AuthApi/AuthApiClient.cs index 7c0678f4..c263c32b 100644 --- a/arangodb-net-standard/AuthApi/AuthApiClient.cs +++ b/arangodb-net-standard/AuthApi/AuthApiClient.cs @@ -69,15 +69,15 @@ public virtual async Task GetJwtTokenAsync( JwtTokenRequestBody body, CancellationToken token = default) { - byte[] content = GetContent(body, new ApiClientSerializationOptions(true, false)); + byte[] content = await GetContentAsync(body, new ApiClientSerializationOptions(true, false)).ConfigureAwait(false); using (var response = await _client.PostAsync("/_open/auth", content,null,token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs b/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs index 16053271..b4d9223a 100644 --- a/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs +++ b/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs @@ -88,7 +88,7 @@ public virtual async Task PostImportDocumentArraysAsync var options = new ApiClientSerializationOptions(true, true); foreach (var valueArr in body.ValueArrays) { - sb.AppendLine(GetContentString(valueArr, options)); + sb.AppendLine(await GetContentStringAsync(valueArr, options).ConfigureAwait(false)); } return await PostImportDocumentArraysAsync(query, sb.ToString(),token) .ConfigureAwait(false); @@ -130,9 +130,9 @@ public virtual async Task PostImportDocumentArraysAsync var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -177,13 +177,13 @@ public virtual async Task PostImportDocumentObjectsAsyn //body should be a list of documents seperated by newline char foreach (var doc in body.Documents) { - sb.AppendLine(GetContentString(doc, options)); + sb.AppendLine(await GetContentStringAsync(doc, options).ConfigureAwait(false)); } } else { //body should be one array of JSON objects - sb.Append(GetContentString(body.Documents, options)); + sb.Append(await GetContentStringAsync(body.Documents, options).ConfigureAwait(false)); } return await PostImportDocumentObjectsAsync(query, sb.ToString(),token) .ConfigureAwait(false); @@ -232,9 +232,9 @@ public virtual async Task PostImportDocumentObjectsAsyn var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/CollectionApi/CollectionApiClient.cs b/arangodb-net-standard/CollectionApi/CollectionApiClient.cs index 08c7d062..e4b4a6cf 100644 --- a/arangodb-net-standard/CollectionApi/CollectionApiClient.cs +++ b/arangodb-net-standard/CollectionApi/CollectionApiClient.cs @@ -65,15 +65,15 @@ public virtual async Task PostCollectionAsync( { uriString += "?" + options.ToQueryString(); } - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PostAsync(uriString, content, null, token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -94,9 +94,9 @@ public virtual async Task DeleteCollectionAsync(string if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -121,9 +121,9 @@ public virtual async Task TruncateCollectionAsync(st if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -147,9 +147,9 @@ public virtual async Task GetCollectionCountAsync(st if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); }; } @@ -173,9 +173,9 @@ public virtual async Task GetCollectionsAsync(GetCollect if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -197,10 +197,10 @@ public async Task GetCollectionAsync(string collectionNam if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - var collection = DeserializeJsonFromStream(stream); + var collection = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); return collection; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -222,9 +222,9 @@ public virtual async Task GetCollectionProperti if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -239,20 +239,20 @@ public virtual async Task GetCollectionProperti public virtual async Task RenameCollectionAsync(string collectionName, RenameCollectionBody body, CancellationToken token = default) { - var content = GetContent(body, new ApiClientSerializationOptions(true, false)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, false)).ConfigureAwait(false); using (var response = await _transport.PutAsync( _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/rename", content, null, token).ConfigureAwait(false)) - { + { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - var collection = DeserializeJsonFromStream(stream); + var collection =await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); return collection; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -274,9 +274,9 @@ public virtual async Task GetCollectionRevisionAs if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -293,7 +293,7 @@ public virtual async Task PutCollectionPropertyAs PutCollectionPropertyBody body, CancellationToken token = default) { - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync( _collectionApiPath + "/" + collectionName + "/properties", content, @@ -303,9 +303,9 @@ public virtual async Task PutCollectionPropertyAs if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -327,10 +327,10 @@ public virtual async Task GetCollectionFiguresAsyn if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); }; } @@ -361,9 +361,9 @@ public virtual async Task GetChecksumAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -391,9 +391,9 @@ public virtual async Task PutLoadIndexesIntoMe if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -417,9 +417,9 @@ public virtual async Task PutRecalculateCountAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -449,15 +449,15 @@ public virtual async Task PutDocumentShardAsync( throw new ArgumentException($"{nameof(body)} is required", nameof(body)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/responsibleShard"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uriString, content, null, token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -482,9 +482,9 @@ public virtual async Task GetCollectionShardsAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -512,9 +512,9 @@ public virtual async Task GetCollectionShar if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -540,9 +540,9 @@ public virtual async Task PutCompactCollection if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/CursorApi/CursorApiClient.cs b/arangodb-net-standard/CursorApi/CursorApiClient.cs index 16176f6a..60191545 100644 --- a/arangodb-net-standard/CursorApi/CursorApiClient.cs +++ b/arangodb-net-standard/CursorApi/CursorApiClient.cs @@ -122,7 +122,7 @@ public virtual async Task> PostCursorAsync( CursorHeaderProperties headerProperties = null, CancellationToken token = default) { - var content = GetContent(postCursorBody, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(postCursorBody, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headerProperties); using (var response = await _client.PostAsync(_cursorApiPath, content, @@ -132,10 +132,9 @@ public virtual async Task> PostCursorAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -157,10 +156,10 @@ public virtual async Task DeleteCursorAsync(string cursorI if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -181,10 +180,10 @@ public virtual async Task> PutCursorAsync(string cursorI if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -205,9 +204,9 @@ public virtual async Task> PostAdvanceCursorAsync(string cu if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs b/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs index 776238e4..c749c665 100644 --- a/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs +++ b/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs @@ -55,15 +55,15 @@ public DatabaseApiClient(IApiClientTransport client, IApiClientSerialization ser /// public virtual async Task PostDatabaseAsync(PostDatabaseBody request, CancellationToken token = default) { - var content = GetContent(request, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(request, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _client.PostAsync(_databaseApiPath, content, null, token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -82,9 +82,9 @@ public virtual async Task DeleteDatabaseAsync(string dat if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -105,9 +105,9 @@ public virtual async Task GetDatabasesAsync(CancellationTo if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -123,9 +123,9 @@ public virtual async Task GetUserDatabasesAsync(Cancellati if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -141,9 +141,9 @@ public virtual async Task GetCurrentDatabaseInfo if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/DocumentApi/DocumentApiClient.cs b/arangodb-net-standard/DocumentApi/DocumentApiClient.cs index f5953c5e..54b4de9f 100644 --- a/arangodb-net-standard/DocumentApi/DocumentApiClient.cs +++ b/arangodb-net-standard/DocumentApi/DocumentApiClient.cs @@ -118,17 +118,17 @@ public virtual async Task> PostDocumentAsync( uriString += "?" + query.ToQueryString(); } - var content = GetContent(document, serializationOptions); + var content = await GetContentAsync(document, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PostAsync(uriString, content, headerCollection, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -158,7 +158,7 @@ public virtual async Task> PostDocumentsAsync( uriString += "?" + query.ToQueryString(); } - var content = GetContent(documents, serializationOptions); + var content = await GetContentAsync(documents, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PostAsync(uriString, content, headerCollection, token: token).ConfigureAwait(false)) { @@ -171,11 +171,11 @@ public virtual async Task> PostDocumentsAsync( else { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -205,7 +205,7 @@ public virtual async Task> PutDocumentsAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(documents, serializationOptions); + var content = await GetContentAsync(documents, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PutAsync(uri, content, headerCollection, token: token).ConfigureAwait(false)) { @@ -218,11 +218,11 @@ public virtual async Task> PutDocumentsAsync( else { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -255,17 +255,17 @@ public virtual async Task> PutDocumentAsync( uri += "?" + opts.ToQueryString(); } - var content = GetContent(doc, serializationOptions); + var content = await GetContentAsync(doc, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PutAsync(uri, content, headerCollection, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -344,11 +344,11 @@ public virtual async Task GetDocumentAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - var document = DeserializeJsonFromStream(stream); + var document = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); return document; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } /// @@ -372,18 +372,18 @@ public virtual async Task> GetDocumentsAsync( CancellationToken token = default) { string uri = $"{_docApiPath}/{WebUtility.UrlEncode(collectionName)}?onlyget=true"; - var content = GetContent(selectors, new ApiClientSerializationOptions(false, true)); + var content = await GetContentAsync(selectors, new ApiClientSerializationOptions(false, true)).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PutAsync(uri, content, headerCollection, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - var documents = DeserializeJsonFromStream>(stream); + var documents = await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); return documents; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -486,11 +486,11 @@ public virtual async Task> DeleteDocumentAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - var responseModel = DeserializeJsonFromStream>(stream); + var responseModel = await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); return responseModel; } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -544,7 +544,7 @@ public virtual async Task> DeleteDocumentsAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(selectors, new ApiClientSerializationOptions(false, false)); + var content = await GetContentAsync(selectors, new ApiClientSerializationOptions(false, false)).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.DeleteAsync(uri, content, headerCollection, token: token).ConfigureAwait(false)) { @@ -557,11 +557,11 @@ public virtual async Task> DeleteDocumentsAsync( else { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -605,7 +605,7 @@ public virtual async Task> PatchDocumentsAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(patches, serializationOptions); + var content = await GetContentAsync(patches, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PatchAsync(uri, content, headerCollection, token: token).ConfigureAwait(false)) { @@ -618,11 +618,11 @@ public virtual async Task> PatchDocumentsAsync( else { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -735,17 +735,17 @@ public virtual async Task> PatchDocumentAsync( uriString += "?" + query.ToQueryString(); } - var content = GetContent(body, serializationOptions); + var content = await GetContentAsync(body, serializationOptions).ConfigureAwait(false); var headerCollection = GetHeaderCollection(headers); using (var response = await _client.PatchAsync(uriString, content, headerCollection, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } diff --git a/arangodb-net-standard/GraphApi/GraphApiClient.cs b/arangodb-net-standard/GraphApi/GraphApiClient.cs index 3b6b81c3..cc5d9e96 100644 --- a/arangodb-net-standard/GraphApi/GraphApiClient.cs +++ b/arangodb-net-standard/GraphApi/GraphApiClient.cs @@ -70,16 +70,16 @@ public virtual async Task PostGraphAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(postGraphBody, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(postGraphBody, new ApiClientSerializationOptions(true, true)); using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -100,9 +100,9 @@ public virtual async Task GetGraphsAsync( CancellationToken t if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -130,9 +130,9 @@ public virtual async Task DeleteGraphAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -151,9 +151,9 @@ public virtual async Task GetGraphAsync(string graphName, Canc if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -171,9 +171,9 @@ public virtual async Task GetVertexCollectionsAsyn if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -191,9 +191,9 @@ public virtual async Task GetEdgeCollectionsAsync(st if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -215,7 +215,7 @@ public virtual async Task PostEdgeDefinitionAsync( string graphName, PostEdgeDefinitionBody body, CancellationToken token = default) { - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge"; @@ -224,9 +224,9 @@ public virtual async Task PostEdgeDefinitionAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -245,16 +245,16 @@ public virtual async Task PostVertexCollectionAsyn { string uri = _graphApiPath + '/' + WebUtility.UrlEncode(graphName) + "/vertex"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -287,15 +287,15 @@ public virtual async Task> PostVertexAsync( { uri += "?" + query.ToQueryString(); } - var content = GetContent(vertex, serializationOptions); + var content = await GetContentAsync(vertex, serializationOptions).ConfigureAwait(false); using (var response = await _transport.PostAsync(uri, content,headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -326,9 +326,9 @@ public virtual async Task DeleteEdgeDefinitionAsyn if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -360,9 +360,9 @@ public virtual async Task DeleteVertexCollection if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -394,7 +394,7 @@ public virtual async Task> PostEdgeAsync( GraphHeaderProperties headers = null, CancellationToken token = default) { - var content = GetContent(edge, serializationOptions); + var content = await GetContentAsync(edge, serializationOptions); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge/" + WebUtility.UrlEncode(collectionName); @@ -409,9 +409,9 @@ public virtual async Task> PostEdgeAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -472,9 +472,9 @@ public virtual async Task> GetEdgeAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -540,9 +540,9 @@ public virtual async Task> DeleteEdgeAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -603,9 +603,9 @@ public virtual async Task> GetVertexAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -668,9 +668,9 @@ public virtual async Task> DeleteVertexAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -748,15 +748,15 @@ public virtual async Task> PatchVertexAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(body, serializationOptions); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(false, false)).ConfigureAwait(false); using (var response = await _transport.PatchAsync(uri, content,headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -828,16 +828,15 @@ public virtual async Task> PutEdgeAsync( uri += "?" + query.ToQueryString(); } - var content = GetContent(edge, serializationOptions); - + var content = await GetContentAsync(edge, new ApiClientSerializationOptions(false, false)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -866,15 +865,15 @@ public virtual async Task PutEdgeDefinitionAsync( { uriString += "?" + query.ToQueryString(); } - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uriString, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -948,16 +947,15 @@ public virtual async Task> PatchEdgeAsync( { uri += "?" + query.ToQueryString(); } - - var content = GetContent(edge, serializationOptions); + var content = await GetContentAsync(edge, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PatchAsync(uri, content, headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -1027,16 +1025,15 @@ public virtual async Task> PutVertexAsync( { uri += "?" + query.ToQueryString(); } - var content = GetContent(vertex, serializationOptions); + var content = await GetContentAsync(vertex, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, headers?.ToWebHeaderCollection(),token:token).ConfigureAwait(false)) - { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } diff --git a/arangodb-net-standard/IndexApi/IndexApiClient.cs b/arangodb-net-standard/IndexApi/IndexApiClient.cs index 884ff953..32ce5a54 100644 --- a/arangodb-net-standard/IndexApi/IndexApiClient.cs +++ b/arangodb-net-standard/IndexApi/IndexApiClient.cs @@ -63,9 +63,9 @@ public virtual async Task GetIndexAsync(string indexId, if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -84,9 +84,9 @@ public virtual async Task DeleteIndexAsync(string indexId, if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -119,9 +119,9 @@ public virtual async Task GetAllCollectionIndex if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -158,15 +158,15 @@ public virtual async Task PostIndexAsync(PostIndexQuery query } uri += '?' + query.ToQueryString(); - 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,token:token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } diff --git a/arangodb-net-standard/PregelApi/PregelApiClient.cs b/arangodb-net-standard/PregelApi/PregelApiClient.cs index 565dd92b..b049f539 100644 --- a/arangodb-net-standard/PregelApi/PregelApiClient.cs +++ b/arangodb-net-standard/PregelApi/PregelApiClient.cs @@ -68,15 +68,15 @@ public PregelApiClient(IApiClientTransport transport, IApiClientSerialization se public virtual async Task PostStartJobAsync(PostStartJobBody body, CancellationToken token = default) { string uri = _apiPath; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -99,9 +99,9 @@ public virtual async Task GetJobStatusAsync(string jobId, Cance if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -122,9 +122,9 @@ public virtual async Task> GetAllRunningJobsAsync(Cancella if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -150,9 +150,9 @@ public virtual async Task DeleteJobAsync(string jobId, CancellationToken if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/Serialization/ApiClientSerialization.cs b/arangodb-net-standard/Serialization/ApiClientSerialization.cs index a8245d16..3964f469 100644 --- a/arangodb-net-standard/Serialization/ApiClientSerialization.cs +++ b/arangodb-net-standard/Serialization/ApiClientSerialization.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Threading.Tasks; namespace ArangoDBNetStandard.Serialization { @@ -28,6 +29,15 @@ public abstract class ApiClientSerialization : IApiClientSerialization /// public abstract T DeserializeFromStream(Stream stream); + /// + /// Asynchronously deserializes the data structure contained by the specified stream + /// into an instance of the specified type. + /// + /// The type of the object to deserialize to. + /// The stream containing the JSON structure to deserialize. + /// + public abstract Task DeserializeFromStreamAsync(Stream stream); + /// /// Serializes the specified object to a sequence of bytes, /// following the provided rules for camel case property name and null value handling. @@ -39,6 +49,17 @@ public abstract class ApiClientSerialization : IApiClientSerialization /// public abstract byte[] Serialize(T item, ApiClientSerializationOptions serializationOptions); + /// + /// Asynchronously serializes the specified object to a sequence of bytes, + /// following the provided rules for camel case property name and null value handling. + /// + /// The type of the object to serialize. + /// The object to serialize. + /// The serialization options. When the value is null the + /// the serialization options should be provided by the serializer, otherwise the given options should be used. + /// + public abstract Task SerializeAsync(T item, ApiClientSerializationOptions serializationOptions); + /// /// Serializes the specified object to a JSON string, /// following the provided rules for camel case property name and null value handling. @@ -49,5 +70,16 @@ public abstract class ApiClientSerialization : IApiClientSerialization /// the serialization options should be provided by the serializer, otherwise the given options should be used. /// public abstract string SerializeToString(T item, ApiClientSerializationOptions serializationOptions); + + /// + /// Asynchronously serializes the specified object to a JSON string, + /// following the provided rules for camel case property name and null value handling. + /// + /// The type of the object to serialize. + /// The object to serialize. + /// The serialization options. When the value is null the + /// the serialization options should be provided by the serializer, otherwise the given options should be used. + /// + public abstract Task SerializeToStringAsync(T item, ApiClientSerializationOptions serializationOptions); } } diff --git a/arangodb-net-standard/Serialization/IApiClientSerialization.cs b/arangodb-net-standard/Serialization/IApiClientSerialization.cs index f2731190..1c0bfe14 100644 --- a/arangodb-net-standard/Serialization/IApiClientSerialization.cs +++ b/arangodb-net-standard/Serialization/IApiClientSerialization.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Threading.Tasks; namespace ArangoDBNetStandard.Serialization { @@ -8,16 +9,16 @@ namespace ArangoDBNetStandard.Serialization public interface IApiClientSerialization { /// - /// Deserializes the data structure contained by the specified stream + /// Asynchronously deserializes the data structure contained by the specified stream /// into an instance of the specified type. /// /// The type of the object to deserialize to. /// The stream containing the JSON structure to deserialize. /// - T DeserializeFromStream(Stream stream); + Task DeserializeFromStreamAsync(Stream stream); /// - /// Serializes the specified object to a sequence of bytes, + /// Asynchronously serializes the specified object to a sequence of bytes, /// following the provided rules for camel case property name and null value handling. /// /// The type of the object to serialize. @@ -25,10 +26,10 @@ public interface IApiClientSerialization /// The serialization options. When the value is null the /// the serialization options should be provided by the serializer, otherwise the given options should be used. /// - byte[] Serialize(T item, ApiClientSerializationOptions serializationOptions); + Task SerializeAsync(T item, ApiClientSerializationOptions serializationOptions); /// - /// Serializes the specified object to a JSON string, + /// Asynchronously serializes the specified object to a JSON string, /// following the provided rules for camel case property name and null value handling. /// /// The type of the object to serialize. @@ -36,6 +37,6 @@ public interface IApiClientSerialization /// The serialization options. When the value is null the /// the serialization options should be provided by the serializer, otherwise the given options should be used. /// - string SerializeToString(T item, ApiClientSerializationOptions serializationOptions); + Task SerializeToStringAsync(T item, ApiClientSerializationOptions serializationOptions); } -} +} \ No newline at end of file diff --git a/arangodb-net-standard/Serialization/JsonNetApiClientSerialization.cs b/arangodb-net-standard/Serialization/JsonNetApiClientSerialization.cs index 89635b59..c03543f0 100644 --- a/arangodb-net-standard/Serialization/JsonNetApiClientSerialization.cs +++ b/arangodb-net-standard/Serialization/JsonNetApiClientSerialization.cs @@ -2,7 +2,9 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using System.IO; +using System.Runtime.InteropServices.ComTypes; using System.Text; +using System.Threading.Tasks; namespace ArangoDBNetStandard.Serialization { @@ -36,6 +38,19 @@ public override T DeserializeFromStream(Stream stream) } } + /// + /// Asynchronously deserializes the data structure contained by the specified stream + /// into an instance of the specified type. + /// + /// The type of the object to deserialize to. + /// The stream containing the JSON structure to deserialize. + /// + public override async Task DeserializeFromStreamAsync(Stream stream) + { + T result = DeserializeFromStream(stream); + return await Task.FromResult(result); + } + /// /// /// @@ -51,6 +66,20 @@ public override byte[] Serialize(T item, ApiClientSerializationOptions serial return Encoding.UTF8.GetBytes(json); } + /// + /// Asynchronously serializes the specified object to a sequence of bytes, + /// following the provided rules for camel case property name and null value handling. + /// + /// The type of the object to serialize. + /// The object to serialize. + /// The serialization options. When the value is null the + /// the serialization options should be provided by the serializer, otherwise the given options should be used. + /// + public override async Task SerializeAsync(T item, ApiClientSerializationOptions serializationOptions) + { + var result = Serialize(item,serializationOptions); + return await Task.FromResult(result); + } /// /// Serializes an object to JSON string @@ -90,5 +119,20 @@ public override string SerializeToString(T item, ApiClientSerializationOption return json; } + + /// + /// Asynchronously serializes the specified object to a JSON string, + /// following the provided rules for camel case property name and null value handling. + /// + /// The type of the object to serialize. + /// The object to serialize. + /// The serialization options. When the value is null the + /// the serialization options should be provided by the serializer, otherwise the given options should be used. + /// + public override async Task SerializeToStringAsync(T item, ApiClientSerializationOptions serializationOptions) + { + var result = SerializeToString(item, serializationOptions); + return await Task.FromResult(result); + } } } diff --git a/arangodb-net-standard/TransactionApi/TransactionApiClient.cs b/arangodb-net-standard/TransactionApi/TransactionApiClient.cs index 66cc0827..8f8af105 100644 --- a/arangodb-net-standard/TransactionApi/TransactionApiClient.cs +++ b/arangodb-net-standard/TransactionApi/TransactionApiClient.cs @@ -65,16 +65,16 @@ public virtual async Task> PostTransactionAsync( PostTransactionBody body, CancellationToken token = default) { - 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(_transactionApiPath, content, token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream>(stream); + return await DeserializeJsonFromStreamAsync>(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } @@ -101,10 +101,10 @@ public virtual async Task AbortTransaction(string tra var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } @@ -130,7 +130,7 @@ public virtual async Task BeginTransaction( ApiHeaderProperties headerProperties = null, CancellationToken token = default) { - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); string beginTransactionPath = string.Format(_streamTransactionApiPath, "begin"); using (var response = await _client.PostAsync( beginTransactionPath, @@ -141,10 +141,10 @@ public virtual async Task BeginTransaction( var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } @@ -171,10 +171,10 @@ public virtual async Task CommitTransaction(string tr var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } @@ -195,10 +195,10 @@ public virtual async Task GetAllRunningTransactions( var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } @@ -222,10 +222,10 @@ public virtual async Task GetTransactionStatus(string var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) { - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - var error = DeserializeJsonFromStream(stream); + var error =await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); throw new ApiErrorException(error); } } diff --git a/arangodb-net-standard/UserApi/UserApiClient.cs b/arangodb-net-standard/UserApi/UserApiClient.cs index 6c4b376e..35a955e8 100644 --- a/arangodb-net-standard/UserApi/UserApiClient.cs +++ b/arangodb-net-standard/UserApi/UserApiClient.cs @@ -58,15 +58,15 @@ public UserApiClient(IApiClientTransport client, IApiClientSerialization seriali public virtual async Task PostUserAsync(PostUserBody body, CancellationToken token = default) { - 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(_userApiPath, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -83,15 +83,15 @@ public virtual async Task PutUserAsync(string username, PutUser CancellationToken token = default) { string uri = _userApiPath + '/' + username; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); 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(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -108,15 +108,15 @@ public virtual async Task PatchUserAsync(string username, Pat CancellationToken token = default) { string uri = _userApiPath + '/' + username; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _client.PatchAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -137,9 +137,9 @@ public virtual async Task GetUserAsync(string username, if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -159,9 +159,9 @@ public virtual async Task DeleteUserAsync(string username, if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -181,9 +181,9 @@ public virtual async Task GetUsersAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -204,15 +204,15 @@ public virtual async Task PutDatabaseAccessLevelAsync( { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName); - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); 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(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -235,9 +235,9 @@ public virtual async Task GetDatabaseAccessLevelAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -263,9 +263,9 @@ public virtual async Task DeleteDatabaseAccessLevelAs if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -292,9 +292,9 @@ public virtual async Task GetAccessibleDatabases if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -318,15 +318,15 @@ public virtual async Task PutCollectionAccessLevelAsync( string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName) + "/" + WebUtility.UrlEncode(collectionName); - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); 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(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -352,9 +352,9 @@ public virtual async Task GetCollectionAccessLevelAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -383,9 +383,9 @@ public virtual async Task DeleteCollectionAccessLevel if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } } diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index 97d66670..dde01428 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -62,9 +62,9 @@ public virtual async Task GetAllViewsAsync( if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -83,19 +83,19 @@ public virtual async Task GetAllViewsAsync( public virtual async Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization=true, CancellationToken token = default) { string uri = _apiPath; - var content = GetContent(body, - new ApiClientSerializationOptions( - useCamelCasePropertyNames: true, - ignoreNullValues: ignoreNullValuesOnSerialization, - applySerializationOptionsToDictionaryValues: true)); + + var content = await GetContentAsync(body, new ApiClientSerializationOptions(useCamelCasePropertyNames: true, + ignoreNullValues: ignoreNullValuesOnSerialization, + applySerializationOptionsToDictionaryValues: true)).ConfigureAwait(false); + using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -115,9 +115,9 @@ public virtual async Task DeleteViewAsync(string viewNameOrI if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -137,9 +137,9 @@ public virtual async Task GetViewAsync(string viewNameOrId, if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -159,9 +159,9 @@ public virtual async Task GetViewPropertiesAsync(stri if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -182,19 +182,18 @@ public virtual async Task PatchViewPropertiesAsync(string viewName bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; - var content = GetContent(body, - new ApiClientSerializationOptions( - useCamelCasePropertyNames: true, - ignoreNullValues: ignoreNullValuesOnSerialization, - applySerializationOptionsToDictionaryValues: true)); + + var content = await GetContentAsync(body, new ApiClientSerializationOptions(useCamelCasePropertyNames: true, + ignoreNullValues: ignoreNullValuesOnSerialization, + applySerializationOptionsToDictionaryValues: true)).ConfigureAwait(false); using (var response = await _transport.PatchAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -215,19 +214,18 @@ public virtual async Task PutViewPropertiesAsync(string viewName, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/properties"; - var content = GetContent(body, - new ApiClientSerializationOptions( - useCamelCasePropertyNames: true, - ignoreNullValues: ignoreNullValuesOnSerialization, - applySerializationOptionsToDictionaryValues: true)); + + var content = await GetContentAsync(body, new ApiClientSerializationOptions(useCamelCasePropertyNames: true, + ignoreNullValues: ignoreNullValuesOnSerialization, + applySerializationOptionsToDictionaryValues: true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } @@ -243,15 +241,15 @@ public virtual async Task PutRenameViewAsync(string viewN CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/rename"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return DeserializeJsonFromStream(stream); + return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); } - throw await GetApiErrorException(response).ConfigureAwait(false); + throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } }