//----------------------
//
// Generated using the NSwag toolchain v13.2.0.0 (NJsonSchema v10.1.2.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org)
//
//----------------------
#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?'
#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
namespace SABClientNSwag
{
using System = global::System;
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.2.0.0 (NJsonSchema v10.1.2.0 (Newtonsoft.Json v11.0.0.0))")]
public partial class Client
{
private string _baseUrl = "";
private System.Net.Http.HttpClient _httpClient;
private System.Lazy _settings;
public Client(string baseUrl, System.Net.Http.HttpClient httpClient)
{
BaseUrl = baseUrl;
_httpClient = httpClient;
_settings = new System.Lazy(() =>
{
var settings = new Newtonsoft.Json.JsonSerializerSettings();
UpdateJsonSerializerSettings(settings);
return settings;
});
}
public string BaseUrl
{
get { return _baseUrl; }
set { _baseUrl = value; }
}
protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } }
partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings);
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Server status
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/status");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(StatusResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// User login status
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetLoginStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/loginStatus");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(LoginStatusResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// User configuration
/// optional code from user invitation
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task ConfigAsync(string code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/user/config?");
if (code != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("code") + "=").Append(System.Uri.EscapeDataString(ConvertToString(code, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(UserConfigResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Localization messages
/// Localization messages (key=message JSON).
/// A server side error occurred.
public async System.Threading.Tasks.Task> GetMessagesAsync(string locale, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (locale == null)
throw new System.ArgumentNullException("locale");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/messages/{locale}");
urlBuilder_.Replace("{locale}", System.Uri.EscapeDataString(ConvertToString(locale, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(System.Collections.Generic.IDictionary);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Generate user login password or access code (type = 'login'/'accessCode')
/// optional code from user invitation (if no user is ahenticated)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GenerateUserPasswordAsync(Type type, string code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (type == null)
throw new System.ArgumentNullException("type");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/user/generate-password?");
urlBuilder_.Append(System.Uri.EscapeDataString("type") + "=").Append(System.Uri.EscapeDataString(ConvertToString(type, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
if (code != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("code") + "=").Append(System.Uri.EscapeDataString(ConvertToString(code, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(GeneratedPassword);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Generate password based on provided PasswordRequirements
/// optional code from user invitation (if no user is ahenticated)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GenerateCustomPasswordAsync(PasswordRequirements body, string code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/user/generate-password?");
if (code != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("code") + "=").Append(System.Uri.EscapeDataString(ConvertToString(code, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(GeneratedPassword);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Password policy checker for user login password and access code
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task CheckUserPasswordComplianceAsync(string password = null, Type2? type = null, string code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/user/generate-password");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var boundary_ = System.Guid.NewGuid().ToString();
var content_ = new System.Net.Http.MultipartFormDataContent(boundary_);
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);
if (password != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(password, System.Globalization.CultureInfo.InvariantCulture)), "password");
}
if (type != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(type, System.Globalization.CultureInfo.InvariantCulture)), "type");
}
if (code != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(code, System.Globalization.CultureInfo.InvariantCulture)), "code");
}
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("OPTIONS");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(PasswodComplianceResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Calculates entropy of user provided password
/// optional code from user invitation (if no user is ahenticated)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task CalculatePasswordEntropyAsync(string password, string code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (password == null)
throw new System.ArgumentNullException("password");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/password-entropy/{password}?");
urlBuilder_.Replace("{password}", System.Uri.EscapeDataString(ConvertToString(password, System.Globalization.CultureInfo.InvariantCulture)));
if (code != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("code") + "=").Append(System.Uri.EscapeDataString(ConvertToString(code, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(PasswordEntropyResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Ticket password
/// Ticket ID
/// Station name
/// Optional station user - it is ignored if station user is defined in ticket
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetStationPasswordAsync(string ticket, string station, Platform? platform = null, string user = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (ticket == null)
throw new System.ArgumentNullException("ticket");
if (station == null)
throw new System.ArgumentNullException("station");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/getPassword?");
urlBuilder_.Append(System.Uri.EscapeDataString("ticket") + "=").Append(System.Uri.EscapeDataString(ConvertToString(ticket, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
urlBuilder_.Append(System.Uri.EscapeDataString("station") + "=").Append(System.Uri.EscapeDataString(ConvertToString(station, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
if (platform != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("platform") + "=").Append(System.Uri.EscapeDataString(ConvertToString(platform, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
if (user != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("user") + "=").Append(System.Uri.EscapeDataString(ConvertToString(user, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string));
return result_;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(string);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// QR Code
/// QR code url
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetQrCodeImageAsync(string url, int? size = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (url == null)
throw new System.ArgumentNullException("url");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/qr?");
urlBuilder_.Append(System.Uri.EscapeDataString("url") + "=").Append(System.Uri.EscapeDataString(ConvertToString(url, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
if (size != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("size") + "=").Append(System.Uri.EscapeDataString(ConvertToString(size, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200" || status_ == "206")
{
var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);
var fileResponse_ = new FileResponse((int)response_.StatusCode, headers_, responseStream_, null, response_);
client_ = null; response_ = null; // response and client are disposed by FileResponse
return fileResponse_;
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(FileResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Register station
/// Station/agent config name
/// Station platform
/// Station name
/// Unique random string
/// digest computed from stationName, nonce and seedBase
/// name of timezone - defined in java.util.TimeZone class
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task RegisterStationAsync(string configName, Platform2 platform, string stationName, string nonce, string digest, string timezone = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (configName == null)
throw new System.ArgumentNullException("configName");
if (platform == null)
throw new System.ArgumentNullException("platform");
if (stationName == null)
throw new System.ArgumentNullException("stationName");
if (nonce == null)
throw new System.ArgumentNullException("nonce");
if (digest == null)
throw new System.ArgumentNullException("digest");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/public/api/registerStation?");
urlBuilder_.Append(System.Uri.EscapeDataString("configName") + "=").Append(System.Uri.EscapeDataString(ConvertToString(configName, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
urlBuilder_.Append(System.Uri.EscapeDataString("platform") + "=").Append(System.Uri.EscapeDataString(ConvertToString(platform, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
urlBuilder_.Append(System.Uri.EscapeDataString("stationName") + "=").Append(System.Uri.EscapeDataString(ConvertToString(stationName, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
urlBuilder_.Append(System.Uri.EscapeDataString("nonce") + "=").Append(System.Uri.EscapeDataString(ConvertToString(nonce, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
urlBuilder_.Append(System.Uri.EscapeDataString("digest") + "=").Append(System.Uri.EscapeDataString(ConvertToString(digest, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
if (timezone != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("timezone") + "=").Append(System.Uri.EscapeDataString(ConvertToString(timezone, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(string);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// User Login
/// 'username' (if authenticating to the System domain) or 'domain\username' of user logging in
/// Login Success
/// A server side error occurred.
public async System.Threading.Tasks.Task LoginAsync(string login = null, string password = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/login");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var keyValues_ = new System.Collections.Generic.List>();
if (login != null)
keyValues_.Add(new System.Collections.Generic.KeyValuePair("login", ConvertToString(login, System.Globalization.CultureInfo.InvariantCulture)));
if (password != null)
keyValues_.Add(new System.Collections.Generic.KeyValuePair("password", ConvertToString(password, System.Globalization.CultureInfo.InvariantCulture)));
request_.Content = new System.Net.Http.FormUrlEncodedContent(keyValues_);
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Login failed", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(LoginStatusResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// User Login using KeyShield SSO (certificate/token)
/// base64 encoded KeyShield SSO authentication (certificate/token)
/// Login Success
/// A server side error occurred.
public async System.Threading.Tasks.Task KshieldCertLoginAsync(string authCert = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/certlogin");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var keyValues_ = new System.Collections.Generic.List>();
if (authCert != null)
keyValues_.Add(new System.Collections.Generic.KeyValuePair("authCert", ConvertToString(authCert, System.Globalization.CultureInfo.InvariantCulture)));
request_.Content = new System.Net.Http.FormUrlEncodedContent(keyValues_);
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Login failed", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(LoginStatusResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// 2FA authentication / verification
/// Login Success
/// A server side error occurred.
public async System.Threading.Tasks.Task Authenticate2FAsync(string securityCode = null, string key = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/user/secondfactor");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var keyValues_ = new System.Collections.Generic.List>();
if (securityCode != null)
keyValues_.Add(new System.Collections.Generic.KeyValuePair("securityCode", ConvertToString(securityCode, System.Globalization.CultureInfo.InvariantCulture)));
if (key != null)
keyValues_.Add(new System.Collections.Generic.KeyValuePair("key", ConvertToString(key, System.Globalization.CultureInfo.InvariantCulture)));
request_.Content = new System.Net.Http.FormUrlEncodedContent(keyValues_);
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "500")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Failed to verify securityCode - see msg in response for details", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Safe Boxes
/// list only boxes for which user has at least ccess rights specified (example for Read and Create: RC)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetSafeBoxesAsync(string access = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes?");
if (access != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("access") + "=").Append(System.Uri.EscapeDataString(ConvertToString(access, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(SafeBoxes);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// New Safe Box
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task CreateSafeBoxAsync(string sAB_Access_Code, SafeBox body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes");
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(NewRecordId);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Get Safe Box
/// ID of Safe Box to get.
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetSafeBoxAsync(long boxId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response2);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// New Safe Box
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Safe Box. ID=0 or missing ID means Root Safe Box
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task CreateChildSafeBoxAsync(string sAB_Access_Code, SafeBox safebox, long boxId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(safebox, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(NewRecordId);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Update Safe Box
/// ID of Safe Box. ID=0 or missing ID means Root Safe Box
/// access code is required when changing to/from private safebox
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task UpdateChildSafeBoxAsync(long boxId, string sAB_Access_Code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code != null)
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
request_.Method = new System.Net.Http.HttpMethod("PUT");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response3);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Delete Safe Box
/// ID of Safe Box. ID=0 or missing ID means Root Safe Box
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task DeleteChildSafeBoxAsync(long boxId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("DELETE");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response4);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Safe Boxes
/// ID of parent Safe Box
/// list only boxes for which user has at least ccess rights specified (example for Read and Create: RC)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetChildSafeBoxesAsync(long boxId, string access = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}/boxes?");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
if (access != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("access") + "=").Append(System.Uri.EscapeDataString(ConvertToString(access, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(SafeBoxes);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Find Safe Boxes and Records using given query
/// Lucene query string
/// optional query syntax switch (currently recognizes 'default' = the way SecureAnyBox web interface searches or 'standard' which accepts Lucene query syntax (field names = name,description,note,login,address,tag,type,template)
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task FindRecordsAsync(string query, string queryType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (query == null)
throw new System.ArgumentNullException("query");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/search/{query}?");
urlBuilder_.Replace("{query}", System.Uri.EscapeDataString(ConvertToString(query, System.Globalization.CultureInfo.InvariantCulture)));
if (queryType != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("queryType") + "=").Append(System.Uri.EscapeDataString(ConvertToString(queryType, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "500")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Request failed.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(SearchResults);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Safe Box Records
/// ID of parent Safe Box
/// return file name and size in record list
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetRecordsAsync(long boxId, bool? fileInfo = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}/records?");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
if (fileInfo != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("fileInfo") + "=").Append(System.Uri.EscapeDataString(ConvertToString(fileInfo, System.Globalization.CultureInfo.InvariantCulture))).Append("&");
}
urlBuilder_.Length--;
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Records);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// New Record
/// ID of parent Safe Box
/// required if setting password or encrypted attributes - URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task CreateRecordAsync(Record body, long boxId, string sAB_Access_Code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (boxId == null)
throw new System.ArgumentNullException("boxId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/boxes/{boxId}/records");
urlBuilder_.Replace("{boxId}", System.Uri.EscapeDataString(ConvertToString(boxId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code != null)
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Request parameter validation failed.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "500")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Request failed.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(NewRecordId);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Get Record
/// ID of Record
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetRecordAsync(long recordId, string sAB_Access_Code = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code != null)
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "500")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Login failed", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response5);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Update Record
/// ID of Record
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task UpdateRecordAsync(long recordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
request_.Method = new System.Net.Http.HttpMethod("PUT");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response6);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Delete Record
/// ID of Record
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task DeleteRecordAsync(long recordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("DELETE");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
return;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Get Account or Secret Account Password
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Record
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetPasswordAsync(string sAB_Access_Code, long recordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/passwords");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response7);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Change Account or Secret Account Password
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Record
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task SetPasswordAsync(string sAB_Access_Code, Body body, long recordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/passwords");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value));
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response8);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Get Account or Secret Account password history
/// ID of Record
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task GetPasswordHistoryAsync(long recordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/passwords");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
request_.Method = new System.Net.Http.HttpMethod("OPTIONS");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response9);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Get record password by Id
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Record
/// ID of account password
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task PasswordsAsync(string sAB_Access_Code, long recordId, string passwordId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
if (passwordId == null)
throw new System.ArgumentNullException("passwordId");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/passwords/{passwordId}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
urlBuilder_.Replace("{passwordId}", System.Uri.EscapeDataString(ConvertToString(passwordId, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
return objectResponse_.Object;
}
else
if (status_ == "401")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("No user is authenticated!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission for requested operation.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Database record with provided id was not found.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(Response10);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Upload file to record
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Record
/// name of file attribute in Record. Usually 'file'
/// The file to upload
/// File uploaded successfully.
/// A server side error occurred.
public async System.Threading.Tasks.Task UploadAsync(string sAB_Access_Code, long recordId, string attrName, FileParameter file = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
if (attrName == null)
throw new System.ArgumentNullException("attrName");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/upload/{attrName}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
urlBuilder_.Replace("{attrName}", System.Uri.EscapeDataString(ConvertToString(attrName, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
request_.Headers.TryAddWithoutValidation("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture));
var boundary_ = System.Guid.NewGuid().ToString();
var content_ = new System.Net.Http.MultipartFormDataContent(boundary_);
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);
if (file != null)
{
var content_file_ = new System.Net.Http.StreamContent(file.Data);
if (!string.IsNullOrEmpty(file.ContentType))
content_file_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(file.ContentType);
content_.Add(content_file_, "file", file.FileName ?? "file");
}
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200" || status_ == "206")
{
var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);
var fileResponse_ = new FileResponse((int)response_.StatusCode, headers_, responseStream_, null, response_);
client_ = null; response_ = null; // response and client are disposed by FileResponse
return fileResponse_;
}
else
if (status_ == "401")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("Not user authenticated!", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ == "403")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("User has no permission to modify Account", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ == "404")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("Record not found!", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ == "413")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("File size limit exceeded!", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ == "422")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(FileResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// Download file from record
/// URL encoded access code - you must use URL encoding on utf-8 bytes to preserve international characters, special characters etc. as HTTP headers use only limited ASCII. There is no encoding standard and SecureAnyBox expects and decodes URL encoded access code.
/// ID of Record
/// name of file attribute in Record. Usually 'file'
/// Status 200
/// A server side error occurred.
public async System.Threading.Tasks.Task DownloadAsync(string sAB_Access_Code, long recordId, string attrName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (recordId == null)
throw new System.ArgumentNullException("recordId");
if (attrName == null)
throw new System.ArgumentNullException("attrName");
var urlBuilder_ = new System.Text.StringBuilder();
urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/safe/records/{recordId}/download/{attrName}");
urlBuilder_.Replace("{recordId}", System.Uri.EscapeDataString(ConvertToString(recordId, System.Globalization.CultureInfo.InvariantCulture)));
urlBuilder_.Replace("{attrName}", System.Uri.EscapeDataString(ConvertToString(attrName, System.Globalization.CultureInfo.InvariantCulture)));
var client_ = _httpClient;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var keyValues_ = new System.Collections.Generic.List>();
if (sAB_Access_Code == null)
throw new System.ArgumentNullException("sAB_Access_Code");
else
keyValues_.Add(new System.Collections.Generic.KeyValuePair("SAB-Access-Code", ConvertToString(sAB_Access_Code, System.Globalization.CultureInfo.InvariantCulture)));
request_.Content = new System.Net.Http.FormUrlEncodedContent(keyValues_);
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("binary/octet-stream"));
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = ((int)response_.StatusCode).ToString();
if (status_ == "200" || status_ == "206")
{
var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);
var fileResponse_ = new FileResponse((int)response_.StatusCode, headers_, responseStream_, null, response_);
client_ = null; response_ = null; // response and client are disposed by FileResponse
return fileResponse_;
}
else
if (status_ == "401")
{
string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("No user authenticated!", (int)response_.StatusCode, responseText_, headers_, null);
}
else
if (status_ == "403")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("User has no permission to read record.", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "404")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Record not found!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ == "422")
{
var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false);
throw new ApiException("Validation failed!", (int)response_.StatusCode, objectResponse_.Text, headers_, objectResponse_.Object, null);
}
else
if (status_ != "200" && status_ != "204")
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
}
return default(FileResponse);
}
finally
{
if (response_ != null)
response_.Dispose();
}
}
}
finally
{
}
}
protected struct ObjectResponseResult
{
public ObjectResponseResult(T responseObject, string responseText)
{
this.Object = responseObject;
this.Text = responseText;
}
public T Object { get; }
public string Text { get; }
}
public bool ReadResponseAsString { get; set; }
protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers)
{
if (response == null || response.Content == null)
{
return new ObjectResponseResult(default(T), string.Empty);
}
if (ReadResponseAsString)
{
var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings);
return new ObjectResponseResult(typedBody, responseText);
}
catch (Newtonsoft.Json.JsonException exception)
{
var message = "Could not deserialize the response body string as " + typeof(T).FullName + ".";
throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception);
}
}
else
{
try
{
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
using (var streamReader = new System.IO.StreamReader(responseStream))
using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader))
{
var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings);
var typedBody = serializer.Deserialize(jsonTextReader);
return new ObjectResponseResult(typedBody, string.Empty);
}
}
catch (Newtonsoft.Json.JsonException exception)
{
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + ".";
throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception);
}
}
}
private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo)
{
if (value is System.Enum)
{
string name = System.Enum.GetName(value.GetType(), value);
if (name != null)
{
var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name);
if (field != null)
{
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
as System.Runtime.Serialization.EnumMemberAttribute;
if (attribute != null)
{
return attribute.Value != null ? attribute.Value : name;
}
}
}
}
else if (value is bool) {
return System.Convert.ToString(value, cultureInfo).ToLowerInvariant();
}
else if (value is byte[])
{
return System.Convert.ToBase64String((byte[]) value);
}
else if (value != null && value.GetType().IsArray)
{
var array = System.Linq.Enumerable.OfType