diff --git a/Deepgram.Dev.sln b/Deepgram.Dev.sln
index 744e5ce0..d0f59b96 100644
--- a/Deepgram.Dev.sln
+++ b/Deepgram.Dev.sln
@@ -169,6 +169,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "reconnect_same_object", "re
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReconnectStreaming", "tests\edge_cases\reconnect_same_object\ReconnectStreaming.csproj", "{64AB4BAC-6917-424D-A5EA-BA023BD7795A}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "stt_v1_client_example", "stt_v1_client_example", "{0BF29CA2-1CD6-4FF0-BC7B-B33C6B41E9A1}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tts_v1_client_example", "tts_v1_client_example", "{5CEEB2F0-F284-4BB3-8999-6E91151C0C06}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "tests\edge_cases\stt_v1_client_example\Streaming.csproj", "{964A87B4-31F8-4D68-AE64-64E66C9959FD}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speak", "tests\edge_cases\tts_v1_client_example\Speak.csproj", "{AB053DDA-2487-476C-9793-A50C37F10CCA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -311,6 +319,14 @@ Global
{64AB4BAC-6917-424D-A5EA-BA023BD7795A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64AB4BAC-6917-424D-A5EA-BA023BD7795A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64AB4BAC-6917-424D-A5EA-BA023BD7795A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {964A87B4-31F8-4D68-AE64-64E66C9959FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {964A87B4-31F8-4D68-AE64-64E66C9959FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {964A87B4-31F8-4D68-AE64-64E66C9959FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {964A87B4-31F8-4D68-AE64-64E66C9959FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AB053DDA-2487-476C-9793-A50C37F10CCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AB053DDA-2487-476C-9793-A50C37F10CCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AB053DDA-2487-476C-9793-A50C37F10CCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AB053DDA-2487-476C-9793-A50C37F10CCA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -392,6 +408,10 @@ Global
{ECB0B55E-54C1-4723-8641-9249E7507FB0} = {2F92D959-D3C7-4EFF-8549-C6162E517644}
{6E328CB9-8C9B-446B-B83E-3796804497F7} = {1280E66D-A375-422A-ACB4-48F17E9C190E}
{64AB4BAC-6917-424D-A5EA-BA023BD7795A} = {6E328CB9-8C9B-446B-B83E-3796804497F7}
+ {0BF29CA2-1CD6-4FF0-BC7B-B33C6B41E9A1} = {1280E66D-A375-422A-ACB4-48F17E9C190E}
+ {5CEEB2F0-F284-4BB3-8999-6E91151C0C06} = {1280E66D-A375-422A-ACB4-48F17E9C190E}
+ {964A87B4-31F8-4D68-AE64-64E66C9959FD} = {0BF29CA2-1CD6-4FF0-BC7B-B33C6B41E9A1}
+ {AB053DDA-2487-476C-9793-A50C37F10CCA} = {5CEEB2F0-F284-4BB3-8999-6E91151C0C06}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D4ABC6D-7126-4EE2-9303-43A954616B2A}
diff --git a/Deepgram.Tests/Fakes/ConcreteRestClient.cs b/Deepgram.Tests/Fakes/ConcreteRestClient.cs
index 8c57fdd3..ca7bb61a 100644
--- a/Deepgram.Tests/Fakes/ConcreteRestClient.cs
+++ b/Deepgram.Tests/Fakes/ConcreteRestClient.cs
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT
using Deepgram.Models.Authenticate.v1;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.Fakes;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/AbstractRestClientTests.cs b/Deepgram.Tests/UnitTests/ClientTests/AbstractRestClientTests.cs
index 91f6edb1..bbc93d6d 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/AbstractRestClientTests.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/AbstractRestClientTests.cs
@@ -5,7 +5,6 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.PreRecorded.v1;
-using Deepgram.Models.Exceptions.v1;
using Deepgram.Clients.Manage.v1;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/AnalyzeClientTests.cs b/Deepgram.Tests/UnitTests/ClientTests/AnalyzeClientTests.cs
index 3eae0f22..e38678d9 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/AnalyzeClientTests.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/AnalyzeClientTests.cs
@@ -5,6 +5,7 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Clients.Analyze.v1;
using Deepgram.Models.Analyze.v1;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.ClientTests;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs b/Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
index 6732e5b6..671970ac 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
@@ -5,8 +5,7 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;
using Deepgram.Clients.Manage.v1;
-using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection;
-using NSubstitute;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.ClientTests;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs b/Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs
index 2b786c8a..575c676b 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs
@@ -5,6 +5,7 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.SelfHosted.v1;
using Deepgram.Clients.SelfHosted.v1;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.ClientTests;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/PrerecordedClientTests.cs b/Deepgram.Tests/UnitTests/ClientTests/PrerecordedClientTests.cs
index 4ca51130..335f1e08 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/PrerecordedClientTests.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/PrerecordedClientTests.cs
@@ -5,6 +5,7 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Clients.Listen.v1.REST;
using Deepgram.Models.Listen.v1.REST;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.ClientTests;
diff --git a/Deepgram.Tests/UnitTests/ClientTests/SpeakClientTests.cs b/Deepgram.Tests/UnitTests/ClientTests/SpeakClientTests.cs
index b9b84e5e..47375c6f 100644
--- a/Deepgram.Tests/UnitTests/ClientTests/SpeakClientTests.cs
+++ b/Deepgram.Tests/UnitTests/ClientTests/SpeakClientTests.cs
@@ -5,6 +5,7 @@
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Speak.v1.REST;
using Deepgram.Clients.Speak.v1.REST;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.ClientTests;
diff --git a/Deepgram.Tests/UnitTests/UtilitiesTests/RequestContentUtilTests.cs b/Deepgram.Tests/UnitTests/UtilitiesTests/RequestContentUtilTests.cs
index cdba2d3e..c13e2b6b 100644
--- a/Deepgram.Tests/UnitTests/UtilitiesTests/RequestContentUtilTests.cs
+++ b/Deepgram.Tests/UnitTests/UtilitiesTests/RequestContentUtilTests.cs
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
using Deepgram.Models.Manage.v1;
-using Deepgram.Abstractions;
+using Deepgram.Abstractions.v1;
namespace Deepgram.Tests.UnitTests.UtilitiesTests;
diff --git a/Deepgram/Abstractions/LocalFileWithMetadata.cs b/Deepgram/Abstractions/LocalFileWithMetadata.cs
deleted file mode 100644
index 9035750d..00000000
--- a/Deepgram/Abstractions/LocalFileWithMetadata.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved.
-// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
-// SPDX-License-Identifier: MIT
-
-namespace Deepgram.Abstractions;
-
-///
-/// LocalFileWithMetadata is a class that represents a file with metadata.
-///
-public class LocalFileWithMetadata
-{
- public Dictionary Metadata { get; set; }
-
- public MemoryStream Content { get; set; }
-}
diff --git a/Deepgram/Abstractions/AbstractRestClient.cs b/Deepgram/Abstractions/v1/AbstractRestClient.cs
similarity index 95%
rename from Deepgram/Abstractions/AbstractRestClient.cs
rename to Deepgram/Abstractions/v1/AbstractRestClient.cs
index 56ba7901..07decabd 100644
--- a/Deepgram/Abstractions/AbstractRestClient.cs
+++ b/Deepgram/Abstractions/v1/AbstractRestClient.cs
@@ -1,782 +1,782 @@
-// Copyright 2021-2024 Deepgram .NET SDK contributors. All Rights Reserved.
-// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
-// SPDX-License-Identifier: MIT
-
-using Deepgram.Encapsulations;
-using Deepgram.Models.Authenticate.v1;
-using Deepgram.Models.Exceptions.v1;
-
-namespace Deepgram.Abstractions;
-
-public abstract class AbstractRestClient
-{
- ///
- /// HttpClient created by the factory
- internal HttpClient _httpClient;
-
- ///
- /// Copy of the options for the client
- ///
- internal IDeepgramClientOptions _options;
-
- ///
- /// Constructor that take the options and a httpClient
- ///
- /// Options for the Deepgram client
-
- internal AbstractRestClient(string? apiKey = null, IDeepgramClientOptions? options = null, string? httpId = null)
- {
- Log.Verbose("AbstractRestClient", "ENTER");
-
- if (options == null)
- {
- options = (IDeepgramClientOptions) new DeepgramHttpClientOptions(apiKey);
- }
- _httpClient = HttpClientFactory.Create(httpId);
- _httpClient = HttpClientFactory.ConfigureDeepgram(_httpClient, options);
- _options = options;
-
- Log.Debug("AbstractRestClient", $"APIVersion: {options.APIVersion}");
- Log.Debug("AbstractRestClient", $"BaseAddress: {options.BaseAddress}");
- Log.Debug("AbstractRestClient", $"options: {options.OnPrem}");
- Log.Verbose("AbstractRestClient", "LEAVE");
- }
-
- ///
- /// GET Rest Request
- ///
- /// Type of class of response expected
- /// request uri Endpoint
- /// Instance of T
- public virtual async Task GetAsync(string uriSegment, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.GetAsync", "ENTER");
- Log.Debug("GetAsync", $"uriSegment: {uriSegment}");
- Log.Debug("GetAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("GetAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- NoopSchema? parameter = null;
- var request = new HttpRequestMessage(HttpMethod.Get, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("GetAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("GetAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("GetAsync", response, resultStr);
- }
-
- Log.Verbose("GetAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("GetAsync", "Succeeded");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("GetAsync", "Task was cancelled.");
- Log.Verbose("GetAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("GetAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("GetAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
- throw;
- }
- }
-
- public virtual async Task GetAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.GetAsync", "ENTER");
- Log.Debug("GetAsync", $"uriSegment: {uriSegment}");
- Log.Debug("GetAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("GetAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Get, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("GetAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("GetAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("GetAsync", response, resultStr);
- }
-
- Log.Verbose("GetAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("GetAsync", "Succeeded");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("GetAsync", "Task was cancelled.");
- Log.Verbose("GetAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("GetAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("GetAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Post method
- ///
- /// Class type of what return type is expected
- /// Uri for the api including the query parameters
- /// HttpContent as content for HttpRequestMessage
- /// Instance of T
- public virtual async Task PostRetrieveLocalFileAsync(string uriSegment, S? parameter, R? content,
- List? keys = null, CancellationTokenSource? cancellationToken = null, Dictionary? addons = null,
- Dictionary? headers = null
- )
- {
- Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "ENTER");
- Log.Debug("PostRetrieveLocalFileAsync", $"uriSegment: {uriSegment}");
- Log.Debug("PostRetrieveLocalFileAsync", $"keys: {keys}");
- Log.Debug("PostRetrieveLocalFileAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("PostRetrieveLocalFileAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Post, QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
- {
- Content = HttpRequestUtil.CreatePayload(content)
- };
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("PostRetrieveLocalFileAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("PostRetrieveLocalFileAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("PostRetrieveLocalFileAsync", response, response.Content.ReadAsStringAsync().Result);
- }
-
- var result = new Dictionary();
-
- if (keys != null)
- {
- for (int i = 0; i < response.Headers.Count(); i++)
- {
- var key = response.Headers.ElementAt(i).Key.ToLower();
- var value = response.Headers.GetValues(key).FirstOrDefault() ?? "";
-
- var index = key.IndexOf("x-dg-");
- if (index == 0)
- {
- var newKey = key.Substring(5);
- if (keys.Contains(newKey))
- {
- result.Add(newKey, value);
- continue;
- }
- }
- index = key.IndexOf("dg-");
- if (index == 0)
- {
- var newKey = key.Substring(3);
- if (keys.Contains(newKey))
- {
- result.Add(newKey, value);
- continue;
- }
- }
- if (keys.Contains(key))
- {
- result.Add(key, value);
- }
- }
-
- if (keys.Contains("content-type"))
- {
- result.Add("content-type", response.Content.Headers.ContentType?.MediaType ?? "");
- }
- }
-
- MemoryStream stream = new MemoryStream();
- await response.Content.CopyToAsync(stream);
-
- Log.Verbose("PostRetrieveLocalFileAsync", "Succeeded");
- Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "LEAVE");
-
- return new LocalFileWithMetadata()
- {
- Metadata = result,
- Content = stream,
- };
-
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("PostRetrieveLocalFileAsync", "Task was cancelled.");
- Log.Verbose("PostRetrieveLocalFileAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("PostRetrieveLocalFileAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("PostRetrieveLocalFileAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Post method
- ///
- /// Class type of what return type is expected
- /// Uri for the api including the query parameters
- /// HttpContent as content for HttpRequestMessage
- /// Instance of T
- public virtual async Task PostAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.PostAsync", "ENTER");
- Log.Debug("PostAsync", $"uriSegment: {uriSegment}");
- Log.Debug("PostAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("PostAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Post, QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
- {
- Content = HttpRequestUtil.CreatePayload(parameter)
- };
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("PostAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("PostAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("PostAsync", response, resultStr);
- }
-
- Log.Verbose("PostAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("PostAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("PostAsync", "Task was cancelled.");
- Log.Verbose("PostAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("PostAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("PostAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
- throw;
- }
- }
-
- public virtual async Task PostAsync(string uriSegment, S? parameter, R? content, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.PostAsync", "ENTER");
- Log.Debug("PostAsync", $"uriSegment: {uriSegment}");
- Log.Debug("PostAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("PostAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Post, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
- if (typeof(R) == typeof(Stream))
- {
- Stream? stream = content as Stream;
- if (stream == null)
- {
- stream = new MemoryStream();
- }
- request.Content = HttpRequestUtil.CreateStreamPayload(stream);
- }
- else
- {
- request.Content = HttpRequestUtil.CreatePayload(content);
- }
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("PostAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("PostAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("PostAsync", response, resultStr);
- }
-
- Log.Verbose("PostAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("PostAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("PostAsync", "Task was cancelled.");
- Log.Verbose("PostAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("PostAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("PostAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.PostAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Patch method call that takes a body object
- ///
- /// Class type of what return type is expected
- /// Uri for the api including the query parameters
- /// Instance of T
- public virtual async Task PatchAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.PatchAsync", "ENTER");
- Log.Debug("PatchAsync", $"uriSegment: {uriSegment}");
- Log.Debug("PatchAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("PatchAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
-#if NETSTANDARD2_0
- var request = new HttpRequestMessage(new HttpMethod("PATCH"), QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
- {
- Content = HttpRequestUtil.CreatePayload(parameter)
- };
-#else
- var request = new HttpRequestMessage(HttpMethod.Patch, QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
- {
- Content = HttpRequestUtil.CreatePayload(parameter)
- };
-#endif
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("PatchAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("PatchAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("PatchAsync", response, resultStr);
- }
-
- Log.Verbose("PatchAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("PatchAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.PatchAsync", "LEAVE");
-
- return result;
-
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("PatchAsync", "Task was cancelled.");
- Log.Verbose("PatchAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.PatchAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("PatchAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("PatchAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.PatchAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Put method call that takes a body object
- ///
- /// Class type of what return type is expected
- /// Uri for the api
- /// Instance of T
- public virtual async Task PutAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.PutAsync", "ENTER");
- Log.Debug("PutAsync", $"uriSegment: {uriSegment}");
- Log.Debug("PutAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("PutAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Put, QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
- {
- Content = HttpRequestUtil.CreatePayload(parameter)
- };
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- var tmp = header.Key.ToLower();
- if ( !(tmp.Contains("password") || tmp.Contains("token") || tmp.Contains("authorization") || tmp.Contains("auth")) )
- {
- Log.Debug("PutAsync", $"Add Header {header.Key}={header.Value}");
- }
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("PutAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("PutAsync", response, resultStr);
- }
-
- Log.Verbose("PutAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("PutAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.PutAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("PutAsync", "Task was cancelled.");
- Log.Verbose("PutAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.PutAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("PutAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("PutAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.PutAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Delete Method for use with calls that do not expect a response
- ///
- /// Uri for the api including the query parameters
- public virtual async Task DeleteAsync(string uriSegment, CancellationTokenSource? cancellationToken = null,
- Dictionary? addons = null, Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.DeleteAsync", "ENTER");
- Log.Debug("DeleteAsync", $"uriSegment: {uriSegment}");
- Log.Debug("DeleteAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("DeleteAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Delete, QueryParameterUtil.FormatURL(uriSegment, new NoopSchema(), addons));
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("DeleteAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("DeleteAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("DeleteAsync", response, resultStr);
- }
-
- Log.Verbose("DeleteAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("DeleteAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("DeleteAsync", "Task was cancelled.");
- Log.Verbose("DeleteAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("DeleteAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("DeleteAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
- throw;
- }
- }
-
- ///
- /// Delete method that returns the type of response specified
- ///
- /// Class Type of expected response
- /// Uri for the api including the query parameters
- /// Instance of T or throws Exception
- public virtual async Task DeleteAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null, Dictionary? addons = null,
- Dictionary? headers = null)
- {
- Log.Verbose("AbstractRestClient.DeleteAsync", "ENTER");
- Log.Debug("DeleteAsync", $"uriSegment: {uriSegment}");
- Log.Debug("DeleteAsync", $"addons: {addons}");
-
- try
- {
- // if not defined, use default timeout
- if (cancellationToken == null)
- {
- Log.Information("DeleteAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
- cancellationToken = new CancellationTokenSource();
- cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
- }
-
- // create request message and add custom query parameters
- var request = new HttpRequestMessage(HttpMethod.Delete, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
-
- // add custom headers
- if (headers != null)
- {
- foreach (var header in headers)
- {
- Log.Debug("DeleteAsync", $"Add Header {header.Key}={header.Value}");
- request.Headers.Add(header.Key, header.Value);
- }
- }
-
- // do the request
- Log.Verbose("DeleteAsync", "Calling _httpClient.SendAsync...");
- var response = await _httpClient.SendAsync(request, cancellationToken.Token);
-
- var resultStr = response.Content.ReadAsStringAsync().Result;
- if (!response.IsSuccessStatusCode)
- {
- await ThrowException("DeleteAsync", response, resultStr);
- }
-
- Log.Verbose("DeleteAsync", $"Response:\n{resultStr}");
- var result = await HttpRequestUtil.DeserializeAsync(response);
-
- Log.Debug("DeleteAsync", $"Succeeded");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
-
- return result;
- }
- catch (OperationCanceledException ex)
- {
- Log.Information("DeleteAsync", "Task was cancelled.");
- Log.Verbose("DeleteAsync", $"Connect cancelled. Info: {ex}");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
- throw;
- }
- catch (Exception ex)
- {
- Log.Error("DeleteAsync", $"{ex.GetType()} thrown {ex.Message}");
- Log.Verbose("DeleteAsync", $"Excepton: {ex}");
- Log.Verbose("AbstractRestClient.DeleteAsync", "LEAVE");
- throw;
- }
- }
-
- private static async Task ThrowException(string module, HttpResponseMessage response, string errMsg)
- {
- if (errMsg == null || errMsg.Length == 0)
- {
- Log.Verbose(module, $"HTTP/REST Exception thrown");
- response.EnsureSuccessStatusCode(); // this throws the exception
- }
-
- Log.Verbose(module, $"Deepgram Exception: {errMsg}");
- DeepgramRESTException? resException = null;
- try
- {
- resException = await HttpRequestUtil.DeserializeAsync(response);
- }
- catch (Exception ex)
- {
- Log.Verbose(module, $"DeserializeAsync Error Exception: {ex}");
- }
-
- if (resException != null)
- {
- Log.Verbose(module, "DeepgramRESTException thrown");
- throw resException;
- }
-
- Log.Verbose(module, $"Deepgram Generic Exception thrown");
- throw new DeepgramException(errMsg);
- }
-
- internal static string GetUri(IDeepgramClientOptions options, string path)
- {
- return $"{options.BaseAddress}/{path}";
- }
-}
-
+// Copyright 2021-2024 Deepgram .NET SDK contributors. All Rights Reserved.
+// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
+// SPDX-License-Identifier: MIT
+
+using Deepgram.Encapsulations;
+using Deepgram.Models.Authenticate.v1;
+using Deepgram.Models.Exceptions.v1;
+
+namespace Deepgram.Abstractions.v1;
+
+public abstract class AbstractRestClient
+{
+ ///
+ /// HttpClient created by the factory
+ internal HttpClient _httpClient;
+
+ ///
+ /// Copy of the options for the client
+ ///
+ internal IDeepgramClientOptions _options;
+
+ ///
+ /// Constructor that take the options and a httpClient
+ ///
+ /// Options for the Deepgram client
+
+ internal AbstractRestClient(string? apiKey = null, IDeepgramClientOptions? options = null, string? httpId = null)
+ {
+ Log.Verbose("AbstractRestClient", "ENTER");
+
+ if (options == null)
+ {
+ options = new DeepgramHttpClientOptions(apiKey);
+ }
+ _httpClient = HttpClientFactory.Create(httpId);
+ _httpClient = HttpClientFactory.ConfigureDeepgram(_httpClient, options);
+ _options = options;
+
+ Log.Debug("AbstractRestClient", $"APIVersion: {options.APIVersion}");
+ Log.Debug("AbstractRestClient", $"BaseAddress: {options.BaseAddress}");
+ Log.Debug("AbstractRestClient", $"options: {options.OnPrem}");
+ Log.Verbose("AbstractRestClient", "LEAVE");
+ }
+
+ ///
+ /// GET Rest Request
+ ///
+ /// Type of class of response expected
+ /// request uri Endpoint
+ /// Instance of T
+ public virtual async Task GetAsync(string uriSegment, CancellationTokenSource? cancellationToken = null,
+ Dictionary? addons = null, Dictionary? headers = null)
+ {
+ Log.Verbose("AbstractRestClient.GetAsync", "ENTER");
+ Log.Debug("GetAsync", $"uriSegment: {uriSegment}");
+ Log.Debug("GetAsync", $"addons: {addons}");
+
+ try
+ {
+ // if not defined, use default timeout
+ if (cancellationToken == null)
+ {
+ Log.Information("GetAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
+ cancellationToken = new CancellationTokenSource();
+ cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
+ }
+
+ // create request message and add custom query parameters
+ NoopSchema? parameter = null;
+ var request = new HttpRequestMessage(HttpMethod.Get, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
+
+ // add custom headers
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ {
+ Log.Debug("GetAsync", $"Add Header {header.Key}={header.Value}");
+ request.Headers.Add(header.Key, header.Value);
+ }
+ }
+
+ // do the request
+ Log.Verbose("GetAsync", "Calling _httpClient.SendAsync...");
+ var response = await _httpClient.SendAsync(request, cancellationToken.Token);
+
+ var resultStr = response.Content.ReadAsStringAsync().Result;
+ if (!response.IsSuccessStatusCode)
+ {
+ await ThrowException("GetAsync", response, resultStr);
+ }
+
+ Log.Verbose("GetAsync", $"Response:\n{resultStr}");
+ var result = await HttpRequestUtil.DeserializeAsync(response);
+
+ Log.Debug("GetAsync", "Succeeded");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+ return result;
+ }
+ catch (OperationCanceledException ex)
+ {
+ Log.Information("GetAsync", "Task was cancelled.");
+ Log.Verbose("GetAsync", $"Connect cancelled. Info: {ex}");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+ throw;
+ }
+ catch (Exception ex)
+ {
+ Log.Error("GetAsync", $"{ex.GetType()} thrown {ex.Message}");
+ Log.Verbose("GetAsync", $"Excepton: {ex}");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+ throw;
+ }
+ }
+
+ public virtual async Task GetAsync(string uriSegment, S? parameter, CancellationTokenSource? cancellationToken = null,
+ Dictionary? addons = null, Dictionary? headers = null)
+ {
+ Log.Verbose("AbstractRestClient.GetAsync", "ENTER");
+ Log.Debug("GetAsync", $"uriSegment: {uriSegment}");
+ Log.Debug("GetAsync", $"addons: {addons}");
+
+ try
+ {
+ // if not defined, use default timeout
+ if (cancellationToken == null)
+ {
+ Log.Information("GetAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
+ cancellationToken = new CancellationTokenSource();
+ cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
+ }
+
+ // create request message and add custom query parameters
+ var request = new HttpRequestMessage(HttpMethod.Get, QueryParameterUtil.FormatURL(uriSegment, parameter, addons));
+
+ // add custom headers
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ {
+ Log.Debug("GetAsync", $"Add Header {header.Key}={header.Value}");
+ request.Headers.Add(header.Key, header.Value);
+ }
+ }
+
+ // do the request
+ Log.Verbose("GetAsync", "Calling _httpClient.SendAsync...");
+ var response = await _httpClient.SendAsync(request, cancellationToken.Token);
+
+ var resultStr = response.Content.ReadAsStringAsync().Result;
+ if (!response.IsSuccessStatusCode)
+ {
+ await ThrowException("GetAsync", response, resultStr);
+ }
+
+ Log.Verbose("GetAsync", $"Response:\n{resultStr}");
+ var result = await HttpRequestUtil.DeserializeAsync(response);
+
+ Log.Debug("GetAsync", "Succeeded");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+
+ return result;
+ }
+ catch (OperationCanceledException ex)
+ {
+ Log.Information("GetAsync", "Task was cancelled.");
+ Log.Verbose("GetAsync", $"Connect cancelled. Info: {ex}");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+ throw;
+ }
+ catch (Exception ex)
+ {
+ Log.Error("GetAsync", $"{ex.GetType()} thrown {ex.Message}");
+ Log.Verbose("GetAsync", $"Excepton: {ex}");
+ Log.Verbose("AbstractRestClient.GetAsync", "LEAVE");
+ throw;
+ }
+ }
+
+ ///
+ /// Post method
+ ///
+ /// Class type of what return type is expected
+ /// Uri for the api including the query parameters
+ /// HttpContent as content for HttpRequestMessage
+ /// Instance of T
+ public virtual async Task PostRetrieveLocalFileAsync(string uriSegment, S? parameter, R? content,
+ List? keys = null, CancellationTokenSource? cancellationToken = null, Dictionary? addons = null,
+ Dictionary? headers = null
+ )
+ {
+ Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "ENTER");
+ Log.Debug("PostRetrieveLocalFileAsync", $"uriSegment: {uriSegment}");
+ Log.Debug("PostRetrieveLocalFileAsync", $"keys: {keys}");
+ Log.Debug("PostRetrieveLocalFileAsync", $"addons: {addons}");
+
+ try
+ {
+ // if not defined, use default timeout
+ if (cancellationToken == null)
+ {
+ Log.Information("PostRetrieveLocalFileAsync", $"Using default timeout: {Constants.DefaultRESTTimeout}");
+ cancellationToken = new CancellationTokenSource();
+ cancellationToken.CancelAfter(Constants.DefaultRESTTimeout);
+ }
+
+ // create request message and add custom query parameters
+ var request = new HttpRequestMessage(HttpMethod.Post, QueryParameterUtil.FormatURL(uriSegment, parameter, addons))
+ {
+ Content = HttpRequestUtil.CreatePayload(content)
+ };
+
+ // add custom headers
+ if (headers != null)
+ {
+ foreach (var header in headers)
+ {
+ Log.Debug("PostRetrieveLocalFileAsync", $"Add Header {header.Key}={header.Value}");
+ request.Headers.Add(header.Key, header.Value);
+ }
+ }
+
+ // do the request
+ Log.Verbose("PostRetrieveLocalFileAsync", "Calling _httpClient.SendAsync...");
+ var response = await _httpClient.SendAsync(request, cancellationToken.Token);
+
+ if (!response.IsSuccessStatusCode)
+ {
+ await ThrowException("PostRetrieveLocalFileAsync", response, response.Content.ReadAsStringAsync().Result);
+ }
+
+ var result = new Dictionary();
+
+ if (keys != null)
+ {
+ for (var i = 0; i < response.Headers.Count(); i++)
+ {
+ var key = response.Headers.ElementAt(i).Key.ToLower();
+ var value = response.Headers.GetValues(key).FirstOrDefault() ?? "";
+
+ var index = key.IndexOf("x-dg-");
+ if (index == 0)
+ {
+ var newKey = key.Substring(5);
+ if (keys.Contains(newKey))
+ {
+ result.Add(newKey, value);
+ continue;
+ }
+ }
+ index = key.IndexOf("dg-");
+ if (index == 0)
+ {
+ var newKey = key.Substring(3);
+ if (keys.Contains(newKey))
+ {
+ result.Add(newKey, value);
+ continue;
+ }
+ }
+ if (keys.Contains(key))
+ {
+ result.Add(key, value);
+ }
+ }
+
+ if (keys.Contains("content-type"))
+ {
+ result.Add("content-type", response.Content.Headers.ContentType?.MediaType ?? "");
+ }
+ }
+
+ var stream = new MemoryStream();
+ await response.Content.CopyToAsync(stream);
+
+ Log.Verbose("PostRetrieveLocalFileAsync", "Succeeded");
+ Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "LEAVE");
+
+ return new LocalFileWithMetadata()
+ {
+ Metadata = result,
+ Content = stream,
+ };
+
+ }
+ catch (OperationCanceledException ex)
+ {
+ Log.Information("PostRetrieveLocalFileAsync", "Task was cancelled.");
+ Log.Verbose("PostRetrieveLocalFileAsync", $"Connect cancelled. Info: {ex}");
+ Log.Verbose("AbstractRestClient.PostRetrieveLocalFileAsync", "LEAVE");
+ throw;
+ }
+ catch (Exception ex)
+ {
+ Log.Error("PostRetrieveLocalFileAsync", $"{ex.GetType()} thrown {ex.Message}");
+ Log.Verbose("PostRetrieveLocalFileAsync