Skip to content

Commit f79aaa9

Browse files
Use string filter for status/health to simplify API
1 parent ca70993 commit f79aaa9

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/Certify.Server/Certify.Server.Hub.Api.Client/Certify.Server.Hub.Api.Client.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//----------------------
1+
//----------------------
22
// <auto-generated>
33
// Generated using the NSwag toolchain v14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
44
// </auto-generated>
@@ -12,7 +12,7 @@
1212
using Certify.Models.Hub;
1313
using Certify.Models.Config.Migration;
1414
using Certify.Shared;
15-
using ProblemDetails = Certify.Models.Util.ProblemDetails;
15+
using ProblemDetails=Certify.Models.Util.ProblemDetails;
1616

1717
#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
1818
#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
@@ -35,19 +35,19 @@ namespace Certify.Server.Hub.Api
3535
using System = global::System;
3636

3737
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
38-
public partial class Client
38+
public partial class Client
3939
{
40-
#pragma warning disable 8618
40+
#pragma warning disable 8618
4141
private string _baseUrl;
42-
#pragma warning restore 8618
42+
#pragma warning restore 8618
4343

4444
private System.Net.Http.HttpClient _httpClient;
4545
private static System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings, true);
4646
private Newtonsoft.Json.JsonSerializerSettings _instanceSettings;
4747

48-
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
48+
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
4949
public Client(string baseUrl, System.Net.Http.HttpClient httpClient)
50-
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
50+
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
5151
{
5252
BaseUrl = baseUrl;
5353
_httpClient = httpClient;
@@ -3634,7 +3634,7 @@ public virtual async System.Threading.Tasks.Task<ActionResult> RemoveAcmeAccount
36343634
/// </summary>
36353635
/// <returns>OK</returns>
36363636
/// <exception cref="ApiException">A server side error occurred.</exception>
3637-
public virtual System.Threading.Tasks.Task<ManagedCertificateSummaryResult> GetHubManagedItemsAsync(string instanceId, string keyword, ManagedCertificateHealth? health, int? page, int? pageSize)
3637+
public virtual System.Threading.Tasks.Task<ManagedCertificateSummaryResult> GetHubManagedItemsAsync(string instanceId, string keyword, string health, int? page, int? pageSize)
36383638
{
36393639
return GetHubManagedItemsAsync(instanceId, keyword, health, page, pageSize, System.Threading.CancellationToken.None);
36403640
}
@@ -3645,7 +3645,7 @@ public virtual System.Threading.Tasks.Task<ManagedCertificateSummaryResult> GetH
36453645
/// </summary>
36463646
/// <returns>OK</returns>
36473647
/// <exception cref="ApiException">A server side error occurred.</exception>
3648-
public virtual async System.Threading.Tasks.Task<ManagedCertificateSummaryResult> GetHubManagedItemsAsync(string instanceId, string keyword, ManagedCertificateHealth? health, int? page, int? pageSize, System.Threading.CancellationToken cancellationToken)
3648+
public virtual async System.Threading.Tasks.Task<ManagedCertificateSummaryResult> GetHubManagedItemsAsync(string instanceId, string keyword, string health, int? page, int? pageSize, System.Threading.CancellationToken cancellationToken)
36493649
{
36503650
var client_ = _httpClient;
36513651
var disposeClient_ = false;
@@ -6716,7 +6716,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
67166716
var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name);
67176717
if (field != null)
67186718
{
6719-
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
6719+
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
67206720
as System.Runtime.Serialization.EnumMemberAttribute;
67216721
if (attribute != null)
67226722
{
@@ -6728,13 +6728,13 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
67286728
return converted == null ? string.Empty : converted;
67296729
}
67306730
}
6731-
else if (value is bool)
6731+
else if (value is bool)
67326732
{
67336733
return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant();
67346734
}
67356735
else if (value is byte[])
67366736
{
6737-
return System.Convert.ToBase64String((byte[])value);
6737+
return System.Convert.ToBase64String((byte[]) value);
67386738
}
67396739
else if (value is string[])
67406740
{
@@ -6756,7 +6756,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
67566756
}
67576757
}
67586758

6759-
6759+
67606760

67616761
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0))")]
67626762
public partial class FileResponse : System.IDisposable
@@ -6844,4 +6844,4 @@ public ApiException(string message, int statusCode, string response, System.Coll
68446844
#pragma warning restore 8602
68456845
#pragma warning restore 8603
68466846
#pragma warning restore 8604
6847-
#pragma warning restore 8625
6847+
#pragma warning restore 8625

src/Certify.Server/Certify.Server.Hub.Api/Controllers/internal/HubController.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public HubController(ILogger<CertificateController> logger, ICertifyInternalApiC
5151
[Route("items")]
5252
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
5353
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ManagedCertificateSummaryResult))]
54-
public async Task<IActionResult> GetHubManagedItems(string? instanceId, string? keyword, Models.ManagedCertificateHealth? health = null, int? page = null, int? pageSize = null)
54+
public async Task<IActionResult> GetHubManagedItems(string? instanceId, string? keyword, string? health = null, int? page = null, int? pageSize = null)
5555
{
5656
var result = new ManagedCertificateSummaryResult();
5757

@@ -60,14 +60,24 @@ public async Task<IActionResult> GetHubManagedItems(string? instanceId, string?
6060

6161
var list = new List<ManagedCertificateSummary>();
6262

63+
ManagedCertificateHealth? healthFilter = null;
64+
65+
if (!string.IsNullOrEmpty(health))
66+
{
67+
if (Enum.TryParse(health, true, out ManagedCertificateHealth healthValue))
68+
{
69+
healthFilter = healthValue;
70+
}
71+
}
72+
6373
foreach (var remote in managedItems.Values)
6474
{
6575
if (string.IsNullOrEmpty(instanceId) || (instanceId == remote.InstanceId))
6676
{
6777
list.AddRange(
6878
remote.Items
6979
.Where(i => string.IsNullOrWhiteSpace(keyword) || (!string.IsNullOrWhiteSpace(keyword) && i.Name?.Contains(keyword, StringComparison.InvariantCultureIgnoreCase) == true))
70-
.Where(i => health == null || (health != null && i.Health == health))
80+
.Where(i => healthFilter == null || (healthFilter != null && i.Health == healthFilter))
7181
.Select(i =>
7282
{
7383
var instance = instances.FirstOrDefault(i => i.InstanceId == remote.InstanceId);

0 commit comments

Comments
 (0)