diff --git a/arangodb-net-standard.Test/ViewApi/ViewApiClientTest.cs b/arangodb-net-standard.Test/ViewApi/ViewApiClientTest.cs index 31c74df3..a1f504b4 100644 --- a/arangodb-net-standard.Test/ViewApi/ViewApiClientTest.cs +++ b/arangodb-net-standard.Test/ViewApi/ViewApiClientTest.cs @@ -44,10 +44,10 @@ public async Task GetAllViewsAsync_ShouldSucceed() }); var res = await _viewApi.GetAllViewsAsync(); - Assert.Equal(HttpStatusCode.OK, res.Code); - Assert.False(res.Error); - Assert.NotNull(res.Result); - Assert.NotEmpty(res.Result); + Assert.Equal(HttpStatusCode.OK, res.Response.Code); + Assert.False(res.Response.Error); + Assert.NotNull(res.Response.Result); + Assert.NotEmpty(res.Response.Result); } [Fact] diff --git a/arangodb-net-standard/AdminApi/AdminApiClient.cs b/arangodb-net-standard/AdminApi/AdminApiClient.cs index 02e2e895..b56d9300 100644 --- a/arangodb-net-standard/AdminApi/AdminApiClient.cs +++ b/arangodb-net-standard/AdminApi/AdminApiClient.cs @@ -53,19 +53,20 @@ public AdminApiClient(IApiClientTransport client, IApiClientSerialization serial /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Query string parameters + /// Headers for the request /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#read-global-logs-from-the-server /// - public virtual async Task GetLogsAsync(GetLogsQuery query = null, CancellationToken token = default) + public virtual async Task GetLogsAsync(GetLogsQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/log/entries"; if (query != null) { uri += '?' + query.ToQueryString(); } - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -80,17 +81,18 @@ public virtual async Task GetLogsAsync(GetLogsQuery query = nul /// Reloads the routing table. /// POST /_admin/routing/reload /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#reloads-the-routing-information /// - public virtual async Task PostReloadRoutingInfoAsync(CancellationToken token = default) + public virtual async Task PostReloadRoutingInfoAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/routing/reload"; var body = new byte[] { }; - using (var response = await _client.PostAsync(uri, body, null, token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(uri, body, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -105,16 +107,17 @@ public virtual async Task PostReloadRoutingInfoAsync(CancellationToken tok /// The method will fail if the server is not running in cluster mode. /// GET /_admin/server/id /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster /// - public virtual async Task GetServerIdAsync(CancellationToken token = default) + public virtual async Task GetServerIdAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/server/id"; - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -129,16 +132,17 @@ public virtual async Task GetServerIdAsync(CancellationToke /// Retrieves the role of the server in a cluster. /// GET /_admin/server/role /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-the-role-of-a-server-in-a-cluster /// - public virtual async Task GetServerRoleAsync(CancellationToken token = default) + public virtual async Task GetServerRoleAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/server/role"; - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -153,16 +157,17 @@ public virtual async Task GetServerRoleAsync(Cancellation /// Retrieves the server database engine type. /// GET /_api/engine /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-database-engine-type /// - public virtual async Task GetServerEngineTypeAsync(CancellationToken token = default) + public virtual async Task GetServerEngineTypeAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/engine"; - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -178,20 +183,21 @@ public virtual async Task GetServerEngineTypeAsync( /// GET /_api/version /// /// Query string parameters + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-version /// - public virtual async Task GetServerVersionAsync(GetServerVersionQuery query = null, CancellationToken token = default) + public virtual async Task GetServerVersionAsync(GetServerVersionQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/version"; if (query != null) { uri += '?' + query.ToQueryString(); } - using (var response = await _client.GetAsync(uri,null,token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -206,16 +212,17 @@ public virtual async Task GetServerVersionAsync(GetSer /// Retrieves the server license information. /// GET /_admin/license /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/3.9/administration-license.html /// - public virtual async Task GetLicenseAsync(CancellationToken token = default) + public virtual async Task GetLicenseAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/license"; - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -232,13 +239,14 @@ public virtual async Task GetLicenseAsync(CancellationToken /// /// The new license key /// Query string parameters + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/3.9/administration-license.html /// - public virtual async Task PutLicenseAsync(string licenseKey, PutLicenseQuery query = null, CancellationToken token = default) + public virtual async Task PutLicenseAsync(string licenseKey, PutLicenseQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_adminApiPath}/license"; if (query != null) @@ -246,7 +254,7 @@ public virtual async Task PutLicenseAsync(string licenseKey, uri += '?' + query.ToQueryString(); } var content = await GetContentAsync(licenseKey, new ApiClientSerializationOptions(true, true)); - using (var response = await _client.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(uri, content, headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/AdminApi/IAdminApiClient.cs b/arangodb-net-standard/AdminApi/IAdminApiClient.cs index 184a31ec..d72616ca 100644 --- a/arangodb-net-standard/AdminApi/IAdminApiClient.cs +++ b/arangodb-net-standard/AdminApi/IAdminApiClient.cs @@ -16,87 +16,94 @@ public interface IAdminApiClient /// Works on ArangoDB 3.8 or later. /// /// Query string parameters + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#read-global-logs-from-the-server /// - Task GetLogsAsync(GetLogsQuery query = null, CancellationToken token = default); + Task GetLogsAsync(GetLogsQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Reloads the routing table. /// POST /_admin/routing/reload /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#reloads-the-routing-information /// - Task PostReloadRoutingInfoAsync(CancellationToken token = default); + Task PostReloadRoutingInfoAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the internal id of the server. /// The method will fail if the server is not running in cluster mode. /// GET /_admin/server/id /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster /// - Task GetServerIdAsync(CancellationToken token = default); + Task GetServerIdAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the role of the server in a cluster. /// GET /_admin/server/role /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-the-role-of-a-server-in-a-cluster /// - Task GetServerRoleAsync(CancellationToken token = default); + Task GetServerRoleAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the server database engine type. /// GET /_api/engine /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-database-engine-type /// - Task GetServerEngineTypeAsync(CancellationToken token = default); + Task GetServerEngineTypeAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the server version. /// GET /_api/version /// /// Query string parameters + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-version /// - Task GetServerVersionAsync(GetServerVersionQuery query = null, CancellationToken token = default); - + Task GetServerVersionAsync(GetServerVersionQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); + /// /// Retrieves the server license information. /// GET /_admin/license /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/3.9/administration-license.html /// - Task GetLicenseAsync(CancellationToken token = default); + Task GetLicenseAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Sets a new license key. @@ -104,12 +111,13 @@ public interface IAdminApiClient /// /// The new license key /// Query string parameters + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// /// For further information see /// https://www.arangodb.com/docs/3.9/administration-license.html /// - Task PutLicenseAsync(string licenseKey, PutLicenseQuery query = null, CancellationToken token = default); + Task PutLicenseAsync(string licenseKey, PutLicenseQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs b/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs index ecb2558a..826f6a95 100644 --- a/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs +++ b/arangodb-net-standard/AnalyzerApi/AnalyzerApiClient.cs @@ -52,12 +52,13 @@ public AnalyzerApiClient(IApiClientTransport client, IApiClientSerialization ser /// Fetch the list of available Analyzer definitions. /// GET /_api/analyzer /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetAllAnalyzersAsync(CancellationToken token = default) + public virtual async Task GetAllAnalyzersAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _analyzerApiPath; - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -73,9 +74,10 @@ public virtual async Task GetAllAnalyzersAsync(Cancella /// POST /_api/analyzer /// /// The properties of the new analyzer. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostAnalyzerAsync(Analyzer body, CancellationToken token = default) + public virtual async Task PostAnalyzerAsync(Analyzer body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) { @@ -83,7 +85,7 @@ public virtual async Task PostAnalyzerAsync(Analyzer body, Cancellatio } var uri = _analyzerApiPath; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(uri, content, null, token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(uri, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -99,16 +101,17 @@ public virtual async Task PostAnalyzerAsync(Analyzer body, Cancellatio /// GET /_api/analyzer/{analyzer-name} /// /// The name of the analyzer + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetAnalyzerAsync(string analyzerName, CancellationToken token = default) + public virtual async Task GetAnalyzerAsync(string analyzerName, ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrEmpty(analyzerName)) { throw new ArgumentException("Analyzer name is required", nameof(analyzerName)); } string uri = _analyzerApiPath + '/' + WebUtility.UrlEncode(analyzerName); - using (var response = await _client.GetAsync(uri, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -124,16 +127,17 @@ public virtual async Task GetAnalyzerAsync(string analyzerN /// DELETE /_api/analyzer/{analyzer-name} /// /// The name of the analyzer + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task DeleteAnalyzerAsync(string analyzerName, CancellationToken token = default) + public virtual async Task DeleteAnalyzerAsync(string analyzerName, ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrEmpty(analyzerName)) { throw new ArgumentException("Analyzer name is required", nameof(analyzerName)); } string uri = _analyzerApiPath + '/' + WebUtility.UrlEncode(analyzerName); - using (var response = await _client.DeleteAsync(uri,null,token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection() ,token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/AnalyzerApi/IAnalyzerApiClient.cs b/arangodb-net-standard/AnalyzerApi/IAnalyzerApiClient.cs index c83bebab..d1314fcc 100644 --- a/arangodb-net-standard/AnalyzerApi/IAnalyzerApiClient.cs +++ b/arangodb-net-standard/AnalyzerApi/IAnalyzerApiClient.cs @@ -13,35 +13,39 @@ internal interface IAnalyzerApiClient /// Fetch the list of available Analyzer definitions. /// GET /_api/analyzer /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetAllAnalyzersAsync(CancellationToken token = default); + Task GetAllAnalyzersAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Creates a new Analyzer based on the provided definition /// POST /_api/analyzer /// /// The properties of the new analyzer. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostAnalyzerAsync(Analyzer body, CancellationToken token = default); + Task PostAnalyzerAsync(Analyzer body, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Fetches the definition of the specified analyzer. /// GET /_api/analyzer/{analyzer-name} /// /// The name of the analyzer + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetAnalyzerAsync(string analyzerName, CancellationToken token = default); + Task GetAnalyzerAsync(string analyzerName, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Deletes an Analyzer. /// DELETE /_api/analyzer/{analyzer-name} /// /// The name of the analyzer + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task DeleteAnalyzerAsync(string analyzerName, CancellationToken token = default); + Task DeleteAnalyzerAsync(string analyzerName, ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/ApiClientBase.cs b/arangodb-net-standard/ApiClientBase.cs index dba79340..dba4b0fe 100644 --- a/arangodb-net-standard/ApiClientBase.cs +++ b/arangodb-net-standard/ApiClientBase.cs @@ -1,7 +1,10 @@ using ArangoDBNetStandard.Serialization; using ArangoDBNetStandard.Transport; +using ArangoDBNetStandard.ViewApi.Models; using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; namespace ArangoDBNetStandard @@ -31,7 +34,22 @@ protected async Task GetApiErrorExceptionAsync(IApiClientResp try { var error = await _serialization.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - return new ApiErrorException(error); + var ex = new ApiErrorException(error); + if (response.Headers != null) + { + ex.Headers = new Dictionary(); + foreach (var rh in response.Headers) + { + var key = rh.Key; + var value = string.Empty; + if (rh.Value != null) + { + value = string.Join(",", rh.Value); + } + ex.Headers.Add(key, value); + } + } + return ex; } catch (Exception e) { @@ -90,5 +108,25 @@ protected async Task GetContentStringAsync(T item, ApiClientSerializa } } + protected async Task> GetResponseAsync(IApiClientResponse response) + { + var apiResponse = new ApiResponse() { Headers = new Dictionary() }; + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + apiResponse.Response = await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); + if (response.Headers != null) + { + foreach (var rh in response.Headers) + { + var key = rh.Key; + var value = string.Empty; + if (rh.Value != null) + { + value = string.Join(",", rh.Value); + } + apiResponse.Headers.Add(key, value); + } + } + return apiResponse; + } } -} +} \ No newline at end of file diff --git a/arangodb-net-standard/ApiErrorException.cs b/arangodb-net-standard/ApiErrorException.cs index fbec5399..3b8ebd9a 100644 --- a/arangodb-net-standard/ApiErrorException.cs +++ b/arangodb-net-standard/ApiErrorException.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Runtime.Serialization; namespace ArangoDBNetStandard @@ -11,6 +12,7 @@ public class ApiErrorException : Exception /// in the response. /// public ApiErrorResponse ApiError { get; set; } + public Dictionary Headers { get; set; } public ApiErrorException() { diff --git a/arangodb-net-standard/ApiHeaderProperties.cs b/arangodb-net-standard/ApiHeaderProperties.cs index 8c9a619e..46c0dbb0 100644 --- a/arangodb-net-standard/ApiHeaderProperties.cs +++ b/arangodb-net-standard/ApiHeaderProperties.cs @@ -18,6 +18,16 @@ public class ApiHeaderProperties /// public bool? AllowReadFromFollowers { get; set; } + /// + /// Set max queue time limit. + /// When executing a request, specify a maximal + /// queue time in seconds before the request is + /// canceled and removed from the queue. + /// The value 0 is ignored by the server. + /// Introduced in ArangoDB 3.9 + /// + public decimal? MaxQueueTimeLimit { get; set; } + /// /// Any other headers you wish to add based on /// the specifications of the API operation. @@ -37,6 +47,11 @@ public WebHeaderCollection ToWebHeaderCollection() collection.Add(CustomHttpHeaders.ReadFromFollowersHeader, AllowReadFromFollowers.Value.ToString()); } + if (MaxQueueTimeLimit != null) + { + collection.Add(CustomHttpHeaders.MaxQueueTimeLimitHeader, MaxQueueTimeLimit.Value.ToString()); + } + if (OtherHeaders != null && OtherHeaders.Count > 0) { foreach (string key in OtherHeaders.Keys) diff --git a/arangodb-net-standard/ApiResponse.cs b/arangodb-net-standard/ApiResponse.cs new file mode 100644 index 00000000..c60d222b --- /dev/null +++ b/arangodb-net-standard/ApiResponse.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ArangoDBNetStandard +{ + /// + /// Represents a generic response from ArangoDB server. + /// + /// + public class ApiResponse + { + /// + /// Header values returned by the server + /// + public Dictionary Headers { get; set; } + + /// + /// The response object returned by the server + /// + public T Response { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs b/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs index 66d8626e..9f9d497a 100644 --- a/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs +++ b/arangodb-net-standard/AqlFunctionApi/AqlFunctionApiClient.cs @@ -53,15 +53,16 @@ public AqlFunctionApiClient(IApiClientTransport transport, IApiClientSerializati /// POST /_api/aqlfunction /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostAqlFunctionAsync( - PostAqlFunctionBody body, + PostAqlFunctionBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PostAsync(_apiPath, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(_apiPath, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -78,11 +79,12 @@ public virtual async Task PostAqlFunctionAsync( /// /// The name of the function or function group (namespace). /// The query parameters of the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteAqlFunctionAsync( string name, - DeleteAqlFunctionQuery query = null, + DeleteAqlFunctionQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _apiPath + '/' + WebUtility.UrlEncode(name); @@ -92,7 +94,7 @@ public virtual async Task DeleteAqlFunctionAsync( uri += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -107,10 +109,11 @@ public virtual async Task DeleteAqlFunctionAsync( /// Get all registered AQL user functions. /// /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetAqlFunctionsAsync( - GetAqlFunctionsQuery query = null, + GetAqlFunctionsQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _apiPath; @@ -120,7 +123,7 @@ public virtual async Task GetAqlFunctionsAsync( uri += "?" + query.ToQueryString(); } - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -136,10 +139,11 @@ public virtual async Task GetAqlFunctionsAsync( /// POST /_api/explain /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostExplainAqlQueryAsync( - PostExplainAqlQueryBody body, + PostExplainAqlQueryBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) @@ -150,7 +154,7 @@ public virtual async Task PostExplainAqlQueryAsync( string uri = "_api/explain"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -166,10 +170,11 @@ public virtual async Task PostExplainAqlQueryAsync( /// POST /_api/query /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostParseAqlQueryAsync( - PostParseAqlQueryBody body, + PostParseAqlQueryBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) @@ -180,7 +185,7 @@ public virtual async Task PostParseAqlQueryAsync( string uri = "_api/query"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -202,6 +207,7 @@ public virtual async Task PostParseAqlQueryAsync( /// the specified query in all databases, not just the /// selected one. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Kills a running query in the currently selected database. @@ -212,7 +218,7 @@ public virtual async Task PostParseAqlQueryAsync( /// public virtual async Task DeleteKillRunningAqlQueryAsync( string queryId, - DeleteKillRunningAqlQueryQuery query = null, + DeleteKillRunningAqlQueryQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(queryId)) @@ -227,7 +233,7 @@ public virtual async Task DeleteKillRunningAqlQueryAsync( uri += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -249,10 +255,11 @@ public virtual async Task DeleteKillRunningAqlQueryAsync( /// Using the parameter is only allowed in the system database /// and with superuser privileges. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteClearSlowAqlQueriesAsync( - DeleteClearSlowAqlQueriesQuery query = null, + DeleteClearSlowAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query/slow"; @@ -262,7 +269,7 @@ public virtual async Task DeleteClearSlowAqlQueriesAsync( uri += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -284,6 +291,7 @@ public virtual async Task DeleteClearSlowAqlQueriesAsync( /// Using the parameter is only allowed in the system database /// and with superuser privileges. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array containing the last AQL queries that are @@ -295,7 +303,7 @@ public virtual async Task DeleteClearSlowAqlQueriesAsync( /// /// public virtual async Task> GetSlowAqlQueriesAsync( - GetSlowAqlQueriesQuery query = null, + GetSlowAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query/slow"; @@ -305,7 +313,7 @@ public virtual async Task> GetSlowAqlQueriesAsync( uri += "?" + query.ToQueryString(); } - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -322,14 +330,15 @@ public virtual async Task> GetSlowAqlQueriesAsync( /// Clears the query results cache for the current database /// DELETE /_api/query-cache /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task DeleteClearAqlQueryCacheAsync( + public virtual async Task DeleteClearAqlQueryCacheAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query-cache"; - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -344,17 +353,18 @@ public virtual async Task DeleteClearAqlQueryCacheAsync( /// Gets a list of the stored results in the AQL query results cache. /// GET /_api/query-cache/entries /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array containing the AQL query results currently /// stored in the query results cache of the selected database. /// /// - public virtual async Task> GetCachedAqlQueryResultsAsync( + public virtual async Task> GetCachedAqlQueryResultsAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query-cache/entries"; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -368,16 +378,17 @@ public virtual async Task> GetCachedAqlQueryResultsAs /// /// Gets the global configuration for the AQL query results cache. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns the global AQL query results cache configuration. /// /// - public virtual async Task GetQueryCacheGlobalPropertiesAsync( + public virtual async Task GetQueryCacheGlobalPropertiesAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query-cache/properties"; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -393,6 +404,7 @@ public virtual async Task GetQueryCacheGlobalPropert /// PUT /_api/query-cache/properties /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// After the properties have been changed, the current set of properties @@ -401,7 +413,7 @@ public virtual async Task GetQueryCacheGlobalPropert /// /// public virtual async Task PutAdjustQueryCacheGlobalPropertiesAsync( - PutAdjustQueryCacheGlobalPropertiesBody body, + PutAdjustQueryCacheGlobalPropertiesBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) @@ -412,7 +424,7 @@ public virtual async Task PutAdjustQueryCacheGlobalP string uri = "_api/query-cache/properties"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uri, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -427,13 +439,14 @@ public virtual async Task PutAdjustQueryCacheGlobalP /// Gets the current query tracking configuration. /// GET /_api/query/properties /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetQueryTrackingConfigurationAsync( + public virtual async Task GetQueryTrackingConfigurationAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query/properties"; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -453,10 +466,11 @@ public virtual async Task GetQueryTrackingConfigurat /// the current set of properties will be returned. /// /// The body of the request containing required configuration properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutChangeQueryTrackingConfigurationAsync( - PutChangeQueryTrackingConfigurationBody body, + PutChangeQueryTrackingConfigurationBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) @@ -467,7 +481,7 @@ public virtual async Task PutChangeQueryTrackingConf string uri = "_api/query/properties"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uri, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -482,13 +496,14 @@ public virtual async Task PutChangeQueryTrackingConf /// Gets a list of currently running AQL queries. /// /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns the global AQL query results cache configuration. /// /// public virtual async Task> GetCurrentlyRunningAqlQueriesAsync( - GetCurrentlyRunningAqlQueriesQuery query = null, + GetCurrentlyRunningAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query/current"; @@ -498,7 +513,7 @@ public virtual async Task> GetCurrentlyRunningAqlQueriesAs uri += "?" + query.ToQueryString(); } - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -513,17 +528,18 @@ public virtual async Task> GetCurrentlyRunningAqlQueriesAs /// Gets the available optimizer rules for AQL queries /// GET /_api/query/rules /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array of objects that contain the name of each available /// rule and its respective flags. /// /// - public virtual async Task> GetQueryRulesAsync(CancellationToken token = default) + public virtual async Task> GetQueryRulesAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = "_api/query/rules"; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/AqlFunctionApi/IAqlFunctionApiClient.cs b/arangodb-net-standard/AqlFunctionApi/IAqlFunctionApiClient.cs index aa55b603..fdd6e5a5 100644 --- a/arangodb-net-standard/AqlFunctionApi/IAqlFunctionApiClient.cs +++ b/arangodb-net-standard/AqlFunctionApi/IAqlFunctionApiClient.cs @@ -16,9 +16,10 @@ public interface IAqlFunctionApiClient /// POST /_api/aqlfunction /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostAqlFunctionAsync(PostAqlFunctionBody body, + Task PostAqlFunctionAsync(PostAqlFunctionBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -26,22 +27,25 @@ Task PostAqlFunctionAsync(PostAqlFunctionBody body, /// DELETE /_api/aqlfunction/{name} /// /// The name of the function or function group (namespace). + /// Headers for the request /// The query parameters of the request. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteAqlFunctionAsync( string name, - DeleteAqlFunctionQuery query = null, + DeleteAqlFunctionQuery query = null, + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get all registered AQL user functions. /// /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetAqlFunctionsAsync( - GetAqlFunctionsQuery query = null, + GetAqlFunctionsQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -49,10 +53,11 @@ Task GetAqlFunctionsAsync( /// POST /_api/explain /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostExplainAqlQueryAsync( - PostExplainAqlQueryBody body, + PostExplainAqlQueryBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -60,10 +65,11 @@ Task PostExplainAqlQueryAsync( /// POST /_api/query /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostParseAqlQueryAsync( - PostParseAqlQueryBody body, + PostParseAqlQueryBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -77,6 +83,7 @@ Task PostParseAqlQueryAsync( /// the specified query in all databases, not just the /// selected one. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Kills a running query in the currently selected database. @@ -87,7 +94,7 @@ Task PostParseAqlQueryAsync( /// Task DeleteKillRunningAqlQueryAsync( string queryId, - DeleteKillRunningAqlQueryQuery query = null, + DeleteKillRunningAqlQueryQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -101,10 +108,11 @@ Task DeleteKillRunningAqlQueryAsync( /// Using the parameter is only allowed in the system database /// and with superuser privileges. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteClearSlowAqlQueriesAsync( - DeleteClearSlowAqlQueriesQuery query = null, + DeleteClearSlowAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -118,6 +126,7 @@ Task DeleteClearSlowAqlQueriesAsync( /// Using the parameter is only allowed in the system database /// and with superuser privileges. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array containing the last AQL queries that are @@ -129,40 +138,43 @@ Task DeleteClearSlowAqlQueriesAsync( /// /// Task> GetSlowAqlQueriesAsync( - GetSlowAqlQueriesQuery query = null, + GetSlowAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Clears the query results cache for the current database /// DELETE /_api/query-cache /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task DeleteClearAqlQueryCacheAsync( + Task DeleteClearAqlQueryCacheAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Gets a list of the stored results in the AQL query results cache. /// GET /_api/query-cache/entries /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array containing the AQL query results currently /// stored in the query results cache of the selected database. /// /// - Task> GetCachedAqlQueryResultsAsync( + Task> GetCachedAqlQueryResultsAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Gets the global configuration for the AQL query results cache. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns the global AQL query results cache configuration. /// /// - Task GetQueryCacheGlobalPropertiesAsync( + Task GetQueryCacheGlobalPropertiesAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -170,6 +182,7 @@ Task GetQueryCacheGlobalPropertiesAsync( /// PUT /_api/query-cache/properties /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// After the properties have been changed, the current set of properties @@ -178,7 +191,7 @@ Task GetQueryCacheGlobalPropertiesAsync( /// /// Task PutAdjustQueryCacheGlobalPropertiesAsync( - PutAdjustQueryCacheGlobalPropertiesBody body, + PutAdjustQueryCacheGlobalPropertiesBody body, ApiHeaderProperties headers = null, CancellationToken token = default); @@ -186,9 +199,10 @@ Task PutAdjustQueryCacheGlobalPropertiesAsync( /// Gets the current query tracking configuration. /// GET /_api/query/properties /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetQueryTrackingConfigurationAsync( + Task GetQueryTrackingConfigurationAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -196,6 +210,7 @@ Task GetQueryTrackingConfigurationAsync( /// PUT /_api/query/properties /// /// The body of the request containing required configuration properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// After the configuration properties have been changed, @@ -203,7 +218,7 @@ Task GetQueryTrackingConfigurationAsync( /// /// Task PutChangeQueryTrackingConfigurationAsync( - PutChangeQueryTrackingConfigurationBody body, + PutChangeQueryTrackingConfigurationBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -211,26 +226,28 @@ Task PutChangeQueryTrackingConfigurationAsync( /// GET /_api/query/current /// /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns the global AQL query results cache configuration. /// /// Task> GetCurrentlyRunningAqlQueriesAsync( - GetCurrentlyRunningAqlQueriesQuery query = null, + GetCurrentlyRunningAqlQueriesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Gets the available optimizer rules for AQL queries /// GET /_api/query/rules /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns an array of objects that contain the name of each available /// rule and its respective flags. /// /// - Task> GetQueryRulesAsync( + Task> GetQueryRulesAsync(ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs b/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs index b4d9223a..85371672 100644 --- a/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs +++ b/arangodb-net-standard/BulkOperationsApi/BulkOperationsApiClient.cs @@ -55,11 +55,13 @@ public BulkOperationsApiClient(IApiClientTransport transport, IApiClientSerializ /// /// Options for the import. /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostImportDocumentArraysAsync( ImportDocumentsQuery query, ImportDocumentArraysBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (body == null) @@ -90,7 +92,7 @@ public virtual async Task PostImportDocumentArraysAsync { sb.AppendLine(await GetContentStringAsync(valueArr, options).ConfigureAwait(false)); } - return await PostImportDocumentArraysAsync(query, sb.ToString(),token) + return await PostImportDocumentArraysAsync(query, sb.ToString(),headers,token) .ConfigureAwait(false); } @@ -100,11 +102,12 @@ public virtual async Task PostImportDocumentArraysAsync /// /// Options for the import. /// The body of the request containing required value arrays. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostImportDocumentArraysAsync( ImportDocumentsQuery query, - string jsonBody, + string jsonBody, ApiHeaderProperties headers = null, CancellationToken token = default) { if (query == null) @@ -125,7 +128,7 @@ public virtual async Task PostImportDocumentArraysAsync string uriString = _bulkOperationsApiPath; uriString += "?" + query.ToQueryString(); var content = Encoding.UTF8.GetBytes(jsonBody); - using (var response = await _transport.PostAsync(uriString, content,null,token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uriString, content,webHeaderCollection: headers?.ToWebHeaderCollection(),token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -142,11 +145,12 @@ public virtual async Task PostImportDocumentArraysAsync /// /// Options for the import. /// The body of the request containing required objects. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostImportDocumentObjectsAsync( ImportDocumentsQuery query, - ImportDocumentObjectsBody body, + ImportDocumentObjectsBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { if (query == null) @@ -185,7 +189,7 @@ public virtual async Task PostImportDocumentObjectsAsyn //body should be one array of JSON objects sb.Append(await GetContentStringAsync(body.Documents, options).ConfigureAwait(false)); } - return await PostImportDocumentObjectsAsync(query, sb.ToString(),token) + return await PostImportDocumentObjectsAsync(query, sb.ToString(),headers, token) .ConfigureAwait(false); } @@ -197,11 +201,12 @@ public virtual async Task PostImportDocumentObjectsAsyn /// /// Options for the import. /// The body of the request containing the required JSON objects. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostImportDocumentObjectsAsync( ImportDocumentsQuery query, - string jsonBody, + string jsonBody, ApiHeaderProperties headers = null, CancellationToken token = default) { if (query == null) @@ -227,7 +232,7 @@ public virtual async Task PostImportDocumentObjectsAsyn string uriString = _bulkOperationsApiPath; uriString += "?" + query.ToQueryString(); var content = Encoding.UTF8.GetBytes(jsonBody); - using (var response = await _transport.PostAsync(uriString, content,null,token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uriString, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) diff --git a/arangodb-net-standard/BulkOperationsApi/IBulkOperationsApiClient.cs b/arangodb-net-standard/BulkOperationsApi/IBulkOperationsApiClient.cs index 99e7a3b6..82b3d60a 100644 --- a/arangodb-net-standard/BulkOperationsApi/IBulkOperationsApiClient.cs +++ b/arangodb-net-standard/BulkOperationsApi/IBulkOperationsApiClient.cs @@ -16,11 +16,13 @@ public interface IBulkOperationsApiClient /// /// Options for the import. /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostImportDocumentArraysAsync( ImportDocumentsQuery query, ImportDocumentArraysBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -31,11 +33,13 @@ Task PostImportDocumentArraysAsync( /// /// Options for the import. /// The body of the request containing required value arrays. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostImportDocumentArraysAsync( ImportDocumentsQuery query, - string jsonBody, + string jsonBody, + ApiHeaderProperties headers = null, CancellationToken token = default); @@ -45,11 +49,13 @@ Task PostImportDocumentArraysAsync( /// /// Options for the import. /// The body of the request containing required objects. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostImportDocumentObjectsAsync( ImportDocumentsQuery query, - ImportDocumentObjectsBody body, + ImportDocumentObjectsBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -60,11 +66,13 @@ Task PostImportDocumentObjectsAsync( /// /// Options for the import. /// The body of the request containing the required JSON objects. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostImportDocumentObjectsAsync( ImportDocumentsQuery query, string jsonBody, + ApiHeaderProperties headers = null, CancellationToken token = default); } } diff --git a/arangodb-net-standard/CollectionApi/CollectionApiClient.cs b/arangodb-net-standard/CollectionApi/CollectionApiClient.cs index e4b4a6cf..dd8acd26 100644 --- a/arangodb-net-standard/CollectionApi/CollectionApiClient.cs +++ b/arangodb-net-standard/CollectionApi/CollectionApiClient.cs @@ -53,11 +53,13 @@ public CollectionApiClient(IApiClientTransport transport, IApiClientSerializatio /// /// Attributes of the new collection /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostCollectionAsync( PostCollectionBody body, PostCollectionQuery options = null, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uriString = _collectionApiPath; @@ -66,7 +68,7 @@ public virtual async Task PostCollectionAsync( uriString += "?" + options.ToQueryString(); } var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PostAsync(uriString, content, null, token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uriString, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -81,14 +83,16 @@ public virtual async Task PostCollectionAsync( /// Deletes a collection. /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteCollectionAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _transport.DeleteAsync( - _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName), - null, + _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName), + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -158,9 +162,11 @@ public virtual async Task GetCollectionCountAsync(st /// GET/_api/collection /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionsAsync(GetCollectionsQuery query = null, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uriString = _collectionApiPath; @@ -168,7 +174,7 @@ public virtual async Task GetCollectionsAsync(GetCollect { uriString += "?" + query.ToQueryString(); } - using (var response = await _transport.GetAsync(uriString, null, token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uriString, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -184,14 +190,16 @@ public virtual async Task GetCollectionsAsync(GetCollect /// GET/_api/collection/{collection-name} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public async Task GetCollectionAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _transport.GetAsync( - _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName), - null, + _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName), + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -209,14 +217,16 @@ public async Task GetCollectionAsync(string collectionNam /// GET /_api/collection/{collection-name}/properties /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionPropertiesAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _transport.GetAsync( _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/properties", - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -234,16 +244,18 @@ public virtual async Task GetCollectionProperti /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task RenameCollectionAsync(string collectionName, RenameCollectionBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, false)).ConfigureAwait(false); using (var response = await _transport.PutAsync( _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/rename", content, - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -261,14 +273,16 @@ public virtual async Task RenameCollectionAsync(string /// GET /_api/collection/{collection-name}/revision /// /// Name of the collection + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionRevisionAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _transport.GetAsync( _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/revision", - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -286,18 +300,20 @@ public virtual async Task GetCollectionRevisionAs /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutCollectionPropertyAsync( string collectionName, PutCollectionPropertyBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); using (var response = await _transport.PutAsync( _collectionApiPath + "/" + collectionName + "/properties", content, - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -314,14 +330,16 @@ public virtual async Task PutCollectionPropertyAs /// GET/_api/collection/{collection-name}/figures /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionFiguresAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _transport.GetAsync( _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/figures", - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -340,11 +358,13 @@ public virtual async Task GetCollectionFiguresAsyn /// /// Name of the collection. /// Query options. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetChecksumAsync( string collectionName, GetChecksumQuery query = null, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -356,7 +376,7 @@ public virtual async Task GetChecksumAsync( { uriString += "?" + query.ToQueryString(); } - using (var response = await _transport.GetAsync(uriString, null, token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uriString, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -376,9 +396,11 @@ public virtual async Task GetChecksumAsync( /// PUT /_api/collection/{collection-name}/loadIndexesIntoMemory /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutLoadIndexesIntoMemoryAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -386,7 +408,7 @@ public virtual async Task PutLoadIndexesIntoMe throw new ArgumentException($"{nameof(collectionName)} is required", nameof(collectionName)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/loadIndexesIntoMemory"; - using (var response = await _transport.PutAsync(uriString, new byte[] { }, null, token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uriString, new byte[] { }, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -402,9 +424,11 @@ public virtual async Task PutLoadIndexesIntoMe /// PUT /_api/collection/{collection-name}/recalculateCount /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutRecalculateCountAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -412,7 +436,7 @@ public virtual async Task PutRecalculateCountAsync( throw new ArgumentException($"{nameof(collectionName)} is required", nameof(collectionName)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/recalculateCount"; - using (var response = await _transport.PutAsync(uriString, new byte[] { },null,token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uriString, new byte[] { }, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -433,11 +457,13 @@ public virtual async Task PutRecalculateCountAsync( /// pairs with at least the collection’s shard /// key attributes set to some values. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutDocumentShardAsync( string collectionName, Dictionary body, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -450,7 +476,7 @@ public virtual async Task PutDocumentShardAsync( } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/responsibleShard"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PutAsync(uriString, content, null, token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uriString, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -467,9 +493,11 @@ public virtual async Task PutDocumentShardAsync( /// GET /_api/collection/{collection-name}/shards /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionShardsAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -477,7 +505,7 @@ public virtual async Task GetCollectionShardsAsync( throw new ArgumentException($"{nameof(collectionName)} is required", nameof(collectionName)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/shards"; - using (var response = await _transport.GetAsync(uriString, null, token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uriString, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -497,9 +525,11 @@ public virtual async Task GetCollectionShardsAsync( /// GET /_api/collection/{collection-name}/shards?details=true /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionShardsWithDetailsAsync(string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -507,7 +537,7 @@ public virtual async Task GetCollectionShar throw new ArgumentException($"{nameof(collectionName)} is required", nameof(collectionName)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/shards?details=true"; - using (var response = await _transport.GetAsync(uriString, null, token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uriString, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -525,9 +555,10 @@ public virtual async Task GetCollectionShar /// PUT /_api/collection/{collection-name}/compact /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PutCompactCollectionDataAsync(string collectionName, + public virtual async Task PutCompactCollectionDataAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default) { if (string.IsNullOrWhiteSpace(collectionName)) @@ -535,7 +566,7 @@ public virtual async Task PutCompactCollection throw new ArgumentException($"{nameof(collectionName)} is required", nameof(collectionName)); } string uriString = _collectionApiPath + "/" + WebUtility.UrlEncode(collectionName) + "/compact"; - using (var response = await _transport.PutAsync(uriString, new byte[] { },null,token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uriString, new byte[] { }, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/CollectionApi/ICollectionApiClient.cs b/arangodb-net-standard/CollectionApi/ICollectionApiClient.cs index 14b010cc..542a696a 100644 --- a/arangodb-net-standard/CollectionApi/ICollectionApiClient.cs +++ b/arangodb-net-standard/CollectionApi/ICollectionApiClient.cs @@ -16,20 +16,22 @@ public interface ICollectionApiClient /// /// Attributes of the new collection /// Query string options for the task. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostCollectionAsync( PostCollectionBody body, - PostCollectionQuery options = null, + PostCollectionQuery options = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Deletes a collection. /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task DeleteCollectionAsync(string collectionName, + Task DeleteCollectionAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -61,9 +63,10 @@ Task GetCollectionCountAsync(string collectionName, /// GET/_api/collection /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCollectionsAsync(GetCollectionsQuery query = null, + Task GetCollectionsAsync(GetCollectionsQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -71,9 +74,10 @@ Task GetCollectionsAsync(GetCollectionsQuery query = nul /// GET/_api/collection/{collection-name} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCollectionAsync(string collectionName, + Task GetCollectionAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -81,9 +85,10 @@ Task GetCollectionAsync(string collectionName, /// GET /_api/collection/{collection-name}/properties /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCollectionPropertiesAsync(string collectionName, + Task GetCollectionPropertiesAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -92,11 +97,12 @@ Task GetCollectionPropertiesAsync(string collec /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task RenameCollectionAsync( string collectionName, - RenameCollectionBody body, + RenameCollectionBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -104,9 +110,10 @@ Task RenameCollectionAsync( /// GET /_api/collection/{collection-name}/revision /// /// Name of the collection + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCollectionRevisionAsync(string collectionName, + Task GetCollectionRevisionAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -115,11 +122,12 @@ Task GetCollectionRevisionAsync(string collection /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutCollectionPropertyAsync( string collectionName, - PutCollectionPropertyBody body, + PutCollectionPropertyBody body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -127,9 +135,10 @@ Task PutCollectionPropertyAsync( /// GET/_api/collection/{collection-name}/figures /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCollectionFiguresAsync(string collectionName, + Task GetCollectionFiguresAsync(string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -138,10 +147,11 @@ Task GetCollectionFiguresAsync(string collectionNa /// /// Name of the collection. /// Query options. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetChecksumAsync(string collectionName, - GetChecksumQuery query = null, + GetChecksumQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -153,10 +163,11 @@ Task GetChecksumAsync(string collectionName, /// PUT /_api/collection/{collection-name}/loadIndexesIntoMemory /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutLoadIndexesIntoMemoryAsync( - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -164,10 +175,11 @@ Task PutLoadIndexesIntoMemoryAsync( /// PUT /_api/collection/{collection-name}/recalculateCount /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutRecalculateCountAsync( - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -180,11 +192,12 @@ Task PutRecalculateCountAsync( /// pairs with at least the collection’s shard /// key attributes set to some values. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutDocumentShardAsync( string collectionName, - Dictionary body, + Dictionary body, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -193,10 +206,11 @@ Task PutDocumentShardAsync( /// GET /_api/collection/{collection-name}/shards /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetCollectionShardsAsync( - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -208,10 +222,11 @@ Task GetCollectionShardsAsync( /// GET /_api/collection/{collection-name}/shards?details=true /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetCollectionShardsWithDetailsAsync( - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -221,10 +236,11 @@ Task GetCollectionShardsWithDetailsAsync( /// PUT /_api/collection/{collection-name}/compact /// /// Name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutCompactCollectionDataAsync( - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/CursorApi/CursorApiClient.cs b/arangodb-net-standard/CursorApi/CursorApiClient.cs index 60191545..658e6d06 100644 --- a/arangodb-net-standard/CursorApi/CursorApiClient.cs +++ b/arangodb-net-standard/CursorApi/CursorApiClient.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Net; using System.Threading; using System.Threading.Tasks; @@ -69,7 +70,7 @@ protected virtual WebHeaderCollection GetHeaderCollection(CursorHeaderProperties /// /// /// - /// Optional. The stream transaction Id. + /// Optional. The stream transaction Id. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task> PostCursorAsync( @@ -143,14 +144,15 @@ public virtual async Task> PostCursorAsync( /// DELETE /_api/cursor/{cursor-identifier} /// /// The id of the cursor to delete. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task DeleteCursorAsync(string cursorId, + public virtual async Task DeleteCursorAsync(string cursorId, ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _client.DeleteAsync( _cursorApiPath + "/" + WebUtility.UrlEncode(cursorId), - null, + webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -168,14 +170,15 @@ public virtual async Task DeleteCursorAsync(string cursorI /// /// Result type to deserialize to /// ID of the existing query cursor. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// [Obsolete("Use PostAdvanceCursorAsync.")] - public virtual async Task> PutCursorAsync(string cursorId, + public virtual async Task> PutCursorAsync(string cursorId, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _cursorApiPath + "/" + WebUtility.UrlEncode(cursorId); - using (var response = await _client.PutAsync(uri, new byte[0], null, token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(uri, new byte[0], webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -189,16 +192,18 @@ public virtual async Task> PutCursorAsync(string cursorI /// /// Advances an existing query cursor and gets the next set of results. - /// Replaces + /// Replaces /// /// The name / identifier of the existing cursor. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task> PostAdvanceCursorAsync(string cursorIdentifier, CancellationToken token = default) + public virtual async Task> PostAdvanceCursorAsync(string cursorIdentifier, ApiHeaderProperties headers = null, CancellationToken token = default) { using (var response = await _client.PostAsync( requestUri: _cursorApiPath + $"/{WebUtility.UrlEncode(cursorIdentifier)}", content: new byte[] { }, + webHeaderCollection:headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) diff --git a/arangodb-net-standard/CursorApi/ICursorApiClient.cs b/arangodb-net-standard/CursorApi/ICursorApiClient.cs index 135479f0..9fc6aff4 100644 --- a/arangodb-net-standard/CursorApi/ICursorApiClient.cs +++ b/arangodb-net-standard/CursorApi/ICursorApiClient.cs @@ -22,7 +22,7 @@ public interface ICursorApiClient /// /// /// - /// Optional. The stream transaction Id. + /// Optional. The stream transaction Id. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task> PostCursorAsync( @@ -55,13 +55,14 @@ Task> PostCursorAsync( /// /// Advances an existing query cursor and gets the next set of results. - /// Replaces + /// Replaces /// /// The name / identifier of the existing cursor. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task> PostAdvanceCursorAsync( - string cursorIdentifier, + string cursorIdentifier, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -69,9 +70,10 @@ Task> PostAdvanceCursorAsync( /// DELETE /_api/cursor/{cursor-identifier} /// /// The id of the cursor to delete. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task DeleteCursorAsync(string cursorId, + Task DeleteCursorAsync(string cursorId, ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -79,9 +81,10 @@ Task DeleteCursorAsync(string cursorId, /// /// Result type to deserialize to /// ID of the existing query cursor. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task> PutCursorAsync(string cursorId, + Task> PutCursorAsync(string cursorId, ApiHeaderProperties headers = null, CancellationToken token = default); } } diff --git a/arangodb-net-standard/CustomHttpHeaders.cs b/arangodb-net-standard/CustomHttpHeaders.cs index ada9b7f1..e138398c 100644 --- a/arangodb-net-standard/CustomHttpHeaders.cs +++ b/arangodb-net-standard/CustomHttpHeaders.cs @@ -18,5 +18,9 @@ public static class CustomHttpHeaders /// The header string used for Driver Info Header /// public const string DriverInfoHeader = "x-arango-driver"; + /// + /// The header string used for + /// + public const string MaxQueueTimeLimitHeader = "x-arango-max-queue-time-seconds"; } } diff --git a/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs b/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs index c749c665..97acea11 100644 --- a/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs +++ b/arangodb-net-standard/DatabaseApi/DatabaseApiClient.cs @@ -51,12 +51,13 @@ public DatabaseApiClient(IApiClientTransport client, IApiClientSerialization ser /// (Only possible from within the _system database) /// /// The parameters required by this endpoint. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostDatabaseAsync(PostDatabaseBody request, CancellationToken token = default) + public virtual async Task PostDatabaseAsync(PostDatabaseBody request, ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(request, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(_databaseApiPath, content, null, token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(_databaseApiPath, content, webHeaderCollection: headers?.ToWebHeaderCollection(), token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -73,11 +74,15 @@ public virtual async Task PostDatabaseAsync(PostDatabaseBo /// DELETE /_api/database/{database-name} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task DeleteDatabaseAsync(string databaseName, CancellationToken token = default) + public virtual async Task DeleteDatabaseAsync(string databaseName, ApiHeaderProperties headers = null, CancellationToken token = default) { - using (var response = await _client.DeleteAsync(_databaseApiPath + "/" + WebUtility.UrlEncode(databaseName), null, token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync( + _databaseApiPath + "/" + WebUtility.UrlEncode(databaseName), + webHeaderCollection: headers?.ToWebHeaderCollection(), + token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -92,15 +97,19 @@ public virtual async Task DeleteDatabaseAsync(string dat /// Retrieves the list of all existing databases. /// (Only possible from within the _system database) /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// You should use to fetch the list of the databases /// available for the current user. /// /// - public virtual async Task GetDatabasesAsync(CancellationToken token = default) + public virtual async Task GetDatabasesAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { - using (var response = await _client.GetAsync(_databaseApiPath, null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync( + _databaseApiPath, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -114,11 +123,15 @@ public virtual async Task GetDatabasesAsync(CancellationTo /// /// Retrieves the list of all databases the current user can access. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetUserDatabasesAsync(CancellationToken token = default) + public virtual async Task GetUserDatabasesAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { - using (var response = await _client.GetAsync(_databaseApiPath + "/user", null, token).ConfigureAwait(false)) + using (var response = await _client.GetAsync( + _databaseApiPath + "/user", + webHeaderCollection: headers?.ToWebHeaderCollection(), + token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -132,11 +145,15 @@ public virtual async Task GetUserDatabasesAsync(Cancellati /// /// Retrieves information about the current database. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetCurrentDatabaseInfoAsync(CancellationToken token = default) + public virtual async Task GetCurrentDatabaseInfoAsync(ApiHeaderProperties headers = null, CancellationToken token = default) { - using (var response = await _client.GetAsync(_databaseApiPath + "/current",null,token).ConfigureAwait(false)) + using (var response = await _client.GetAsync( + _databaseApiPath + "/current", + webHeaderCollection: headers?.ToWebHeaderCollection(), + token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/DatabaseApi/IDatabaseApiClient.cs b/arangodb-net-standard/DatabaseApi/IDatabaseApiClient.cs index dadf666e..ef536df3 100644 --- a/arangodb-net-standard/DatabaseApi/IDatabaseApiClient.cs +++ b/arangodb-net-standard/DatabaseApi/IDatabaseApiClient.cs @@ -14,9 +14,10 @@ public interface IDatabaseApiClient /// (Only possible from within the _system database) /// /// The parameters required by this endpoint. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostDatabaseAsync(PostDatabaseBody request, CancellationToken token = default); + Task PostDatabaseAsync(PostDatabaseBody request, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Delete a database. Dropping a database is only possible from within the _system database. @@ -24,34 +25,38 @@ public interface IDatabaseApiClient /// DELETE /_api/database/{database-name} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task DeleteDatabaseAsync(string databaseName, CancellationToken token = default); + Task DeleteDatabaseAsync(string databaseName, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the list of all existing databases. /// (Only possible from within the _system database) /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// You should use to fetch the list of the databases /// available for the current user. /// /// - Task GetDatabasesAsync(CancellationToken token = default); + Task GetDatabasesAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves the list of all databases the current user can access. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetUserDatabasesAsync(CancellationToken token = default); + Task GetUserDatabasesAsync(ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Retrieves information about the current database. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetCurrentDatabaseInfoAsync(CancellationToken token = default); + Task GetCurrentDatabaseInfoAsync(ApiHeaderProperties headers = null, CancellationToken token = default); } } diff --git a/arangodb-net-standard/DocumentApi/Models/DocumentHeaderProperties.cs b/arangodb-net-standard/DocumentApi/Models/DocumentHeaderProperties.cs index e295608c..04c25ba2 100644 --- a/arangodb-net-standard/DocumentApi/Models/DocumentHeaderProperties.cs +++ b/arangodb-net-standard/DocumentApi/Models/DocumentHeaderProperties.cs @@ -2,7 +2,7 @@ namespace ArangoDBNetStandard.DocumentApi.Models { - public class DocumentHeaderProperties:ApiHeaderProperties + public class DocumentHeaderProperties: ApiHeaderProperties { public string IfMatch { get; set; } diff --git a/arangodb-net-standard/GraphApi/GraphApiClient.cs b/arangodb-net-standard/GraphApi/GraphApiClient.cs index cc5d9e96..3b20ff5d 100644 --- a/arangodb-net-standard/GraphApi/GraphApiClient.cs +++ b/arangodb-net-standard/GraphApi/GraphApiClient.cs @@ -57,11 +57,14 @@ public GraphApiClient(IApiClientTransport transport, IApiClientSerialization ser /// /// The information of the graph to create. Must be an instance of or . /// Optional query parameters of the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostGraphAsync( PostGraphBody postGraphBody, - PostGraphQuery query = null, CancellationToken token = default) + PostGraphQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uri = _graphApiPath; @@ -72,7 +75,9 @@ public virtual async Task PostGraphAsync( var content = await GetContentAsync(postGraphBody, new ApiClientSerializationOptions(true, true)); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -87,15 +92,20 @@ public virtual async Task PostGraphAsync( /// Lists all graphs stored in this database. /// GET /_api/gharial /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Note: The property is null for /// in ArangoDB 4.5.2 and below, in which case you can use instead. /// /// - public virtual async Task GetGraphsAsync( CancellationToken token = default) + public virtual async Task GetGraphsAsync( + GraphHeaderProperties headers = null, + CancellationToken token = default) { - using (var response = await _transport.GetAsync(_graphApiPath, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(_graphApiPath, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -114,18 +124,23 @@ public virtual async Task GetGraphsAsync( CancellationToken t /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteGraphAsync( string graphName, - DeleteGraphQuery query = null, CancellationToken token = default) + DeleteGraphQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uriString = _graphApiPath + "/" + WebUtility.UrlEncode(graphName); if (query != null) { uriString += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uriString, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uriString, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -142,11 +157,17 @@ public virtual async Task DeleteGraphAsync( /// GET /_api/gharial/{graph} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetGraphAsync(string graphName, CancellationToken token = default) + public virtual async Task GetGraphAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default) { - using (var response = await _transport.GetAsync(_graphApiPath + "/" + WebUtility.UrlEncode(graphName), token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync( + _graphApiPath + "/" + WebUtility.UrlEncode(graphName), + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -162,11 +183,17 @@ public virtual async Task GetGraphAsync(string graphName, Canc /// GET /_api/gharial/{graph}/vertex /// /// The name of the graph. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetVertexCollectionsAsync(string graphName, CancellationToken token = default) + public virtual async Task GetVertexCollectionsAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default) { - using (var response = await _transport.GetAsync(_graphApiPath + '/' + WebUtility.UrlEncode(graphName) + "/vertex", token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync( + _graphApiPath + '/' + WebUtility.UrlEncode(graphName) + "/vertex", + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -182,11 +209,17 @@ public virtual async Task GetVertexCollectionsAsyn /// GET /_api/gharial/{graph}/edge /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetEdgeCollectionsAsync(string graphName, CancellationToken token = default) + public virtual async Task GetEdgeCollectionsAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default) { - using (var response = await _transport.GetAsync(_graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge", token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync( + _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge", + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -209,17 +242,22 @@ public virtual async Task GetEdgeCollectionsAsync(st /// /// The name of the graph. /// The information of the edge definition. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostEdgeDefinitionAsync( string graphName, - PostEdgeDefinitionBody body, CancellationToken token = default) + PostEdgeDefinitionBody body, + GraphHeaderProperties headers = null, + CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge"; - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -237,17 +275,22 @@ public virtual async Task PostEdgeDefinitionAsync( /// /// The name of the graph. /// The information of the vertex collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostVertexCollectionAsync( string graphName, - PostVertexCollectionBody body, CancellationToken token = default) + PostVertexCollectionBody body, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uri = _graphApiPath + '/' + WebUtility.UrlEncode(graphName) + "/vertex"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -288,7 +331,9 @@ public virtual async Task> PostVertexAsync( uri += "?" + query.ToQueryString(); } var content = await GetContentAsync(vertex, serializationOptions).ConfigureAwait(false); - using (var response = await _transport.PostAsync(uri, content,headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, + headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -308,12 +353,15 @@ public virtual async Task> PostVertexAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteEdgeDefinitionAsync( string graphName, string collectionName, - DeleteEdgeDefinitionQuery query = null, CancellationToken token = default) + DeleteEdgeDefinitionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge/" + WebUtility.UrlEncode(collectionName); @@ -321,7 +369,9 @@ public virtual async Task DeleteEdgeDefinitionAsyn { uri += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -342,12 +392,15 @@ public virtual async Task DeleteEdgeDefinitionAsyn /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteVertexCollectionAsync( string graphName, string collectionName, - DeleteVertexCollectionQuery query = null, CancellationToken token = default) + DeleteVertexCollectionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/vertex/" + WebUtility.UrlEncode(collectionName); @@ -355,7 +408,9 @@ public virtual async Task DeleteVertexCollection { uri += "?" + query.ToQueryString(); } - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -568,7 +623,9 @@ public virtual Task> GetVertexAsync( return GetVertexAsync( graphName, WebUtility.UrlEncode(collectionName) + "/" + vertexKey, - query, token: token); + query, + headers, + token: token); } /// @@ -849,13 +906,16 @@ public virtual async Task> PutEdgeAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutEdgeDefinitionAsync( string graphName, string collectionName, PutEdgeDefinitionBody body, - PutEdgeDefinitionQuery query = null, CancellationToken token = default) + PutEdgeDefinitionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default) { string uriString = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) + "/edge/" + @@ -866,7 +926,9 @@ public virtual async Task PutEdgeDefinitionAsync( uriString += "?" + query.ToQueryString(); } var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PutAsync(uriString, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uriString, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -1036,6 +1098,5 @@ public virtual async Task> PutVertexAsync( throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } } - } } diff --git a/arangodb-net-standard/GraphApi/IGraphApiClient.cs b/arangodb-net-standard/GraphApi/IGraphApiClient.cs index e4c14da3..5b0d5e4a 100644 --- a/arangodb-net-standard/GraphApi/IGraphApiClient.cs +++ b/arangodb-net-standard/GraphApi/IGraphApiClient.cs @@ -16,23 +16,29 @@ public interface IGraphApiClient /// /// The information of the graph to create. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostGraphAsync( PostGraphBody postGraphBody, - PostGraphQuery query = null, CancellationToken token = default); + PostGraphQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Lists all graphs stored in this database. /// GET /_api/gharial /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Note: The property is null for /// in ArangoDB 4.5.2 and below, in which case you can use instead. /// /// - Task GetGraphsAsync(CancellationToken token = default); + Task GetGraphsAsync( + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Deletes an existing graph object by name. @@ -42,11 +48,14 @@ Task PostGraphAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteGraphAsync( string graphName, - DeleteGraphQuery query = null, CancellationToken token = default); + DeleteGraphQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Selects information for a given graph. @@ -54,27 +63,36 @@ Task DeleteGraphAsync( /// GET /_api/gharial/{graph} /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetGraphAsync(string graphName, CancellationToken token = default); + Task GetGraphAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Lists all vertex collections within the given graph. /// GET /_api/gharial/{graph}/vertex /// /// The name of the graph. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetVertexCollectionsAsync(string graphName, CancellationToken token = default); + Task GetVertexCollectionsAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Lists all edge collections within this graph. /// GET /_api/gharial/{graph}/edge /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetEdgeCollectionsAsync(string graphName, CancellationToken token = default); + Task GetEdgeCollectionsAsync(string graphName, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Adds an additional edge definition to the graph. @@ -88,11 +106,14 @@ Task DeleteGraphAsync( /// /// The name of the graph. /// The information of the edge definition. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostEdgeDefinitionAsync( string graphName, - PostEdgeDefinitionBody body, CancellationToken token = default); + PostEdgeDefinitionBody body, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Adds a vertex collection to the set of orphan collections of the graph. @@ -101,11 +122,14 @@ Task PostEdgeDefinitionAsync( /// /// The name of the graph. /// The information of the vertex collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostVertexCollectionAsync( string graphName, - PostVertexCollectionBody body, CancellationToken token = default); + PostVertexCollectionBody body, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Adds a vertex to the given collection. @@ -138,12 +162,15 @@ Task> PostVertexAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteEdgeDefinitionAsync( string graphName, string collectionName, - DeleteEdgeDefinitionQuery query = null, CancellationToken token = default); + DeleteEdgeDefinitionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Removes a vertex collection from the graph and optionally deletes the collection, @@ -155,12 +182,15 @@ Task DeleteEdgeDefinitionAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteVertexCollectionAsync( string graphName, string collectionName, - DeleteVertexCollectionQuery query = null, CancellationToken token = default); + DeleteVertexCollectionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Creates an edge in an existing graph. @@ -430,13 +460,16 @@ Task> PutEdgeAsync( /// /// /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutEdgeDefinitionAsync( string graphName, string collectionName, PutEdgeDefinitionBody body, - PutEdgeDefinitionQuery query = null, CancellationToken token = default); + PutEdgeDefinitionQuery query = null, + GraphHeaderProperties headers = null, + CancellationToken token = default); /// /// Updates the data of the specific edge in the collection. @@ -530,6 +563,7 @@ Task> PutVertexAsync( T vertex, PutVertexQuery query = null, ApiClientSerializationOptions serializationOptions = null, - GraphHeaderProperties headers = null, CancellationToken token = default); + GraphHeaderProperties headers = null, + CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/IndexApi/IIndexApiClient.cs b/arangodb-net-standard/IndexApi/IIndexApiClient.cs index bb13f6af..bc54dede 100644 --- a/arangodb-net-standard/IndexApi/IIndexApiClient.cs +++ b/arangodb-net-standard/IndexApi/IIndexApiClient.cs @@ -15,42 +15,50 @@ internal interface IIndexApiClient /// Fetches data about the specified index. /// /// The index identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetIndexAsync(string indexId, + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Delete an index permanently. /// /// The index identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteIndexAsync(string indexId, + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Fetch the list of indexes for a collection. /// /// Query parameters for the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetAllCollectionIndexesAsync(GetAllCollectionIndexesQuery query, + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Generic method to create an index. /// It is highly recommended that you use a specialized method like - /// + /// /// to create indexes. Use this method to create indexes that do not /// have a specialized method available. /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostIndexAsync(PostIndexQuery query, PostIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -74,10 +82,12 @@ Task PostFulltextIndexAsync(PostIndexQuery query, /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostGeoSpatialIndexAsync(PostIndexQuery query, PostGeoSpatialIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -101,10 +111,12 @@ Task PostHashIndexAsync(PostIndexQuery query, /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostMultiDimensionalIndexAsync(PostIndexQuery query, PostMultiDimensionalIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -112,10 +124,12 @@ Task PostMultiDimensionalIndexAsync(PostIndexQuery query, /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostPersistentIndexAsync(PostIndexQuery query, PostPersistentIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -139,10 +153,12 @@ Task PostSkiplistIndexAsync(PostIndexQuery query, /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostTTLIndexAsync(PostIndexQuery query, PostTTLIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -150,10 +166,12 @@ Task PostTTLIndexAsync(PostIndexQuery query, /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostInvertedIndexAsync(PostIndexQuery query, PostInvertedIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/IndexApi/IndexApiClient.cs b/arangodb-net-standard/IndexApi/IndexApiClient.cs index 394c1b20..0e84bc1a 100644 --- a/arangodb-net-standard/IndexApi/IndexApiClient.cs +++ b/arangodb-net-standard/IndexApi/IndexApiClient.cs @@ -52,13 +52,17 @@ public IndexApiClient(IApiClientTransport client, IApiClientSerialization serial /// Fetches data about the specified index. /// /// The identifier of the index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetIndexAsync(string indexId, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _indexApiPath + '/' + indexId; - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -73,13 +77,17 @@ public virtual async Task GetIndexAsync(string indexId, /// Delete an index permanently. /// /// The identifier of the index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteIndexAsync(string indexId, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _indexApiPath + "/" + indexId; - using (var response = await _client.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -95,10 +103,12 @@ public virtual async Task DeleteIndexAsync(string indexId, /// Fetch the list of indexes for a collection. /// /// Query parameters for the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Required parameters not provided or invalid. public virtual async Task GetAllCollectionIndexesAsync(GetAllCollectionIndexesQuery query, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _indexApiPath; @@ -114,7 +124,9 @@ public virtual async Task GetAllCollectionIndex } uri += '?' + query.ToQueryString(); - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -128,16 +140,18 @@ public virtual async Task GetAllCollectionIndex /// /// Generic method to create an index. /// It is highly recommended that you use a specialized method like - /// + /// /// to create indexes. Use this method to create indexes that do not /// have a specialized method available. /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostIndexAsync(PostIndexQuery query, PostIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _indexApiPath; @@ -159,7 +173,9 @@ public virtual async Task PostIndexAsync(PostIndexQuery query uri += '?' + query.ToQueryString(); var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(uri, content,token:token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token:token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -186,7 +202,7 @@ public virtual async Task PostFulltextIndexAsync(PostIndexQue PostFulltextIndexBody body, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query: query, body: body, token: token).ConfigureAwait(false); } /// @@ -194,13 +210,15 @@ public virtual async Task PostFulltextIndexAsync(PostIndexQue /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostGeoSpatialIndexAsync(PostIndexQuery query, PostGeoSpatialIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query, body, headers, token).ConfigureAwait(false); } /// @@ -219,7 +237,7 @@ public virtual async Task PostHashIndexAsync(PostIndexQuery q PostHashIndexBody body, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query: query, body: body, token: token).ConfigureAwait(false); } /// @@ -227,13 +245,15 @@ public virtual async Task PostHashIndexAsync(PostIndexQuery q /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostMultiDimensionalIndexAsync(PostIndexQuery query, PostMultiDimensionalIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query, body, headers, token).ConfigureAwait(false); } /// @@ -241,13 +261,15 @@ public virtual async Task PostMultiDimensionalIndexAsync(Post /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostPersistentIndexAsync(PostIndexQuery query, PostPersistentIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query, body, headers, token).ConfigureAwait(false); } /// @@ -266,7 +288,7 @@ public virtual async Task PostSkiplistIndexAsync(PostIndexQue PostSkiplistIndexBody body, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query: query, body: body, token: token).ConfigureAwait(false); } /// @@ -274,13 +296,15 @@ public virtual async Task PostSkiplistIndexAsync(PostIndexQue /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostTTLIndexAsync(PostIndexQuery query, PostTTLIndexBody body, + ApiHeaderProperties headers = null, CancellationToken token = default) { - return await PostIndexAsync(query, body, token).ConfigureAwait(false); + return await PostIndexAsync(query, body, headers, token).ConfigureAwait(false); } /// @@ -288,9 +312,13 @@ public virtual async Task PostTTLIndexAsync(PostIndexQuery qu /// /// Query parameters for the request. /// The properties of the new index. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostInvertedIndexAsync(PostIndexQuery query, PostInvertedIndexBody body, CancellationToken token = default) + public virtual async Task PostInvertedIndexAsync(PostIndexQuery query, + PostInvertedIndexBody body, + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = _indexApiPath; @@ -311,7 +339,9 @@ public virtual async Task PostInvertedIndexAsync(PostInde uri += '?' + query.ToQueryString(); var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(uri, content: content, token: token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(uri, content: content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/PregelApi/IPregelApiClient.cs b/arangodb-net-standard/PregelApi/IPregelApiClient.cs index 9639ddc5..ab1c28ad 100644 --- a/arangodb-net-standard/PregelApi/IPregelApiClient.cs +++ b/arangodb-net-standard/PregelApi/IPregelApiClient.cs @@ -26,10 +26,12 @@ public interface IPregelApiClient /// vary for each algorithm /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// The ID of the newly started job. Task PostStartJobAsync( PostStartJobBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -37,22 +39,26 @@ Task PostStartJobAsync( /// GET /_api/control_pregel/{id} /// /// The ID of the job. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetJobStatusAsync( string jobId, + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get the overview of currently running Pregel jobs. /// GET /_api/control_pregel /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns a list of currently running and recently /// finished Pregel jobs without retrieving their results. /// Task> GetAllRunningJobsAsync( + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -67,10 +73,12 @@ Task> GetAllRunningJobsAsync( /// For more information see https://www.arangodb.com/docs/stable/http/pregel.html#cancel-pregel-job-execution /// /// The ID of the job. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteJobAsync( string jobId, + ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/PregelApi/PregelApiClient.cs b/arangodb-net-standard/PregelApi/PregelApiClient.cs index b049f539..9440b879 100644 --- a/arangodb-net-standard/PregelApi/PregelApiClient.cs +++ b/arangodb-net-standard/PregelApi/PregelApiClient.cs @@ -63,13 +63,18 @@ public PregelApiClient(IApiClientTransport transport, IApiClientSerialization se /// vary for each algorithm /// /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// The ID of the newly started job. - public virtual async Task PostStartJobAsync(PostStartJobBody body, CancellationToken token = default) + public virtual async Task PostStartJobAsync(PostStartJobBody body, + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = _apiPath; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, content, + webHeaderCollection:headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -85,16 +90,20 @@ public virtual async Task PostStartJobAsync(PostStartJobBody body, Cance /// GET /_api/control_pregel/{id} /// /// The ID of the job. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetJobStatusAsync(string jobId, CancellationToken token = default) + public virtual async Task GetJobStatusAsync(string jobId, + ApiHeaderProperties headers = null, + CancellationToken token = default) { if (string.IsNullOrWhiteSpace(jobId)) { throw new ArgumentNullException(nameof(jobId)); } string uri = _apiPath + '/' + jobId; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -109,15 +118,20 @@ public virtual async Task GetJobStatusAsync(string jobId, Cance /// Get the overview of currently running Pregel jobs. /// GET /_api/control_pregel /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Returns a list of currently running and recently /// finished Pregel jobs without retrieving their results. /// - public virtual async Task> GetAllRunningJobsAsync(CancellationToken token = default) + public virtual async Task> GetAllRunningJobsAsync( + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = _apiPath; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -140,12 +154,17 @@ public virtual async Task> GetAllRunningJobsAsync(Cancella /// For more information see https://www.arangodb.com/docs/stable/http/pregel.html#cancel-pregel-job-execution /// /// The ID of the job. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task DeleteJobAsync(string jobId, CancellationToken token = default) + public virtual async Task DeleteJobAsync(string jobId, + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = _apiPath + '/' + jobId; - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/TransactionApi/ITransactionApiClient.cs b/arangodb-net-standard/TransactionApi/ITransactionApiClient.cs index 7fc0bd4b..130230fe 100644 --- a/arangodb-net-standard/TransactionApi/ITransactionApiClient.cs +++ b/arangodb-net-standard/TransactionApi/ITransactionApiClient.cs @@ -16,6 +16,7 @@ public interface ITransactionApiClient /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#abort-transaction /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// With ErrorNum 1653 if the transaction cannot be aborted. @@ -23,7 +24,7 @@ public interface ITransactionApiClient /// /// Response from ArangoDB after aborting a transaction. Task AbortTransaction(string transactionId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Begin a stream transaction by POST. @@ -53,6 +54,7 @@ Task BeginTransaction( /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#commit-transaction /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// With ErrorNum 1653 if the transaction cannot be committed. @@ -60,18 +62,19 @@ Task BeginTransaction( /// /// Response from ArangoDB after committing a transaction. Task CommitTransaction(string transactionId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get currently running transactions. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#get-currently-running-transactions /// /// Response from ArangoDB with all running transactions. Task GetAllRunningTransactions( - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get the status of a transaction. @@ -80,20 +83,22 @@ Task GetAllRunningTransactions( /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#get-transaction-status /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// With ErrorNum 10 if the transaction is not found. /// Response from ArangoDB with the status of a transaction. Task GetTransactionStatus(string transactionId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// POST a transaction to ArangoDB. /// /// Type to use for deserializing the object returned by the transaction function. /// Object containing information to submit in the POST transaction request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Response from ArangoDB after processing the request. Task> PostTransactionAsync(PostTransactionBody body, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); } } diff --git a/arangodb-net-standard/TransactionApi/TransactionApiClient.cs b/arangodb-net-standard/TransactionApi/TransactionApiClient.cs index 8f8af105..d95b6f8d 100644 --- a/arangodb-net-standard/TransactionApi/TransactionApiClient.cs +++ b/arangodb-net-standard/TransactionApi/TransactionApiClient.cs @@ -59,14 +59,18 @@ public TransactionApiClient(IApiClientTransport client, IApiClientSerialization /// /// Type to use for deserializing the object returned by the transaction function. /// Object containing information to submit in the POST transaction request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Response from ArangoDB after processing the request. public virtual async Task> PostTransactionAsync( PostTransactionBody body, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(_transactionApiPath, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(_transactionApiPath, + content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -86,6 +90,7 @@ public virtual async Task> PostTransactionAsync( /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#abort-transaction /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// With ErrorNum 1653 if the transaction cannot be aborted. @@ -93,10 +98,12 @@ public virtual async Task> PostTransactionAsync( /// /// Response from ArangoDB after aborting a transaction. public virtual async Task AbortTransaction(string transactionId, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string completeAbortTransactionPath = string.Format(_streamTransactionApiPath, transactionId); - using (var response = await _client.DeleteAsync(completeAbortTransactionPath, token: token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(completeAbortTransactionPath, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -156,6 +163,7 @@ public virtual async Task BeginTransaction( /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#commit-transaction /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// With ErrorNum 1653 if the transaction cannot be committed. @@ -163,10 +171,13 @@ public virtual async Task BeginTransaction( /// /// Response from ArangoDB after committing a transaction. public virtual async Task CommitTransaction(string transactionId, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string completeCommitTransactionPath = string.Format(_streamTransactionApiPath, transactionId); - using (var response = await _client.PutAsync(completeCommitTransactionPath, Array.Empty(), token: token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(completeCommitTransactionPath, + Array.Empty(), + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -182,15 +193,18 @@ public virtual async Task CommitTransaction(string tr /// /// Get currently running transactions. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#get-currently-running-transactions /// /// Response from ArangoDB with all running transactions. public virtual async Task GetAllRunningTransactions( - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { - using (var response = await _client.GetAsync(_transactionApiPath, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(_transactionApiPath, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) @@ -210,14 +224,17 @@ public virtual async Task GetAllRunningTransactions( /// https://www.arangodb.com/docs/stable/http/transaction-stream-transaction.html#get-transaction-status /// /// The transaction identifier. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// With ErrorNum 10 if the transaction is not found. /// Response from ArangoDB with the status of a transaction. public virtual async Task GetTransactionStatus(string transactionId, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string getTransactionPath = string.Format(_streamTransactionApiPath, transactionId); - using (var response = await _client.GetAsync(getTransactionPath,token:token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(getTransactionPath, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); if (response.IsSuccessStatusCode) diff --git a/arangodb-net-standard/UserApi/IUserApiClient.cs b/arangodb-net-standard/UserApi/IUserApiClient.cs index db48c0a1..24af8c17 100644 --- a/arangodb-net-standard/UserApi/IUserApiClient.cs +++ b/arangodb-net-standard/UserApi/IUserApiClient.cs @@ -14,9 +14,11 @@ public interface IUserApiClient /// in order to execute this REST call. /// /// The request body containing the user information. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostUserAsync(PostUserBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -26,9 +28,11 @@ Task PostUserAsync(PostUserBody body, /// /// The name of the user. /// The user information used for to replace operation. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutUserAsync(string username, PutUserBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -38,9 +42,11 @@ Task PutUserAsync(string username, PutUserBody body, /// /// The name of the user. /// The user information used for to replace operation. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PatchUserAsync(string username, PatchUserBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -49,9 +55,11 @@ Task PatchUserAsync(string username, PatchUserBody body, /// server access level in order to execute this REST call. /// /// The name of the user. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetUserAsync(string username, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -59,9 +67,11 @@ Task GetUserAsync(string username, /// You need Administrate for the server access level in order to execute this REST call. /// /// The name of the user. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteUserAsync(string username, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -69,9 +79,11 @@ Task DeleteUserAsync(string username, /// You need the Administrate server access level in order to execute this REST call. /// Otherwise, you will only get information about yourself. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetUsersAsync( + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -81,12 +93,14 @@ Task GetUsersAsync( /// The name of the user. /// The name of the database. /// The body of the request containing the access level. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutDatabaseAccessLevelAsync( string username, string dbName, PutAccessLevelBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -94,11 +108,13 @@ Task PutDatabaseAccessLevelAsync( /// /// The name of the user. /// The name of the database to query. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetDatabaseAccessLevelAsync( string username, string dbName, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -109,11 +125,13 @@ Task GetDatabaseAccessLevelAsync( /// /// The name of the user. /// The name of the database. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteDatabaseAccessLevelAsync( string username, string dbName, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -122,11 +140,13 @@ Task DeleteDatabaseAccessLevelAsync( /// /// The name of the user. /// Optional query parameters for the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetAccessibleDatabasesAsync( string username, GetAccessibleDatabasesQuery query = null, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -137,6 +157,7 @@ Task GetAccessibleDatabasesAsync( /// The name of the database. /// The name of the collection. /// The body of the request containing the access level. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutCollectionAccessLevelAsync( @@ -144,6 +165,7 @@ Task PutCollectionAccessLevelAsync( string dbName, string collectionName, PutAccessLevelBody body, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -152,12 +174,14 @@ Task PutCollectionAccessLevelAsync( /// The name of the user. /// The name of the database. /// The name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetCollectionAccessLevelAsync( string username, string dbName, string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -169,12 +193,14 @@ Task GetCollectionAccessLevelAsync( /// The name of the user. /// The name of the database. /// The name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteCollectionAccessLevelAsync( string username, string dbName, string collectionName, + ApiHeaderProperties headers = null, CancellationToken token = default); } } diff --git a/arangodb-net-standard/UserApi/UserApiClient.cs b/arangodb-net-standard/UserApi/UserApiClient.cs index 35a955e8..feed6499 100644 --- a/arangodb-net-standard/UserApi/UserApiClient.cs +++ b/arangodb-net-standard/UserApi/UserApiClient.cs @@ -53,13 +53,16 @@ public UserApiClient(IApiClientTransport client, IApiClientSerialization seriali /// /// ArangoDB responded with an error. /// The request body containing the user information. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostUserAsync(PostUserBody body, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PostAsync(_userApiPath, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PostAsync(_userApiPath, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -77,14 +80,17 @@ public virtual async Task PostUserAsync(PostUserBody body, /// /// The name of the user. /// The user information used for to replace operation. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutUserAsync(string username, PutUserBody body, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + '/' + username; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -102,14 +108,17 @@ public virtual async Task PutUserAsync(string username, PutUser /// /// The name of the user. /// The user information used for to replace operation. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PatchUserAsync(string username, PatchUserBody body, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + '/' + username; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PatchAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PatchAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -126,13 +135,16 @@ public virtual async Task PatchUserAsync(string username, Pat /// server access level in order to execute this REST call. /// /// The name of the user. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetUserAsync(string username, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + '/' + username; - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -148,13 +160,16 @@ public virtual async Task GetUserAsync(string username, /// You need Administrate for the server access level in order to execute this REST call. /// /// The name of the user. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteUserAsync(string username, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username); - using (var response = await _client.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -170,13 +185,16 @@ public virtual async Task DeleteUserAsync(string username, /// You need the Administrate server access level in order to execute this REST call. /// Otherwise, you will only get information about yourself. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetUsersAsync( - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath; - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -194,18 +212,21 @@ public virtual async Task GetUsersAsync( /// The name of the user. /// The name of the database. /// The body of the request containing the access level. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutDatabaseAccessLevelAsync( string username, string dbName, - PutAccessLevelBody body, + PutAccessLevelBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName); var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -221,16 +242,19 @@ public virtual async Task PutDatabaseAccessLevelAsync( /// /// The name of the user. /// The name of the database to query. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetDatabaseAccessLevelAsync( string username, - string dbName, + string dbName, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName); - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -249,16 +273,19 @@ public virtual async Task GetDatabaseAccessLevelAsync( /// /// The name of the user. /// The name of the database. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteDatabaseAccessLevelAsync( string username, - string dbName, + string dbName, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName); - using (var response = await _client.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -275,11 +302,12 @@ public virtual async Task DeleteDatabaseAccessLevelAs /// /// The name of the user. /// Optional query parameters for the request. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetAccessibleDatabasesAsync( string username, - GetAccessibleDatabasesQuery query = null, + GetAccessibleDatabasesQuery query = null, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database"; @@ -287,7 +315,9 @@ public virtual async Task GetAccessibleDatabases { uri += '?' + query.ToQueryString(); } - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -306,20 +336,23 @@ public virtual async Task GetAccessibleDatabases /// The name of the database. /// The name of the collection. /// The body of the request containing the access level. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutCollectionAccessLevelAsync( string username, string dbName, string collectionName, - PutAccessLevelBody body, + PutAccessLevelBody body, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName) + "/" + WebUtility.UrlEncode(collectionName); var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _client.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _client.PutAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -336,18 +369,21 @@ public virtual async Task PutCollectionAccessLevelAsync( /// The name of the user. /// The name of the database. /// The name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetCollectionAccessLevelAsync( string username, string dbName, - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName) + "/" + WebUtility.UrlEncode(collectionName); - using (var response = await _client.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _client.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -367,18 +403,21 @@ public virtual async Task GetCollectionAccessLevelAsync( /// The name of the user. /// The name of the database. /// The name of the collection. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteCollectionAccessLevelAsync( string username, string dbName, - string collectionName, + string collectionName, ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _userApiPath + "/" + WebUtility.UrlEncode(username) + "/database/" + WebUtility.UrlEncode(dbName) + "/" + WebUtility.UrlEncode(collectionName); - using (var response = await _client.DeleteAsync(uri,token:token).ConfigureAwait(false)) + using (var response = await _client.DeleteAsync(uri, + webHeaderCollection:headers?.ToWebHeaderCollection(), + token:token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { diff --git a/arangodb-net-standard/ViewApi/IViewsApiClient.cs b/arangodb-net-standard/ViewApi/IViewsApiClient.cs index e9fa96ac..c3cd0452 100644 --- a/arangodb-net-standard/ViewApi/IViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/IViewsApiClient.cs @@ -15,9 +15,11 @@ public interface IViewApiClient /// regardless of their type. /// GET /_api/view /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task GetAllViewsAsync( + Task> GetAllViewsAsync( + ApiHeaderProperties headers = null, CancellationToken token = default); /// @@ -30,39 +32,43 @@ Task GetAllViewsAsync( /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default); + Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization = true, ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Delete / drop a view /// DELETE /_api/view/{view-name} /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task DeleteViewAsync(string viewNameOrId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get information about a view /// GET /_api/view/{view-name} /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetViewAsync(string viewNameOrId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Get the properties of a view /// GET /_api/view/{view-name}/properties /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task GetViewPropertiesAsync(string viewNameOrId, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Partially changes properties of a view @@ -75,10 +81,11 @@ Task GetViewPropertiesAsync(string viewNameOrId, /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, bool ignoreNullValuesOnSerialization = true, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Changes all properties of a view @@ -91,10 +98,11 @@ Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails bod /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutViewPropertiesAsync(string viewName, ViewDetails body, bool ignoreNullValuesOnSerialization = true, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); /// /// Renames a view @@ -102,10 +110,11 @@ Task PutViewPropertiesAsync(string viewName, ViewDetails body, boo /// /// The name of the view. /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// /// Note: This method is not available in a cluster. Task PutRenameViewAsync(string viewName, PutRenameViewBody body, - CancellationToken token = default); + ApiHeaderProperties headers = null, CancellationToken token = default); } } \ No newline at end of file diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index dde01428..8c9c49f9 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -51,18 +51,21 @@ public ViewApiClient(IApiClientTransport transport, IApiClientSerialization seri /// regardless of their type. /// GET /_api/view /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task GetAllViewsAsync( + public virtual async Task> GetAllViewsAsync( + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _apiPath; - using (var response = await _transport.GetAsync(uri,token:token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token:token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { - var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - return await DeserializeJsonFromStreamAsync(stream).ConfigureAwait(false); + return await GetResponseAsync(response).ConfigureAwait(false); } throw await GetApiErrorExceptionAsync(response).ConfigureAwait(false); } @@ -78,9 +81,13 @@ public virtual async Task GetAllViewsAsync( /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization=true, CancellationToken token = default) + public virtual async Task PostCreateViewAsync(ViewDetails body, + bool ignoreNullValuesOnSerialization=true, + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = _apiPath; @@ -88,7 +95,10 @@ public virtual async Task PostCreateViewAsync(ViewDetails body, bo ignoreNullValues: ignoreNullValuesOnSerialization, applySerializationOptionsToDictionaryValues: true)).ConfigureAwait(false); - using (var response = await _transport.PostAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PostAsync(uri, + content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -104,13 +114,17 @@ public virtual async Task PostCreateViewAsync(ViewDetails body, bo /// DELETE /_api/view/{view-name} /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task DeleteViewAsync(string viewNameOrId, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _apiPath + '/' + viewNameOrId; - using (var response = await _transport.DeleteAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.DeleteAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -126,13 +140,17 @@ public virtual async Task DeleteViewAsync(string viewNameOrI /// GET /_api/view/{view-name} /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetViewAsync(string viewNameOrId, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = _apiPath + '/' + viewNameOrId; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -148,13 +166,17 @@ public virtual async Task GetViewAsync(string viewNameOrId, /// GET /_api/view/{view-name}/properties /// /// The name or identifier of the view to drop. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task GetViewPropertiesAsync(string viewNameOrId, + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; - using (var response = await _transport.GetAsync(uri, token: token).ConfigureAwait(false)) + using (var response = await _transport.GetAsync(uri, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -176,17 +198,23 @@ public virtual async Task GetViewPropertiesAsync(stri /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, - bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) + bool ignoreNullValuesOnSerialization = true, + ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; 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)) + using (var response = await _transport.PatchAsync(uri, + content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -208,17 +236,22 @@ public virtual async Task PatchViewPropertiesAsync(string viewName /// This parameter can be used together with /// set to false to control if fields with null values are included. /// + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body, - bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) + bool ignoreNullValuesOnSerialization = true, ApiHeaderProperties headers = null, + CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/properties"; 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)) + using (var response = await _transport.PutAsync(uri, + content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { @@ -235,14 +268,17 @@ public virtual async Task PutViewPropertiesAsync(string viewName, /// /// The name of the view. /// The body of the request containing required properties. + /// Headers for the request /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutRenameViewAsync(string viewName, PutRenameViewBody body, - CancellationToken token = default) + ApiHeaderProperties headers = null, CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/rename"; var content = await GetContentAsync(body, new ApiClientSerializationOptions(true, true)).ConfigureAwait(false); - using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) + using (var response = await _transport.PutAsync(uri, content, + webHeaderCollection: headers?.ToWebHeaderCollection(), + token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) {