diff --git a/src/Evelyn.Client.Rest/EnvironmentStateRestProvider.cs b/src/Evelyn.Client.Rest/EnvironmentStateRestProvider.cs index d198bef..0d7cfdd 100644 --- a/src/Evelyn.Client.Rest/EnvironmentStateRestProvider.cs +++ b/src/Evelyn.Client.Rest/EnvironmentStateRestProvider.cs @@ -10,12 +10,12 @@ public class EnvironmentStateRestProvider : IEnvironmentStateProvider { - private readonly Client _client; + private readonly EvelynRestClient _client; private readonly ILogger _logger; public EnvironmentStateRestProvider(IOptions options, ILogger logger) { - _client = new Client(options.Value.BaseUrl); + _client = new EvelynRestClient(options.Value.BaseUrl); _logger = logger; } @@ -24,7 +24,7 @@ public Domain.EnvironmentState Invoke(Guid projectId, string environmentKey) try { var dto = _client - .ApiStatesAsync(projectId, environmentKey) + .GetAsync(projectId, environmentKey) .GetAwaiter().GetResult(); var toggleStates = new List(); diff --git a/src/Evelyn.Client.Rest/Evelyn.Client.Rest.csproj b/src/Evelyn.Client.Rest/Evelyn.Client.Rest.csproj index 4868294..296d1b8 100644 --- a/src/Evelyn.Client.Rest/Evelyn.Client.Rest.csproj +++ b/src/Evelyn.Client.Rest/Evelyn.Client.Rest.csproj @@ -48,8 +48,4 @@ - - - - diff --git a/src/Evelyn.Client.Rest/Generated/EvelynRestClient.cs b/src/Evelyn.Client.Rest/Generated/EvelynRestClient.cs new file mode 100644 index 0000000..3ea65df --- /dev/null +++ b/src/Evelyn.Client.Rest/Generated/EvelynRestClient.cs @@ -0,0 +1,377 @@ +//---------------------- +// +// Generated using the NSwag toolchain v12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org) +// +//---------------------- + +namespace Evelyn.Client.Rest.Generated +{ + #pragma warning disable + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class EvelynRestClient + { + private string _baseUrl = ""; + private System.Lazy _settings; + + public EvelynRestClient(string baseUrl) + { + BaseUrl = baseUrl; + _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); + + /// Success + /// A server side error occurred. + public System.Threading.Tasks.Task GetAsync(System.Guid projectId, string environmentName) + { + return GetAsync(projectId, environmentName, System.Threading.CancellationToken.None); + } + + /// Success + /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + public async System.Threading.Tasks.Task GetAsync(System.Guid projectId, string environmentName, System.Threading.CancellationToken cancellationToken) + { + if (projectId == null) + throw new System.ArgumentNullException("projectId"); + + if (environmentName == null) + throw new System.ArgumentNullException("environmentName"); + + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/client-api/projects/{projectId}/environments/{environmentName}/state"); + urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Replace("{environmentName}", System.Uri.EscapeDataString(ConvertToString(environmentName, System.Globalization.CultureInfo.InvariantCulture))); + + var client_ = new System.Net.Http.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_ == "500") + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(System.Collections.Generic.IDictionary); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); + } + else + if (status_ == "200") + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(Projection); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); + return result_; + } + catch (System.Exception exception_) + { + throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + } + else + if (status_ == "404") + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + var result_ = default(System.Collections.Generic.IDictionary); + try + { + result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); + } + catch (System.Exception exception_) + { + throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); + } + throw new SwaggerException>("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); + } + else + if (status_ != "200" && status_ != "204") + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); + } + + return default(Projection); + } + finally + { + if (response_ != null) + response_.Dispose(); + } + } + } + finally + { + if (client_ != null) + client_.Dispose(); + } + } + + /// Success + /// A server side error occurred. + public System.Threading.Tasks.Task GetHealthAsync() + { + return GetHealthAsync(System.Threading.CancellationToken.None); + } + + /// Success + /// A server side error occurred. + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + public async System.Threading.Tasks.Task GetHealthAsync(System.Threading.CancellationToken cancellationToken) + { + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/status/health"); + + var client_ = new System.Net.Http.HttpClient(); + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + + 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_ != "200" && status_ != "204") + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new SwaggerException("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 + { + if (client_ != null) + client_.Dispose(); + } + } + + 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; + } + } + } + } + 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((System.Array) value); + return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); + } + + return System.Convert.ToString(value, cultureInfo); + } + } + + + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class Projection + { + [Newtonsoft.Json.JsonProperty("environmentState", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public EnvironmentState EnvironmentState { get; set; } + + [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public ProjectionAudit Audit { get; set; } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static Projection FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class EnvironmentState + { + [Newtonsoft.Json.JsonProperty("toggleStates", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection ToggleStates { get; set; } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static EnvironmentState FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class ProjectionAudit + { + [Newtonsoft.Json.JsonProperty("generated", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? Generated { get; set; } + + [Newtonsoft.Json.JsonProperty("streamPosition", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long? StreamPosition { get; set; } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ProjectionAudit FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.13.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class ToggleState + { + [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Key { get; set; } + + [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Value { get; set; } + + public string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this); + } + + public static ToggleState FromJson(string data) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(data); + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class SwaggerException : System.Exception + { + public int StatusCode { get; private set; } + + public string Response { get; private set; } + + public System.Collections.Generic.Dictionary> Headers { get; private set; } + + public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) + { + StatusCode = statusCode; + Response = response; + Headers = headers; + } + + public override string ToString() + { + return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); + } + } + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.11.0 (NJsonSchema v9.13.13.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class SwaggerException : SwaggerException + { + public TResult Result { get; private set; } + + public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) + : base(message, statusCode, response, headers, innerException) + { + Result = result; + } + } + + #pragma warning restore +} \ No newline at end of file diff --git a/src/Evelyn.Client.Rest/Generated/OpenApiClasses.cs b/src/Evelyn.Client.Rest/Generated/OpenApiClasses.cs deleted file mode 100644 index 832600d..0000000 --- a/src/Evelyn.Client.Rest/Generated/OpenApiClasses.cs +++ /dev/null @@ -1,2093 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v12.0.5.0 (NJsonSchema v9.13.2.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org) -// -//---------------------- - -namespace Evelyn.Client.Rest.Generated -{ -#pragma warning disable // Disable all warnings - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.5.0 (NJsonSchema v9.13.2.0 (Newtonsoft.Json v11.0.0.0))")] - public partial class Client - { - private string _baseUrl = ""; - private System.Lazy _settings; - - public Client(string baseUrl) - { - BaseUrl = baseUrl; - _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); - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsTogglesAddAsync(System.Guid projectId, AddToggle message) - { - return ApiProjectsTogglesAddAsync(projectId, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsTogglesAddAsync(System.Guid projectId, AddToggle message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/toggles/add"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsTogglesDeleteAsync(System.Guid projectId, string toggleKey, DeleteToggle message) - { - return ApiProjectsTogglesDeleteAsync(projectId, toggleKey, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsTogglesDeleteAsync(System.Guid projectId, string toggleKey, DeleteToggle message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (toggleKey == null) - throw new System.ArgumentNullException("toggleKey"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/toggles/{toggleKey}/delete"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{toggleKey}", System.Uri.EscapeDataString(ConvertToString(toggleKey, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsEnvironmentsTogglesChangeStateAsync(System.Guid projectId, string environmentKey, string toggleKey, ChangeToggleState message) - { - return ApiProjectsEnvironmentsTogglesChangeStateAsync(projectId, environmentKey, toggleKey, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsEnvironmentsTogglesChangeStateAsync(System.Guid projectId, string environmentKey, string toggleKey, ChangeToggleState message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (environmentKey == null) - throw new System.ArgumentNullException("environmentKey"); - - if (toggleKey == null) - throw new System.ArgumentNullException("toggleKey"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/environments/{environmentKey}/toggles/{toggleKey}/change-state"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{environmentKey}", System.Uri.EscapeDataString(ConvertToString(environmentKey, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{toggleKey}", System.Uri.EscapeDataString(ConvertToString(toggleKey, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsCreateAsync(CreateProject message) - { - return ApiProjectsCreateAsync(message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsCreateAsync(CreateProject message, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/create"); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsDeleteAsync(System.Guid projectId, DeleteProject message) - { - return ApiProjectsDeleteAsync(projectId, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsDeleteAsync(System.Guid projectId, DeleteProject message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/delete"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsEnvironmentsAddAsync(System.Guid projectId, AddEnvironment message) - { - return ApiProjectsEnvironmentsAddAsync(projectId, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsEnvironmentsAddAsync(System.Guid projectId, AddEnvironment message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/environments/add"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsEnvironmentsDeleteAsync(System.Guid projectId, string environmentKey, DeleteEnvironment message) - { - return ApiProjectsEnvironmentsDeleteAsync(projectId, environmentKey, message, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsEnvironmentsDeleteAsync(System.Guid projectId, string environmentKey, DeleteEnvironment message, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (environmentKey == null) - throw new System.ArgumentNullException("environmentKey"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/environments/{environmentKey}/delete"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{environmentKey}", System.Uri.EscapeDataString(ConvertToString(environmentKey, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(message, _settings.Value)); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("POST"); - - 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_ == "202") - { - return; - } - else - if (status_ == "400") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ValidationErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Bad Request", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "409") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Conflict", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(ErrorResponse); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsEnvironmentsAsync(System.Guid projectId, string environmentKey) - { - return ApiProjectsEnvironmentsAsync(projectId, environmentKey, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsEnvironmentsAsync(System.Guid projectId, string environmentKey, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (environmentKey == null) - throw new System.ArgumentNullException("environmentKey"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/environments/{environmentKey}"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{environmentKey}", System.Uri.EscapeDataString(ConvertToString(environmentKey, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.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_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "200") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(Projection); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - } - else - if (status_ == "404") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); - } - - return default(Projection); - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiStatesAsync(System.Guid projectId, string environmentName) - { - return ApiStatesAsync(projectId, environmentName, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiStatesAsync(System.Guid projectId, string environmentName, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (environmentName == null) - throw new System.ArgumentNullException("environmentName"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/states/{projectId}/{environmentName}"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{environmentName}", System.Uri.EscapeDataString(ConvertToString(environmentName, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.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_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "200") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(Projection2); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - } - else - if (status_ == "404") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); - } - - return default(Projection2); - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task> ApiProjectsGetAsync() - { - return ApiProjectsGetAsync(System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task> ApiProjectsGetAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects"); - - var client_ = new System.Net.Http.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_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "200") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.ICollection); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); - } - - return default(System.Collections.Generic.ICollection); - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsGetAsync(System.Guid id) - { - return ApiProjectsGetAsync(id, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsGetAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) - { - if (id == null) - throw new System.ArgumentNullException("id"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{id}"); - urlBuilder_.Replace("{id}", System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.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_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "200") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(Projection3); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - } - else - if (status_ == "404") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); - } - - return default(Projection3); - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task StatusHealthAsync() - { - return StatusHealthAsync(System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task StatusHealthAsync(System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/status/health"); - - var client_ = new System.Net.Http.HttpClient(); - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - - 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_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("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 - { - if (client_ != null) - client_.Dispose(); - } - } - - /// Success - /// A server side error occurred. - public System.Threading.Tasks.Task ApiProjectsTogglesAsync(System.Guid projectId, string toggleKey) - { - return ApiProjectsTogglesAsync(projectId, toggleKey, System.Threading.CancellationToken.None); - } - - /// Success - /// A server side error occurred. - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - public async System.Threading.Tasks.Task ApiProjectsTogglesAsync(System.Guid projectId, string toggleKey, System.Threading.CancellationToken cancellationToken) - { - if (projectId == null) - throw new System.ArgumentNullException("projectId"); - - if (toggleKey == null) - throw new System.ArgumentNullException("toggleKey"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/api/projects/{projectId}/toggles/{toggleKey}"); - urlBuilder_.Replace("{projectId}", System.Uri.EscapeDataString(ConvertToString(projectId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{toggleKey}", System.Uri.EscapeDataString(ConvertToString(toggleKey, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = new System.Net.Http.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_ == "500") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Server Error", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ == "200") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(Projection4); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject(responseData_, _settings.Value); - return result_; - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - } - else - if (status_ == "404") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = default(System.Collections.Generic.IDictionary); - try - { - result_ = Newtonsoft.Json.JsonConvert.DeserializeObject>(responseData_, _settings.Value); - } - catch (System.Exception exception_) - { - throw new SwaggerException("Could not deserialize the response body.", (int)response_.StatusCode, responseData_, headers_, exception_); - } - throw new SwaggerException>("Not Found", (int)response_.StatusCode, responseData_, headers_, result_, null); - } - else - if (status_ != "200" && status_ != "204") - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null); - } - - return default(Projection4); - } - finally - { - if (response_ != null) - response_.Dispose(); - } - } - } - finally - { - if (client_ != null) - client_.Dispose(); - } - } - - 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; - } - } - } - } - 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((System.Array)value); - return string.Join(",", System.Linq.Enumerable.Select(array, o => ConvertToString(o, cultureInfo))); - } - - return System.Convert.ToString(value, cultureInfo); - } - } - - - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class AddToggle - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - [Newtonsoft.Json.JsonProperty("expectedProjectVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedProjectVersion { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static AddToggle FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ValidationErrorResponse - { - [Newtonsoft.Json.JsonProperty("errors", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Errors { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ValidationErrorResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ValidationError - { - [Newtonsoft.Json.JsonProperty("property", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Property { get; set; } - - [Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Code { get; set; } - - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ValidationError FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ErrorResponse - { - [Newtonsoft.Json.JsonProperty("errors", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Errors { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ErrorResponse FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Error - { - [Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Code { get; set; } - - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Message { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Error FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class DeleteToggle - { - [Newtonsoft.Json.JsonProperty("expectedToggleVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedToggleVersion { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DeleteToggle FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ChangeToggleState - { - [Newtonsoft.Json.JsonProperty("expectedToggleStateVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedToggleStateVersion { get; set; } - - [Newtonsoft.Json.JsonProperty("state", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string State { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ChangeToggleState FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class CreateProject - { - [Newtonsoft.Json.JsonProperty("projectId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Guid? ProjectId { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static CreateProject FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class DeleteProject - { - [Newtonsoft.Json.JsonProperty("expectedProjectVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedProjectVersion { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DeleteProject FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class AddEnvironment - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - [Newtonsoft.Json.JsonProperty("expectedProjectVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedProjectVersion { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static AddEnvironment FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class DeleteEnvironment - { - [Newtonsoft.Json.JsonProperty("expectedEnvironmentVersion", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int? ExpectedEnvironmentVersion { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static DeleteEnvironment FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Projection - { - [Newtonsoft.Json.JsonProperty("environment", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public Environment Environment { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ProjectionAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Projection FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Environment - { - [Newtonsoft.Json.JsonProperty("projectId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Guid? ProjectId { get; set; } - - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public AggregateAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Environment FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ProjectionAudit - { - [Newtonsoft.Json.JsonProperty("generated", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? Generated { get; set; } - - [Newtonsoft.Json.JsonProperty("streamPosition", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? StreamPosition { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ProjectionAudit FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class AggregateAudit - { - [Newtonsoft.Json.JsonProperty("created", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? Created { get; set; } - - [Newtonsoft.Json.JsonProperty("createdBy", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string CreatedBy { get; set; } - - [Newtonsoft.Json.JsonProperty("lastModified", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.DateTimeOffset? LastModified { get; set; } - - [Newtonsoft.Json.JsonProperty("lastModifiedBy", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string LastModifiedBy { get; set; } - - [Newtonsoft.Json.JsonProperty("version", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? Version { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static AggregateAudit FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Projection2 - { - [Newtonsoft.Json.JsonProperty("environmentState", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public EnvironmentState EnvironmentState { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ProjectionAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Projection2 FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class EnvironmentState - { - [Newtonsoft.Json.JsonProperty("toggleStates", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection ToggleStates { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static EnvironmentState FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class ToggleState - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Value { get; set; } - - [Newtonsoft.Json.JsonProperty("version", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public long? Version { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static ToggleState FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Projection3 - { - [Newtonsoft.Json.JsonProperty("project", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public Project Project { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ProjectionAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Projection3 FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Project - { - [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Guid? Id { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public AggregateAudit Audit { get; set; } - - [Newtonsoft.Json.JsonProperty("environments", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Environments { get; set; } - - [Newtonsoft.Json.JsonProperty("toggles", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Collections.Generic.ICollection Toggles { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Project FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Environment2 - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Environment2 FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Toggle - { - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Toggle FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Projection4 - { - [Newtonsoft.Json.JsonProperty("toggle", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public Toggle2 Toggle { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public ProjectionAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Projection4 FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "9.13.2.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class Toggle2 - { - [Newtonsoft.Json.JsonProperty("projectId", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public System.Guid? ProjectId { get; set; } - - [Newtonsoft.Json.JsonProperty("key", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Key { get; set; } - - [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string Name { get; set; } - - [Newtonsoft.Json.JsonProperty("audit", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public AggregateAudit Audit { get; set; } - - public string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this); - } - - public static Toggle2 FromJson(string data) - { - return Newtonsoft.Json.JsonConvert.DeserializeObject(data); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.5.0 (NJsonSchema v9.13.2.0 (Newtonsoft.Json v11.0.0.0))")] - public partial class SwaggerException : System.Exception - { - public int StatusCode { get; private set; } - - public string Response { get; private set; } - - public System.Collections.Generic.Dictionary> Headers { get; private set; } - - public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + response.Substring(0, response.Length >= 512 ? 512 : response.Length), innerException) - { - StatusCode = statusCode; - Response = response; - Headers = headers; - } - - public override string ToString() - { - return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); - } - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "12.0.5.0 (NJsonSchema v9.13.2.0 (Newtonsoft.Json v11.0.0.0))")] - public partial class SwaggerException : SwaggerException - { - public TResult Result { get; private set; } - - public SwaggerException(string message, int statusCode, string response, System.Collections.Generic.Dictionary> headers, TResult result, System.Exception innerException) - : base(message, statusCode, response, headers, innerException) - { - Result = result; - } - } - -#pragma warning restore -} \ No newline at end of file diff --git a/src/Evelyn.Client.Rest/Generated/RestApi.nswag b/src/Evelyn.Client.Rest/Generated/RestApi.nswag index a72ac65..3206967 100644 --- a/src/Evelyn.Client.Rest/Generated/RestApi.nswag +++ b/src/Evelyn.Client.Rest/Generated/RestApi.nswag @@ -3,7 +3,8 @@ "defaultVariables": null, "swaggerGenerator": { "fromSwagger": { - "url": "http://localhost:2316/swagger/v0.1/swagger.json", + "json": "{\r\n \"swagger\": \"2.0\",\r\n \"info\": {\r\n \"version\": \"client-api\",\r\n \"title\": \"Evelyn Client API\",\r\n \"description\": \"Client API for Evelyn\"\r\n },\r\n \"paths\": {\r\n \"/client-api/projects/{projectId}/environments/{environmentName}/state\": {\r\n \"get\": {\r\n \"tags\": [\r\n \"ClientEnvironmentStates\"\r\n ],\r\n \"operationId\": \"Get\",\r\n \"consumes\": [],\r\n \"produces\": [\r\n \"text/plain\",\r\n \"application/json\",\r\n \"text/json\"\r\n ],\r\n \"parameters\": [\r\n {\r\n \"name\": \"projectId\",\r\n \"in\": \"path\",\r\n \"required\": true,\r\n \"type\": \"string\",\r\n \"format\": \"uuid\"\r\n },\r\n {\r\n \"name\": \"environmentName\",\r\n \"in\": \"path\",\r\n \"required\": true,\r\n \"type\": \"string\"\r\n }\r\n ],\r\n \"responses\": {\r\n \"500\": {\r\n \"description\": \"Server Error\",\r\n \"schema\": {\r\n \"type\": \"object\",\r\n \"additionalProperties\": {\r\n \"type\": \"string\"\r\n }\r\n }\r\n },\r\n \"200\": {\r\n \"description\": \"Success\",\r\n \"schema\": {\r\n \"$ref\": \"#/definitions/Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Projection\"\r\n }\r\n },\r\n \"404\": {\r\n \"description\": \"Not Found\",\r\n \"schema\": {\r\n \"type\": \"object\",\r\n \"additionalProperties\": {\r\n \"type\": \"string\"\r\n }\r\n }\r\n }\r\n }\r\n }\r\n },\r\n \"/status/health\": {\r\n \"get\": {\r\n \"tags\": [\r\n \"Status\"\r\n ],\r\n \"operationId\": \"GetHealth\",\r\n \"consumes\": [],\r\n \"produces\": [],\r\n \"parameters\": [],\r\n \"responses\": {\r\n \"200\": {\r\n \"description\": \"Success\"\r\n }\r\n }\r\n }\r\n }\r\n },\r\n \"definitions\": {\r\n \"Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Projection\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"environmentState\": {\r\n \"$ref\": \"#/definitions/Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model.EnvironmentState\"\r\n },\r\n \"audit\": {\r\n \"$ref\": \"#/definitions/Evelyn.Core.ReadModel.Projections.ProjectionAudit\",\r\n \"readOnly\": true\r\n }\r\n }\r\n },\r\n \"Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model.EnvironmentState\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"toggleStates\": {\r\n \"uniqueItems\": false,\r\n \"type\": \"array\",\r\n \"items\": {\r\n \"$ref\": \"#/definitions/Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model.ToggleState\"\r\n },\r\n \"readOnly\": true\r\n }\r\n }\r\n },\r\n \"Evelyn.Core.ReadModel.Projections.ProjectionAudit\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"generated\": {\r\n \"format\": \"date-time\",\r\n \"type\": \"string\",\r\n \"readOnly\": true\r\n },\r\n \"streamPosition\": {\r\n \"format\": \"int64\",\r\n \"type\": \"integer\",\r\n \"readOnly\": true\r\n }\r\n }\r\n },\r\n \"Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model.ToggleState\": {\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"key\": {\r\n \"type\": \"string\",\r\n \"readOnly\": true\r\n },\r\n \"value\": {\r\n \"type\": \"string\",\r\n \"readOnly\": true\r\n }\r\n }\r\n }\r\n }\r\n}", + "url": "http://localhost:2316/swagger/client-api/swagger.json", "output": null } }, @@ -36,8 +37,8 @@ "generateUpdateJsonSerializerSettingsMethod": true, "serializeTypeInformation": false, "queryNullValue": "", - "className": "{controller}Client", - "operationGenerationMode": "SingleClientFromPathSegments", + "className": "EvelynRestClient", + "operationGenerationMode": "SingleClientFromOperationId", "additionalNamespaceUsages": [], "additionalContractNamespaceUsages": [], "generateOptionalParameters": false, @@ -72,13 +73,15 @@ "generateImmutableArrayProperties": false, "generateImmutableDictionaryProperties": false, "jsonSerializerSettingsTransformationMethod": null, + "inlineNamedDictionaries": false, + "inlineNamedTuples": true, "templateDirectory": null, "typeNameGeneratorType": null, "propertyNameGeneratorType": null, "enumNameGeneratorType": null, "serviceHost": null, "serviceSchemes": null, - "output": null + "output": "EvelynRestClient.cs" } } } \ No newline at end of file diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateAddedSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateAddedSpecs.cs new file mode 100644 index 0000000..6dce650 --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateAddedSpecs.cs @@ -0,0 +1,46 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents +{ + using System.Threading.Tasks; + using AutoFixture; + using Evelyn.Core.ReadModel.Projections.ClientEnvironmentState; + using Evelyn.Core.WriteModel.Project.Events; + using FluentAssertions; + using NSubstitute; + using TestStack.BDDfy; + using Xunit; + + public class EnvironmentStateAddedSpecs : ProjectionBuilderHarness + { + [Fact] + public void Nominal() + { + this.Given(_ => GivenThereIsNoProjection()) + .When(_ => WhenWeHandleAnEnvironmentStateAddedEvent()) + .Then(_ => ThenTheProjectionAuditIsSet()) + .And(_ => ThenTheProjectionContainsTheEnvironmentState()) + .BDDfy(); + } + + protected override async Task HandleEventImplementation() + { + await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); + } + + private async Task WhenWeHandleAnEnvironmentStateAddedEvent() + { + Event = DataFixture.Build() + .With(ar => ar.Id, ProjectId) + .With(esa => esa.EnvironmentKey, EnvironmentKey) + .Create(); + + await WhenTheEventIsHandled(); + } + + private void ThenTheProjectionContainsTheEnvironmentState() + { + ProjectionStore.Received().Create(Projection.StoreKey(ProjectId, EnvironmentKey), UpdatedProjection); + + UpdatedProjection.EnvironmentState.ToggleStates.Should().BeEquivalentTo(Event.ToggleStates); + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateDeletedSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateDeletedSpecs.cs new file mode 100644 index 0000000..b14e49e --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/EnvironmentStateDeletedSpecs.cs @@ -0,0 +1,42 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents +{ + using System.Threading.Tasks; + using AutoFixture; + using Evelyn.Core.ReadModel.Projections.ClientEnvironmentState; + using Evelyn.Core.WriteModel.Project.Events; + using NSubstitute; + using TestStack.BDDfy; + using Xunit; + + public class EnvironmentStateDeletedSpecs : ProjectionBuilderHarness + { + [Fact] + public void Nominal() + { + this.Given(_ => GivenTheProjectionExists()) + .When(_ => WhenWeHandleAnEnvironmentStateDeletedEvent()) + .Then(_ => ThenTheProjectionIsDeleted()) + .BDDfy(); + } + + protected override async Task HandleEventImplementation() + { + await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); + } + + private async Task WhenWeHandleAnEnvironmentStateDeletedEvent() + { + Event = DataFixture.Build() + .With(pc => pc.Id, ProjectId) + .With(pc => pc.EnvironmentKey, EnvironmentKey) + .Create(); + + await WhenTheEventIsHandled(); + } + + private void ThenTheProjectionIsDeleted() + { + ProjectionStore.Received().Delete(Projection.StoreKey(ProjectId, EnvironmentKey)); + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateAddedSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateAddedSpecs.cs new file mode 100644 index 0000000..b1c892e --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateAddedSpecs.cs @@ -0,0 +1,74 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents +{ + using System.Linq; + using System.Threading.Tasks; + using AutoFixture; + using Evelyn.Core.WriteModel.Project.Events; + using FluentAssertions; + using TestStack.BDDfy; + using Xunit; + using Projections = Evelyn.Core.ReadModel.Projections; + + public class ToggleStateAddedSpecs : ProjectionBuilderHarness + { + [Fact] + public void ProjectionDoesNotExist() + { + this.Given(_ => GivenThereIsNoProjection()) + .When(_ => WhenWeHandleAToggleStateAddedEvent()) + .Then(_ => ThenAnExceptionIsThrown()) + .BDDfy(); + } + + [Fact] + public void Nominal() + { + this.Given(_ => GivenTheProjectionExists()) + .And(_ => GivenTheProjectAlreadyHasAToggleState()) + .When(_ => WhenWeHandleAToggleStateAddedEvent()) + .Then(_ => ThenTheNewToggleStateIsAdded()) + .And(_ => ThenTheProjectionAuditIsSet()) + .BDDfy(); + } + + protected override async Task HandleEventImplementation() + { + await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); + } + + private void GivenTheProjectAlreadyHasAToggleState() + { + OriginalProjection.EnvironmentState.AddToggleState( + DataFixture.Create(), + DataFixture.Create(), + DataFixture.Create()); + } + + private async Task WhenWeHandleAToggleStateAddedEvent() + { + Event = DataFixture.Build() + .With(pc => pc.Id, ProjectId) + .With(pc => pc.EnvironmentKey, EnvironmentKey) + .Create(); + + await WhenTheEventIsHandled(); + } + + private void ThenTheNewToggleStateIsAdded() + { + var toggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); + toggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count() + 1); + + foreach (var toggleState in OriginalProjection.EnvironmentState.ToggleStates) + { + toggleStates.Should().Contain(ts => + ts.Key == toggleState.Key && + ts.Value == toggleState.Value); + } + + toggleStates.Should().Contain(ts => + ts.Key == Event.ToggleKey && + ts.Value == Event.Value); + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateChangedSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateChangedSpecs.cs new file mode 100644 index 0000000..2dfe808 --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateChangedSpecs.cs @@ -0,0 +1,68 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents +{ + using System.Linq; + using System.Threading.Tasks; + using AutoFixture; + using Evelyn.Core.WriteModel.Project.Events; + using FluentAssertions; + using TestStack.BDDfy; + using Xunit; + + public class ToggleStateChangedSpecs : ProjectionBuilderHarness + { + [Fact] + public void ProjectionDoesNotExist() + { + this.Given(_ => GivenThereIsNoProjection()) + .When(_ => WhenWeHandleAToggleStateChangedEvent()) + .Then(_ => ThenAnExceptionIsThrown()) + .BDDfy(); + } + + [Fact] + public void Nominal() + { + this.Given(_ => GivenTheProjectionExists()) + .And(_ => GivenOurToggleStateIsOnTheProjection()) + .And(_ => GivenTheProjectionHasOtherToggleStates()) + .When(_ => WhenWeHandleAToggleStateChangedEvent()) + .Then(_ => ThenOurToggleStateIsChanged()) + .And(_ => ThenTheProjectionAuditIsSet()) + .BDDfy(); + } + + protected override async Task HandleEventImplementation() + { + await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); + } + + private async Task WhenWeHandleAToggleStateChangedEvent() + { + Event = DataFixture.Build() + .With(pc => pc.Id, ProjectId) + .With(pc => pc.EnvironmentKey, EnvironmentKey) + .With(pc => pc.ToggleKey, ToggleKey) + .Create(); + + await WhenTheEventIsHandled(); + } + + private void ThenOurToggleStateIsChanged() + { + var updatedToggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); + updatedToggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count()); + + foreach (var originalToggleState in OriginalProjection.EnvironmentState.ToggleStates) + { + var expectedToggleStateValue = + (originalToggleState.Key == Event.ToggleKey) + ? Event.Value + : originalToggleState.Value; + + updatedToggleStates.Should().Contain(ts => + ts.Key == originalToggleState.Key && + ts.Value == expectedToggleStateValue); + } + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateDeletedSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateDeletedSpecs.cs new file mode 100644 index 0000000..ee72156 --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectEvents/ToggleStateDeletedSpecs.cs @@ -0,0 +1,65 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState.ProjectEvents +{ + using System.Linq; + using System.Threading.Tasks; + using AutoFixture; + using Evelyn.Core.WriteModel.Project.Events; + using FluentAssertions; + using TestStack.BDDfy; + using Xunit; + + public class ToggleStateDeletedSpecs : ProjectionBuilderHarness + { + [Fact] + public void Nominal() + { + this.Given(_ => GivenTheProjectionExists()) + .And(_ => GivenOurToggleStateIsOnTheProjection()) + .When(_ => WhenWeHandleAToggleStateDeletedEvent()) + .Then(_ => ThenOurToggleStateIsRemoved()) + .And(_ => ThenTheProjectionAuditIsSet()) + .BDDfy(); + } + + [Fact] + public void ProjectionDoesNotExist() + { + this.Given(_ => GivenThereIsNoProjection()) + .When(_ => WhenWeHandleAToggleStateDeletedEvent()) + .Then(_ => ThenAnExceptionIsThrown()) + .BDDfy(); + } + + protected override async Task HandleEventImplementation() + { + await ProjectionBuilder.Handle(StreamPosition, Event, StoppingToken); + } + + private async Task WhenWeHandleAToggleStateDeletedEvent() + { + Event = DataFixture.Build() + .With(pc => pc.Id, ProjectId) + .With(pc => pc.EnvironmentKey, EnvironmentKey) + .With(pc => pc.ToggleKey, ToggleKey) + .Create(); + + await WhenTheEventIsHandled(); + } + + private void ThenOurToggleStateIsRemoved() + { + var updatedToggleStates = UpdatedProjection.EnvironmentState.ToggleStates.ToList(); + updatedToggleStates.Count.Should().Be(OriginalProjection.EnvironmentState.ToggleStates.Count() - 1); + + foreach (var originalToggleState in OriginalProjection.EnvironmentState.ToggleStates) + { + if (originalToggleState.Key != Event.ToggleKey) + { + updatedToggleStates.Should().Contain(ts => + ts.Key == originalToggleState.Key && + ts.Value == originalToggleState.Value); + } + } + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilderHarness.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilderHarness.cs new file mode 100644 index 0000000..a9d1720 --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilderHarness.cs @@ -0,0 +1,53 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState +{ + using System; + using AutoFixture; + using Evelyn.Core.WriteModel; + using Projections = Evelyn.Core.ReadModel.Projections; + + public abstract class ProjectionBuilderHarness : ProjectionBuilderHarness + where TEvent : Event + { + public ProjectionBuilderHarness() + { + ProjectionBuilder = new Projections.ClientEnvironmentState.ProjectionBuilder(ProjectionStore); + } + + protected Guid ProjectId { get; set; } + + protected string EnvironmentKey { get; set; } + + protected string ToggleKey { get; private set; } + + protected void GivenThereIsNoProjection() + { + ProjectId = DataFixture.Create(); + EnvironmentKey = DataFixture.Create(); + } + + protected void GivenTheProjectionExists() + { + OriginalProjection = DataFixture.Create(); + ProjectId = DataFixture.Create(); + EnvironmentKey = DataFixture.Create(); + } + + protected void GivenTheProjectionHasOtherToggleStates() + { + OriginalProjection.EnvironmentState.AddToggleState( + DataFixture.Create(), + DataFixture.Create(), + DataFixture.Create()); + } + + protected void GivenOurToggleStateIsOnTheProjection() + { + ToggleKey = DataFixture.Create(); + + OriginalProjection.EnvironmentState.AddToggleState( + DataFixture.Create(), + ToggleKey, + DataFixture.Create()); + } + } +} diff --git a/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionSpecs.cs b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionSpecs.cs new file mode 100644 index 0000000..31a8d36 --- /dev/null +++ b/src/Evelyn.Core.Tests/ReadModel/Projections/ClientEnvironmentState/ProjectionSpecs.cs @@ -0,0 +1,16 @@ +namespace Evelyn.Core.Tests.ReadModel.Projections.ClientEnvironmentState +{ + using AutoFixture; + using Xunit; + using Projections = Core.ReadModel.Projections; + + public class ProjectionSpecs : ProjectionHarness + { + [Fact] + public void Serialization() + { + var dto = DataFixture.Create(); + AssertSerializationOf(dto); + } + } +} diff --git a/src/Evelyn.Core/DependencyInjection/ConfigureEventStreamHandlerOptions.cs b/src/Evelyn.Core/DependencyInjection/ConfigureEventStreamHandlerOptions.cs index af91b7e..cdfef7e 100644 --- a/src/Evelyn.Core/DependencyInjection/ConfigureEventStreamHandlerOptions.cs +++ b/src/Evelyn.Core/DependencyInjection/ConfigureEventStreamHandlerOptions.cs @@ -14,6 +14,7 @@ public void Configure(EventStreamHandlerOptions options) typeof(Evelyn.Core.ReadModel.Projections.EnvironmentState.ProjectionBuilder), typeof(Evelyn.Core.ReadModel.Projections.ProjectDetails.ProjectionBuilder), typeof(Evelyn.Core.ReadModel.Projections.ToggleDetails.ProjectionBuilder), + typeof(Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.ProjectionBuilder), }); } } diff --git a/src/Evelyn.Core/DependencyInjection/InProcessHandlers.cs b/src/Evelyn.Core/DependencyInjection/InProcessHandlers.cs index b76ecc4..6b131c5 100644 --- a/src/Evelyn.Core/DependencyInjection/InProcessHandlers.cs +++ b/src/Evelyn.Core/DependencyInjection/InProcessHandlers.cs @@ -31,6 +31,7 @@ public static void SynchronouslyInProcess(this EventPublisherOptions parentOptio parentOptions.Services.TryAddSingleton(); parentOptions.Services.TryAddSingleton(); parentOptions.Services.TryAddSingleton(); + parentOptions.Services.TryAddSingleton(); } } } diff --git a/src/Evelyn.Core/ReadModel/DatabaseReadModelFacade.cs b/src/Evelyn.Core/ReadModel/DatabaseReadModelFacade.cs index 6c3c9d9..2e568b7 100644 --- a/src/Evelyn.Core/ReadModel/DatabaseReadModelFacade.cs +++ b/src/Evelyn.Core/ReadModel/DatabaseReadModelFacade.cs @@ -16,18 +16,22 @@ public class DatabaseReadModelFacade : IReadModelFacade private readonly IProjectionStore _environmentStates; + private readonly IProjectionStore _clientEnvironmentStates; + public DatabaseReadModelFacade( IProjectionStore accountProjects, IProjectionStore projectDetails, IProjectionStore environmentDetails, IProjectionStore toggleDetails, - IProjectionStore environmentStates) + IProjectionStore environmentStates, + IProjectionStore clientEnvironmentStates) { _accountProjects = accountProjects; _projectDetails = projectDetails; _environmentDetails = environmentDetails; _toggleDetails = toggleDetails; _environmentStates = environmentStates; + _clientEnvironmentStates = clientEnvironmentStates; } public async Task GetProjects(Guid accountId) @@ -54,5 +58,10 @@ public DatabaseReadModelFacade( { return await _environmentStates.Get(Projections.EnvironmentState.Projection.StoreKey(projectId, environmentName)); } + + public async Task GetClientEnvironmentState(Guid projectId, string environmentName) + { + return await _clientEnvironmentStates.Get(Projections.ClientEnvironmentState.Projection.StoreKey(projectId, environmentName)); + } } } diff --git a/src/Evelyn.Core/ReadModel/IReadModelFacade.cs b/src/Evelyn.Core/ReadModel/IReadModelFacade.cs index 0b2a645..c591f9f 100644 --- a/src/Evelyn.Core/ReadModel/IReadModelFacade.cs +++ b/src/Evelyn.Core/ReadModel/IReadModelFacade.cs @@ -14,5 +14,7 @@ public interface IReadModelFacade Task GetToggleDetails(Guid projectId, string toggleKey); Task GetEnvironmentState(Guid projectId, string environmentName); + + Task GetClientEnvironmentState(Guid projectId, string environmentName); } } diff --git a/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/EnvironmentState.cs b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/EnvironmentState.cs new file mode 100644 index 0000000..7991715 --- /dev/null +++ b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/EnvironmentState.cs @@ -0,0 +1,42 @@ +namespace Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model +{ + using System.Collections.Generic; + using System.Linq; + using Newtonsoft.Json; + + public class EnvironmentState + { + private readonly List _toggleStates; + + [JsonConstructor] + private EnvironmentState(IEnumerable toggleStates) + { + _toggleStates = toggleStates.ToList(); + } + + public IEnumerable ToggleStates => _toggleStates; + + public static EnvironmentState Create(EventAudit eventAudit, IEnumerable toggleStates) + { + return new EnvironmentState(toggleStates ?? new List()); + } + + public void AddToggleState(EventAudit eventAudit, string toggleKey, string toggleValue) + { + var toggleState = ToggleState.Create(toggleKey, toggleValue); + _toggleStates.Add(toggleState); + } + + public void ChangeToggleState(EventAudit eventAudit, string toggleKey, string value) + { + var toggleState = _toggleStates.Find(ts => ts.Key == toggleKey); + toggleState.ChangeState(value, eventAudit.EventVersion); + } + + public void DeleteToggleState(EventAudit eventAudit, string toggleKey) + { + var toggleState = _toggleStates.Find(ts => ts.Key == toggleKey); + _toggleStates.Remove(toggleState); + } + } +} diff --git a/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/ToggleState.cs b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/ToggleState.cs new file mode 100644 index 0000000..3661d20 --- /dev/null +++ b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Model/ToggleState.cs @@ -0,0 +1,28 @@ +namespace Evelyn.Core.ReadModel.Projections.ClientEnvironmentState.Model +{ + using Newtonsoft.Json; + + public class ToggleState + { + [JsonConstructor] + private ToggleState(string key, string value) + { + Key = key; + Value = value; + } + + public string Key { get; private set; } + + public string Value { get; private set; } + + public static ToggleState Create(string key, string value) + { + return new ToggleState(key, value); + } + + public void ChangeState(string value, long version) + { + Value = value; + } + } +} diff --git a/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Projection.cs b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Projection.cs new file mode 100644 index 0000000..a53c574 --- /dev/null +++ b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/Projection.cs @@ -0,0 +1,27 @@ +namespace Evelyn.Core.ReadModel.Projections.ClientEnvironmentState +{ + using System; + using Newtonsoft.Json; + + public class Projection : Projections.Projection + { + [JsonConstructor] + private Projection(ProjectionAudit audit, Model.EnvironmentState environmentState) + : base(audit) + { + EnvironmentState = environmentState; + } + + public Model.EnvironmentState EnvironmentState { get; set; } + + public static Projection Create(EventAudit eventAudit, Model.EnvironmentState environmentState) + { + return new Projection(ProjectionAudit.Create(eventAudit), environmentState); + } + + public static string StoreKey(Guid projectId, string environmentKey) + { + return $"{nameof(ClientEnvironmentState)}-{projectId}-{environmentKey}"; + } + } +} diff --git a/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilder.cs b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilder.cs new file mode 100644 index 0000000..3baf395 --- /dev/null +++ b/src/Evelyn.Core/ReadModel/Projections/ClientEnvironmentState/ProjectionBuilder.cs @@ -0,0 +1,75 @@ +namespace Evelyn.Core.ReadModel.Projections.ClientEnvironmentState +{ + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using ProjectEvents = WriteModel.Project.Events; + + public class ProjectionBuilder : ProjectionBuilder, + IBuildProjectionsFrom, + IBuildProjectionsFrom, + IBuildProjectionsFrom, + IBuildProjectionsFrom, + IBuildProjectionsFrom + { + public ProjectionBuilder(IProjectionStore projectionStore) + : base(projectionStore) + { + } + + public async Task Handle(long streamPosition, ProjectEvents.EnvironmentStateAdded @event, CancellationToken stoppingToken) + { + var eventAudit = CreateEventAudit(streamPosition, @event); + var storeKey = Projection.StoreKey(@event.Id, @event.EnvironmentKey); + + var toggleStates = @event.ToggleStates.Select(ts => Model.ToggleState.Create(ts.Key, ts.Value)); + var environmentState = Model.EnvironmentState.Create(eventAudit, toggleStates); + + var projection = Projection.Create(eventAudit, environmentState); + await Projections.Create(storeKey, projection).ConfigureAwait(false); + } + + public async Task Handle(long streamPosition, ProjectEvents.EnvironmentStateDeleted @event, CancellationToken stoppingToken) + { + var storeKey = Projection.StoreKey(@event.Id, @event.EnvironmentKey); + + await Projections.Delete(storeKey).ConfigureAwait(false); + } + + public async Task Handle(long streamPosition, ProjectEvents.ToggleStateAdded @event, CancellationToken stoppingToken) + { + var eventAudit = CreateEventAudit(streamPosition, @event); + var storeKey = Projection.StoreKey(@event.Id, @event.EnvironmentKey); + var environmentState = (await Projections.Get(storeKey).ConfigureAwait(false)).EnvironmentState; + + environmentState.AddToggleState(eventAudit, @event.ToggleKey, @event.Value); + + var projection = Projection.Create(eventAudit, environmentState); + await Projections.Update(storeKey, projection).ConfigureAwait(false); + } + + public async Task Handle(long streamPosition, ProjectEvents.ToggleStateChanged @event, CancellationToken stoppingToken) + { + var eventAudit = CreateEventAudit(streamPosition, @event); + var storeKey = Projection.StoreKey(@event.Id, @event.EnvironmentKey); + var environmentState = (await Projections.Get(storeKey).ConfigureAwait(false)).EnvironmentState; + + environmentState.ChangeToggleState(CreateEventAudit(streamPosition, @event), @event.ToggleKey, @event.Value); + + var projection = Projection.Create(eventAudit, environmentState); + await Projections.Update(storeKey, projection).ConfigureAwait(false); + } + + public async Task Handle(long streamPosition, ProjectEvents.ToggleStateDeleted @event, CancellationToken stoppingToken) + { + var eventAudit = CreateEventAudit(streamPosition, @event); + var storeKey = Projection.StoreKey(@event.Id, @event.EnvironmentKey); + var environmentState = (await Projections.Get(storeKey).ConfigureAwait(false)).EnvironmentState; + + environmentState.DeleteToggleState(CreateEventAudit(streamPosition, @event), @event.ToggleKey); + + var projection = Projection.Create(eventAudit, environmentState); + await Projections.Update(storeKey, projection).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/Evelyn.Management.Api.Rest.IntegrationTests/Properties/launchSettings.json b/src/Evelyn.Management.Api.Rest.IntegrationTests/Properties/launchSettings.json new file mode 100644 index 0000000..61f7d48 --- /dev/null +++ b/src/Evelyn.Management.Api.Rest.IntegrationTests/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:49945/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Evelyn.Management.Api.Rest.IntegrationTests": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:49949/" + } + } +} \ No newline at end of file diff --git a/src/Evelyn.Management.Api.Rest.IntegrationTests/SmokeTest.cs b/src/Evelyn.Management.Api.Rest.IntegrationTests/SmokeTest.cs index 9e04a03..0194746 100644 --- a/src/Evelyn.Management.Api.Rest.IntegrationTests/SmokeTest.cs +++ b/src/Evelyn.Management.Api.Rest.IntegrationTests/SmokeTest.cs @@ -95,7 +95,7 @@ private async Task GivenWeWaitUntilEverythingIsInitialised() await policy.ExecuteAsync(async () => { var response = await Client - .Request("/api/projects") + .Request("/management-api/projects") .GetAsync().ConfigureAwait(false); response.StatusCode.Should().Be(HttpStatusCode.OK); @@ -111,7 +111,7 @@ private async Task GivenweWaitAFewSecondsForEventualConsistency() private async Task WhenGetProjects() { _response = await Client - .Request("/api/projects") + .Request("/management-api/projects") .GetAsync().ConfigureAwait(false); _responseContent = await _response.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -122,7 +122,7 @@ private async Task WhenWeAddAProject() _createProjectMessage = DataFixture.Create(); _response = await Client - .Request("/api/projects/create") + .Request("/management-api/projects/create") .PostJsonAsync(_createProjectMessage).ConfigureAwait(false); _responseContent = await _response.Content.ReadAsStringAsync().ConfigureAwait(false); @@ -136,7 +136,7 @@ private async Task WhenWeAddAnEnvironment() .Create(); _response = await Client - .Request($"/api/projects/{_createProjectMessage.ProjectId}/environments/add") + .Request($"/management-api/projects/{_createProjectMessage.ProjectId}/environments/add") .PostJsonAsync(_addEnvironmentMessage); _responseContent = await _response.Content.ReadAsStringAsync(); @@ -150,7 +150,7 @@ private async Task WhenWeAddAToggle() .Create(); _response = await Client - .Request($"/api/projects/{_createProjectMessage.ProjectId}/toggles/add") + .Request($"/management-api/projects/{_createProjectMessage.ProjectId}/toggles/add") .PostJsonAsync(_addToggleMessage); _responseContent = await _response.Content.ReadAsStringAsync(); @@ -159,7 +159,7 @@ private async Task WhenWeAddAToggle() private async Task WhenWeGetTheDetailsForTheProjectWeAdded() { _response = await Client - .Request($"/api/projects/{_createProjectMessage.ProjectId}") + .Request($"/management-api/projects/{_createProjectMessage.ProjectId}") .GetAsync(); _responseContent = await _response.Content.ReadAsStringAsync(); @@ -168,7 +168,7 @@ private async Task WhenWeGetTheDetailsForTheProjectWeAdded() private async Task WhenWeGetTheDetailsForTheEnvironmentWeAdded() { _response = await Client - .Request($"/api/projects/{_createProjectMessage.ProjectId}/environments/{_addEnvironmentMessage.Key}") + .Request($"/management-api/projects/{_createProjectMessage.ProjectId}/environments/{_addEnvironmentMessage.Key}") .GetAsync(); _responseContent = await _response.Content.ReadAsStringAsync(); @@ -177,7 +177,7 @@ private async Task WhenWeGetTheDetailsForTheEnvironmentWeAdded() private async Task WhenWeGetTheDetailsForTheToggleWeAdded() { _response = await Client - .Request($"/api/projects/{_createProjectMessage.ProjectId}/toggles/{_addToggleMessage.Key}") + .Request($"/management-api/projects/{_createProjectMessage.ProjectId}/toggles/{_addToggleMessage.Key}") .GetAsync(); _responseContent = await _response.Content.ReadAsStringAsync(); @@ -186,7 +186,7 @@ private async Task WhenWeGetTheDetailsForTheToggleWeAdded() private async Task WhenWeGetTheStateForTheEnvironmentWeAdded() { _response = await Client - .Request($"/api/states/{_createProjectMessage.ProjectId}/{_addEnvironmentMessage.Key}") + .Request($"/management-api/states/{_createProjectMessage.ProjectId}/{_addEnvironmentMessage.Key}") .GetAsync(); _responseContent = await _response.Content.ReadAsStringAsync(); diff --git a/src/Evelyn.Management.Api.Rest.Tests/Read/ClientEnvironmentStatesControllerSpecs.cs b/src/Evelyn.Management.Api.Rest.Tests/Read/ClientEnvironmentStatesControllerSpecs.cs new file mode 100644 index 0000000..0178cf9 --- /dev/null +++ b/src/Evelyn.Management.Api.Rest.Tests/Read/ClientEnvironmentStatesControllerSpecs.cs @@ -0,0 +1,118 @@ +namespace Evelyn.Management.Api.Rest.Tests.Read +{ + using System; + using System.Threading.Tasks; + using AutoFixture; + using Core.ReadModel; + using Core.ReadModel.Projections.ClientEnvironmentState; + using FluentAssertions; + using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Mvc; + using NSubstitute; + using NSubstitute.ExceptionExtensions; + using Rest.Read; + using TestStack.BDDfy; + using Xunit; + + public class ClientEnvironmentStatesControllerSpecs + { + private readonly Fixture _fixture; + private readonly IReadModelFacade _readModelFacade; + private readonly ClientEnvironmentStatesController _controller; + private readonly Guid _projectId; + + private Projection _clientEnvironmentStateReturnedByFacade; + private string _keyOfEnvironmentStateToGet; + private ObjectResult _result; + + public ClientEnvironmentStatesControllerSpecs() + { + _fixture = new Fixture(); + _readModelFacade = Substitute.For(); + _controller = new ClientEnvironmentStatesController(_readModelFacade); + _projectId = _fixture.Create(); + } + + [Fact] + public void GetsEnvironmentState() + { + this.Given(_ => GivenTheEnvironmentStateWeWantDoesExist()) + .When(_ => WhenWeGetTheEnvironmentState()) + .Then(_ => ThenStatusCode200IsReturned()) + .And(_ => ThenTheExpectedEnvironmentStateIsReturned()) + .BDDfy(); + } + + [Fact] + public void EnvironmentNotFound() + { + this.Given(_ => GivenTheEnvironmentStateWeWantDoesntExist()) + .When(_ => WhenWeGetTheEnvironmentState()) + .Then(_ => ThenStatusCode404IsReturned()) + .BDDfy(); + } + + [Fact] + public void ExceptionWhenGettingEnvironment() + { + this.Given(_ => GivenThatAnExceptionIsThrownWhenGettingEnvironmentState()) + .When(_ => WhenWeGetTheEnvironmentState()) + .Then(_ => ThenStatusCode500IsReturned()) + .BDDfy(); + } + + private void GivenTheEnvironmentStateWeWantDoesExist() + { + _clientEnvironmentStateReturnedByFacade = _fixture.Create(); + _keyOfEnvironmentStateToGet = _fixture.Create(); + + _readModelFacade + .GetClientEnvironmentState(_projectId, _keyOfEnvironmentStateToGet) + .Returns(_clientEnvironmentStateReturnedByFacade); + } + + private void GivenTheEnvironmentStateWeWantDoesntExist() + { + _keyOfEnvironmentStateToGet = _fixture.Create(); + + _readModelFacade + .GetClientEnvironmentState(_projectId, _keyOfEnvironmentStateToGet) + .Throws(_fixture.Create()); + } + + private void GivenThatAnExceptionIsThrownWhenGettingEnvironmentState() + { + _keyOfEnvironmentStateToGet = _fixture.Create(); + + _readModelFacade + .GetClientEnvironmentState(_projectId, _keyOfEnvironmentStateToGet) + .Throws(_fixture.Create()); + } + + private async Task WhenWeGetTheEnvironmentState() + { + _result = await _controller.Get(_projectId, _keyOfEnvironmentStateToGet); + } + + private void ThenStatusCode200IsReturned() + { + _result.StatusCode.Should().Be(StatusCodes.Status200OK); + } + + private void ThenStatusCode404IsReturned() + { + _result.StatusCode.Should().Be(StatusCodes.Status404NotFound); + } + + private void ThenStatusCode500IsReturned() + { + _result.StatusCode.Should().Be(StatusCodes.Status500InternalServerError); + } + + private void ThenTheExpectedEnvironmentStateIsReturned() + { + var returnedEnvironmentState = _result.Value as Projection; + returnedEnvironmentState.Should().Be(_clientEnvironmentStateReturnedByFacade); + } + } +} diff --git a/src/Evelyn.Management.Api.Rest/DependencyInjection/EvelynApi.cs b/src/Evelyn.Management.Api.Rest/DependencyInjection/EvelynApi.cs index e494b03..f5070f3 100644 --- a/src/Evelyn.Management.Api.Rest/DependencyInjection/EvelynApi.cs +++ b/src/Evelyn.Management.Api.Rest/DependencyInjection/EvelynApi.cs @@ -17,16 +17,24 @@ public static IServiceCollection AddEvelynApi(this IServiceCollection services, #pragma warning restore SA1616 // Element return value documentation must have text #pragma warning restore SA1614 // Element parameter documentation must have text { - var swaggerInfo = new Swashbuckle.AspNetCore.Swagger.Info() + var managementApiInfo = new Swashbuckle.AspNetCore.Swagger.Info() { Version = "v0.1", Title = "Evelyn Management API", Description = "Management API for Evelyn", }; + var clientApiInfo = new Swashbuckle.AspNetCore.Swagger.Info() + { + Version = "client-api", + Title = "Evelyn Client API", + Description = "Client API for Evelyn", + }; + services.AddSwaggerGen(config => { - config.SwaggerDoc("v0.1", swaggerInfo); + config.SwaggerDoc("management-api", managementApiInfo); + config.SwaggerDoc("client-api", clientApiInfo); config.CustomSchemaIds(type => type.FullName); }); diff --git a/src/Evelyn.Management.Api.Rest/Read/ClientEnvironmentStatesController.cs b/src/Evelyn.Management.Api.Rest/Read/ClientEnvironmentStatesController.cs new file mode 100644 index 0000000..1a7fcb9 --- /dev/null +++ b/src/Evelyn.Management.Api.Rest/Read/ClientEnvironmentStatesController.cs @@ -0,0 +1,43 @@ +namespace Evelyn.Management.Api.Rest.Read +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using Core.ReadModel.Projections.ClientEnvironmentState; + using Evelyn.Core.ReadModel; + using Microsoft.AspNetCore.Http; + using Microsoft.AspNetCore.Mvc; + + [Route("client-api/projects/{projectId}/environments/{environmentName}/state")] + [ProducesResponseType(typeof(IDictionary), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "client-api")] + public class ClientEnvironmentStatesController : Controller + { + private readonly IReadModelFacade _readModelFacade; + + public ClientEnvironmentStatesController(IReadModelFacade readModelFacade) + { + _readModelFacade = readModelFacade; + } + + [HttpGet] + [ProducesResponseType(typeof(Projection), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IDictionary), StatusCodes.Status404NotFound)] + public async Task Get(Guid projectId, string environmentName) + { + try + { + var result = await _readModelFacade.GetClientEnvironmentState(projectId, environmentName); + return Ok(result); + } + catch (ProjectionNotFoundException) + { + return NotFound(null); + } + catch (Exception) + { + return new ObjectResult(null) { StatusCode = StatusCodes.Status500InternalServerError }; + } + } + } +} diff --git a/src/Evelyn.Management.Api.Rest/Read/EnvironmentStatesController.cs b/src/Evelyn.Management.Api.Rest/Read/EnvironmentStatesController.cs index d796dd0..88f8b98 100644 --- a/src/Evelyn.Management.Api.Rest/Read/EnvironmentStatesController.cs +++ b/src/Evelyn.Management.Api.Rest/Read/EnvironmentStatesController.cs @@ -8,8 +8,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; - [Route("api/states/{projectId}/{environmentName}")] + [Route("management-api/states/{projectId}/{environmentName}")] [ProducesResponseType(typeof(IDictionary), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class EnvironmentStatesController : Controller { private readonly IReadModelFacade _readModelFacade; diff --git a/src/Evelyn.Management.Api.Rest/Read/EnvironmentsController.cs b/src/Evelyn.Management.Api.Rest/Read/EnvironmentsController.cs index a9a4517..3b5762b 100644 --- a/src/Evelyn.Management.Api.Rest/Read/EnvironmentsController.cs +++ b/src/Evelyn.Management.Api.Rest/Read/EnvironmentsController.cs @@ -8,8 +8,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; - [Route("api/projects/{projectId}/environments")] + [Route("management-api/projects/{projectId}/environments")] [ProducesResponseType(typeof(IDictionary), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class EnvironmentsController : Controller { private readonly IReadModelFacade _readModelFacade; diff --git a/src/Evelyn.Management.Api.Rest/Read/ProjectsController.cs b/src/Evelyn.Management.Api.Rest/Read/ProjectsController.cs index 0a2ed3c..3d7c97f 100644 --- a/src/Evelyn.Management.Api.Rest/Read/ProjectsController.cs +++ b/src/Evelyn.Management.Api.Rest/Read/ProjectsController.cs @@ -10,8 +10,9 @@ using Microsoft.Extensions.Logging; using Write; - [Route("api/projects")] + [Route("management-api/projects")] [ProducesResponseType(typeof(IDictionary), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class ProjectsController : EvelynController { private readonly IReadModelFacade _readModelFacade; diff --git a/src/Evelyn.Management.Api.Rest/Read/TogglesController.cs b/src/Evelyn.Management.Api.Rest/Read/TogglesController.cs index aca4c10..b42fb24 100644 --- a/src/Evelyn.Management.Api.Rest/Read/TogglesController.cs +++ b/src/Evelyn.Management.Api.Rest/Read/TogglesController.cs @@ -8,8 +8,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; - [Route("api/projects/{projectId}/toggles")] + [Route("management-api/projects/{projectId}/toggles")] [ProducesResponseType(typeof(IDictionary), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class TogglesController : Controller { private readonly IReadModelFacade _readModelFacade; diff --git a/src/Evelyn.Management.Api.Rest/Write/Environments/Controller.cs b/src/Evelyn.Management.Api.Rest/Write/Environments/Controller.cs index 34e68bd..c38642f 100644 --- a/src/Evelyn.Management.Api.Rest/Write/Environments/Controller.cs +++ b/src/Evelyn.Management.Api.Rest/Write/Environments/Controller.cs @@ -10,11 +10,12 @@ using Microsoft.Extensions.Logging; using Responses; - [Route("api/projects/{projectId}/environments")] + [Route("management-api/projects/{projectId}/environments")] [ProducesResponseType(StatusCodes.Status202Accepted)] [ProducesResponseType(typeof(ValidationErrorResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class Controller : EvelynController { private readonly ICommandHandler _addHandler; @@ -53,6 +54,7 @@ public async Task Post(Guid projectId, [FromBody]Messages.AddEnvir [Route("{environmentKey}/delete")] [HttpPost] + [ApiExplorerSettings(GroupName = "management-api")] public async Task Post(Guid projectId, string environmentKey, [FromBody]Messages.DeleteEnvironment message) { try diff --git a/src/Evelyn.Management.Api.Rest/Write/Projects/Controller.cs b/src/Evelyn.Management.Api.Rest/Write/Projects/Controller.cs index c93b55a..53b5c06 100644 --- a/src/Evelyn.Management.Api.Rest/Write/Projects/Controller.cs +++ b/src/Evelyn.Management.Api.Rest/Write/Projects/Controller.cs @@ -10,11 +10,12 @@ using Microsoft.Extensions.Logging; using Responses; - [Route("api/projects")] + [Route("management-api/projects")] [ProducesResponseType(StatusCodes.Status202Accepted)] [ProducesResponseType(typeof(ValidationErrorResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class Controller : EvelynController { private readonly ICommandHandler _createHandler; diff --git a/src/Evelyn.Management.Api.Rest/Write/ToggleStates/Controller.cs b/src/Evelyn.Management.Api.Rest/Write/ToggleStates/Controller.cs index 00ae225..d4c2b3c 100644 --- a/src/Evelyn.Management.Api.Rest/Write/ToggleStates/Controller.cs +++ b/src/Evelyn.Management.Api.Rest/Write/ToggleStates/Controller.cs @@ -10,11 +10,12 @@ using Microsoft.Extensions.Logging; using Responses; - [Route("api/projects/{projectId}/environments/{environmentKey}/toggles/{toggleKey}")] + [Route("management-api/projects/{projectId}/environments/{environmentKey}/toggles/{toggleKey}")] [ProducesResponseType(StatusCodes.Status202Accepted)] [ProducesResponseType(typeof(ValidationErrorResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class Controller : EvelynController { private readonly ICommandHandler _handler; diff --git a/src/Evelyn.Management.Api.Rest/Write/Toggles/Controller.cs b/src/Evelyn.Management.Api.Rest/Write/Toggles/Controller.cs index dac79bc..5a6e9a4 100644 --- a/src/Evelyn.Management.Api.Rest/Write/Toggles/Controller.cs +++ b/src/Evelyn.Management.Api.Rest/Write/Toggles/Controller.cs @@ -10,11 +10,12 @@ using Microsoft.Extensions.Logging; using Responses; - [Route("api/projects/{projectId}/toggles")] + [Route("management-api/projects/{projectId}/toggles")] [ProducesResponseType(StatusCodes.Status202Accepted)] [ProducesResponseType(typeof(ValidationErrorResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status500InternalServerError)] + [ApiExplorerSettings(GroupName = "management-api")] public class Controller : EvelynController { private readonly ICommandHandler _addToggleHandler; diff --git a/src/Evelyn.Server.Host/Startup.cs b/src/Evelyn.Server.Host/Startup.cs index 4e2c325..3edfaea 100644 --- a/src/Evelyn.Server.Host/Startup.cs +++ b/src/Evelyn.Server.Host/Startup.cs @@ -70,7 +70,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IStartUp app.UseEvelynApi(startUpCommands); app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v0.1/swagger.json", "Evelyn Management API")); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/management-api/swagger.json", "Evelyn Management API"); + c.SwaggerEndpoint("/swagger/client-api/swagger.json", "Evelyn Client API"); + }); } } }