feat!(certificates): expose full /certificates/search filter surface on Get/Search-InfisicalCertificate

Get-InfisicalCertificate and Search-InfisicalCertificate now expose every
filter accepted by POST /api/v1/projects/{projectId}/certificates/search:

ADDED parameters (both cmdlets)
- -Search                 free-text search across SAN/CN/cert id/serial
- -ProfileId              profile id array filter (Get- only previously missing)
- -ApplicationId          single application id (new on both)
- -ApplicationIds         application id array (renamed from old -ApplicationId)
- -EnrollmentType         api|est|acme|scep filter
- -ExtendedKeyUsage       e.g. codeSigning, serverAuth
- -KeyAlgorithm           e.g. RSA_2048, EC_prime256v1 (string[])
- -SignatureAlgorithm     e.g. RSA-SHA256, ECDSA-SHA256
- -KeySize                int[] key sizes in bits (e.g. 2048,4096)
- -Source                 issued|discovered|imported
- -FromDate / -ToDate     created-at window
- -NotAfterFrom/-NotAfterTo/-NotBeforeFrom/-NotBeforeTo
- -Metadata <Hashtable>   serialized as [{key,value}] entries
- -ForPkiSync             switch -> forPkiSync=true
- -SortBy                 ValidateSet: notAfter, notBefore, createdAt,
                           commonName, keyAlgorithm, status
- -SortOrder              ValidateSet: asc, desc

INTERNAL
- InfisicalCertificateSearchQuery gains ApplicationId, KeySizes, Metadata.
- InfisicalCertificateSearchRequestDto gains applicationId, keySizes,
  metadata (new InfisicalCertificateSearchMetadataEntryDto with key/value).
- BuildSearchRequest maps the new fields; BuildMetadataEntries converts
  Dictionary<string,string> into the API's [{key,value}] array shape.

BREAKING
- Search-InfisicalCertificate's -ApplicationId changed from string[] to
  string. Callers passing an array must switch to -ApplicationIds.

TESTS
- PkiEndpointRegistryTests.GetInfisicalCertificate_Cmdlet_Exposes_List_Filter_Properties
  extended to assert all 27 List-set parameters are present.
- 216/216 tests passing.
This commit is contained in:
GraceSolutions
2026-06-04 22:04:31 -04:00
parent 56be777095
commit bdec5aa6ec
6 changed files with 142 additions and 3 deletions
@@ -61,7 +61,28 @@ namespace PSInfisicalAPI.Tests
Type cmdletType = ModuleAssembly.GetType("PSInfisicalAPI.Cmdlets.GetInfisicalCertificateCmdlet", true); Type cmdletType = ModuleAssembly.GetType("PSInfisicalAPI.Cmdlets.GetInfisicalCertificateCmdlet", true);
Assert.NotNull(cmdletType.GetProperty("CommonName")); Assert.NotNull(cmdletType.GetProperty("CommonName"));
Assert.NotNull(cmdletType.GetProperty("FriendlyName")); Assert.NotNull(cmdletType.GetProperty("FriendlyName"));
Assert.NotNull(cmdletType.GetProperty("Search"));
Assert.NotNull(cmdletType.GetProperty("Status"));
Assert.NotNull(cmdletType.GetProperty("CaId")); Assert.NotNull(cmdletType.GetProperty("CaId"));
Assert.NotNull(cmdletType.GetProperty("ProfileId"));
Assert.NotNull(cmdletType.GetProperty("ApplicationId"));
Assert.NotNull(cmdletType.GetProperty("ApplicationIds"));
Assert.NotNull(cmdletType.GetProperty("EnrollmentType"));
Assert.NotNull(cmdletType.GetProperty("ExtendedKeyUsage"));
Assert.NotNull(cmdletType.GetProperty("KeyAlgorithm"));
Assert.NotNull(cmdletType.GetProperty("SignatureAlgorithm"));
Assert.NotNull(cmdletType.GetProperty("KeySize"));
Assert.NotNull(cmdletType.GetProperty("Source"));
Assert.NotNull(cmdletType.GetProperty("FromDate"));
Assert.NotNull(cmdletType.GetProperty("ToDate"));
Assert.NotNull(cmdletType.GetProperty("NotAfterFrom"));
Assert.NotNull(cmdletType.GetProperty("NotAfterTo"));
Assert.NotNull(cmdletType.GetProperty("NotBeforeFrom"));
Assert.NotNull(cmdletType.GetProperty("NotBeforeTo"));
Assert.NotNull(cmdletType.GetProperty("Metadata"));
Assert.NotNull(cmdletType.GetProperty("ForPkiSync"));
Assert.NotNull(cmdletType.GetProperty("SortBy"));
Assert.NotNull(cmdletType.GetProperty("SortOrder"));
Assert.NotNull(cmdletType.GetProperty("Limit")); Assert.NotNull(cmdletType.GetProperty("Limit"));
Assert.NotNull(cmdletType.GetProperty("Offset")); Assert.NotNull(cmdletType.GetProperty("Offset"));
Assert.NotNull(cmdletType.GetProperty("NoAutoPage")); Assert.NotNull(cmdletType.GetProperty("NoAutoPage"));
@@ -1,4 +1,6 @@
using System; using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation; using System.Management.Automation;
using PSInfisicalAPI.Connections; using PSInfisicalAPI.Connections;
using PSInfisicalAPI.Models; using PSInfisicalAPI.Models;
@@ -18,8 +20,35 @@ namespace PSInfisicalAPI.Cmdlets
[Parameter(ParameterSetName = "List", Mandatory = true)] public string ProjectId { get; set; } [Parameter(ParameterSetName = "List", Mandatory = true)] public string ProjectId { get; set; }
[Parameter(ParameterSetName = "List")] public string CommonName { get; set; } [Parameter(ParameterSetName = "List")] public string CommonName { get; set; }
[Parameter(ParameterSetName = "List")] public string FriendlyName { get; set; } [Parameter(ParameterSetName = "List")] public string FriendlyName { get; set; }
[Parameter(ParameterSetName = "List")] public string Search { get; set; }
[Parameter(ParameterSetName = "List")] public string Status { get; set; } [Parameter(ParameterSetName = "List")] public string Status { get; set; }
[Parameter(ParameterSetName = "List")] public string[] CaId { get; set; } [Parameter(ParameterSetName = "List")] public string[] CaId { get; set; }
[Parameter(ParameterSetName = "List")] public string[] ProfileId { get; set; }
[Parameter(ParameterSetName = "List")] public string ApplicationId { get; set; }
[Parameter(ParameterSetName = "List")] public string[] ApplicationIds { get; set; }
[Parameter(ParameterSetName = "List")] public string[] EnrollmentType { get; set; }
[Parameter(ParameterSetName = "List")] public string ExtendedKeyUsage { get; set; }
[Parameter(ParameterSetName = "List")] public string[] KeyAlgorithm { get; set; }
[Parameter(ParameterSetName = "List")] public string SignatureAlgorithm { get; set; }
[Parameter(ParameterSetName = "List")] public int[] KeySize { get; set; }
[Parameter(ParameterSetName = "List")] public string[] Source { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? FromDate { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? ToDate { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? NotAfterFrom { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? NotAfterTo { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? NotBeforeFrom { get; set; }
[Parameter(ParameterSetName = "List")] public DateTimeOffset? NotBeforeTo { get; set; }
[Parameter(ParameterSetName = "List")] public Hashtable Metadata { get; set; }
[Parameter(ParameterSetName = "List")] public SwitchParameter ForPkiSync { get; set; }
[Parameter(ParameterSetName = "List")]
[ValidateSet("notAfter", "notBefore", "createdAt", "commonName", "keyAlgorithm", "status")]
public string SortBy { get; set; }
[Parameter(ParameterSetName = "List")]
[ValidateSet("asc", "desc")]
public string SortOrder { get; set; }
[Parameter(ParameterSetName = "List")] public int? Limit { get; set; } [Parameter(ParameterSetName = "List")] public int? Limit { get; set; }
[Parameter(ParameterSetName = "List")] public int? Offset { get; set; } [Parameter(ParameterSetName = "List")] public int? Offset { get; set; }
[Parameter(ParameterSetName = "List")] public SwitchParameter NoAutoPage { get; set; } [Parameter(ParameterSetName = "List")] public SwitchParameter NoAutoPage { get; set; }
@@ -47,8 +76,28 @@ namespace PSInfisicalAPI.Cmdlets
ProjectId = ProjectId, ProjectId = ProjectId,
CommonName = CommonName, CommonName = CommonName,
FriendlyName = FriendlyName, FriendlyName = FriendlyName,
Search = Search,
Status = Status, Status = Status,
CaIds = CaId, CaIds = CaId,
ProfileIds = ProfileId,
ApplicationId = ApplicationId,
ApplicationIds = ApplicationIds,
EnrollmentTypes = EnrollmentType,
ExtendedKeyUsage = ExtendedKeyUsage,
KeyAlgorithm = KeyAlgorithm,
SignatureAlgorithm = SignatureAlgorithm,
KeySizes = KeySize,
Source = Source,
FromDate = FromDate,
ToDate = ToDate,
NotAfterFrom = NotAfterFrom,
NotAfterTo = NotAfterTo,
NotBeforeFrom = NotBeforeFrom,
NotBeforeTo = NotBeforeTo,
Metadata = ToStringDictionary(Metadata),
SortBy = SortBy,
SortOrder = SortOrder,
ForPkiSync = ForPkiSync.IsPresent ? (bool?)true : null,
Limit = Limit ?? 100, Limit = Limit ?? 100,
Offset = Offset ?? 0 Offset = Offset ?? 0
}; };
@@ -87,5 +136,17 @@ namespace PSInfisicalAPI.Cmdlets
ThrowTerminatingForException("GetInfisicalCertificateCmdlet", "GetCertificate", exception); ThrowTerminatingForException("GetInfisicalCertificateCmdlet", "GetCertificate", exception);
} }
} }
private static Dictionary<string, string> ToStringDictionary(Hashtable hashtable)
{
if (hashtable == null) { return null; }
Dictionary<string, string> result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry entry in hashtable)
{
if (entry.Key == null) { continue; }
result[entry.Key.ToString()] = entry.Value != null ? entry.Value.ToString() : null;
}
return result;
}
} }
} }
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Management.Automation; using System.Management.Automation;
using PSInfisicalAPI.Connections; using PSInfisicalAPI.Connections;
@@ -18,17 +19,27 @@ namespace PSInfisicalAPI.Cmdlets
[Parameter] public string Status { get; set; } [Parameter] public string Status { get; set; }
[Parameter] public string[] CaId { get; set; } [Parameter] public string[] CaId { get; set; }
[Parameter] public string[] ProfileId { get; set; } [Parameter] public string[] ProfileId { get; set; }
[Parameter] public string[] ApplicationId { get; set; } [Parameter] public string ApplicationId { get; set; }
[Parameter] public string[] ApplicationIds { get; set; }
[Parameter] public string[] EnrollmentType { get; set; } [Parameter] public string[] EnrollmentType { get; set; }
[Parameter] public string ExtendedKeyUsage { get; set; } [Parameter] public string ExtendedKeyUsage { get; set; }
[Parameter] public string[] KeyAlgorithm { get; set; } [Parameter] public string[] KeyAlgorithm { get; set; }
[Parameter] public string SignatureAlgorithm { get; set; } [Parameter] public string SignatureAlgorithm { get; set; }
[Parameter] public int[] KeySize { get; set; }
[Parameter] public string[] Source { get; set; } [Parameter] public string[] Source { get; set; }
[Parameter] public DateTimeOffset? FromDate { get; set; }
[Parameter] public DateTimeOffset? ToDate { get; set; }
[Parameter] public DateTimeOffset? NotAfterFrom { get; set; } [Parameter] public DateTimeOffset? NotAfterFrom { get; set; }
[Parameter] public DateTimeOffset? NotAfterTo { get; set; } [Parameter] public DateTimeOffset? NotAfterTo { get; set; }
[Parameter] public DateTimeOffset? NotBeforeFrom { get; set; } [Parameter] public DateTimeOffset? NotBeforeFrom { get; set; }
[Parameter] public DateTimeOffset? NotBeforeTo { get; set; } [Parameter] public DateTimeOffset? NotBeforeTo { get; set; }
[Parameter] public string SortBy { get; set; } [Parameter] public Hashtable Metadata { get; set; }
[Parameter] public SwitchParameter ForPkiSync { get; set; }
[Parameter]
[ValidateSet("notAfter", "notBefore", "createdAt", "commonName", "keyAlgorithm", "status")]
public string SortBy { get; set; }
[Parameter] [ValidateSet("asc", "desc")] public string SortOrder { get; set; } [Parameter] [ValidateSet("asc", "desc")] public string SortOrder { get; set; }
[Parameter] public int? Limit { get; set; } [Parameter] public int? Limit { get; set; }
[Parameter] public int? Offset { get; set; } [Parameter] public int? Offset { get; set; }
@@ -91,21 +102,39 @@ namespace PSInfisicalAPI.Cmdlets
Status = Status, Status = Status,
CaIds = CaId, CaIds = CaId,
ProfileIds = ProfileId, ProfileIds = ProfileId,
ApplicationIds = ApplicationId, ApplicationId = ApplicationId,
ApplicationIds = ApplicationIds,
EnrollmentTypes = EnrollmentType, EnrollmentTypes = EnrollmentType,
ExtendedKeyUsage = ExtendedKeyUsage, ExtendedKeyUsage = ExtendedKeyUsage,
KeyAlgorithm = KeyAlgorithm, KeyAlgorithm = KeyAlgorithm,
SignatureAlgorithm = SignatureAlgorithm, SignatureAlgorithm = SignatureAlgorithm,
KeySizes = KeySize,
Source = Source, Source = Source,
FromDate = FromDate,
ToDate = ToDate,
NotAfterFrom = NotAfterFrom, NotAfterFrom = NotAfterFrom,
NotAfterTo = NotAfterTo, NotAfterTo = NotAfterTo,
NotBeforeFrom = NotBeforeFrom, NotBeforeFrom = NotBeforeFrom,
NotBeforeTo = NotBeforeTo, NotBeforeTo = NotBeforeTo,
Metadata = ToStringDictionary(Metadata),
ForPkiSync = ForPkiSync.IsPresent ? (bool?)true : null,
SortBy = SortBy, SortBy = SortBy,
SortOrder = SortOrder, SortOrder = SortOrder,
Limit = Limit, Limit = Limit,
Offset = Offset Offset = Offset
}; };
} }
private static Dictionary<string, string> ToStringDictionary(Hashtable hashtable)
{
if (hashtable == null) { return null; }
Dictionary<string, string> result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (DictionaryEntry entry in hashtable)
{
if (entry.Key == null) { continue; }
result[entry.Key.ToString()] = entry.Value != null ? entry.Value.ToString() : null;
}
return result;
}
} }
} }
@@ -70,11 +70,13 @@ namespace PSInfisicalAPI.Pki
[JsonProperty("limit", NullValueHandling = NullValueHandling.Ignore)] public int? Limit { get; set; } [JsonProperty("limit", NullValueHandling = NullValueHandling.Ignore)] public int? Limit { get; set; }
[JsonProperty("caIds", NullValueHandling = NullValueHandling.Ignore)] public string[] CaIds { get; set; } [JsonProperty("caIds", NullValueHandling = NullValueHandling.Ignore)] public string[] CaIds { get; set; }
[JsonProperty("profileIds", NullValueHandling = NullValueHandling.Ignore)] public string[] ProfileIds { get; set; } [JsonProperty("profileIds", NullValueHandling = NullValueHandling.Ignore)] public string[] ProfileIds { get; set; }
[JsonProperty("applicationId", NullValueHandling = NullValueHandling.Ignore)] public string ApplicationId { get; set; }
[JsonProperty("applicationIds", NullValueHandling = NullValueHandling.Ignore)] public string[] ApplicationIds { get; set; } [JsonProperty("applicationIds", NullValueHandling = NullValueHandling.Ignore)] public string[] ApplicationIds { get; set; }
[JsonProperty("enrollmentTypes", NullValueHandling = NullValueHandling.Ignore)] public string[] EnrollmentTypes { get; set; } [JsonProperty("enrollmentTypes", NullValueHandling = NullValueHandling.Ignore)] public string[] EnrollmentTypes { get; set; }
[JsonProperty("extendedKeyUsage", NullValueHandling = NullValueHandling.Ignore)] public string ExtendedKeyUsage { get; set; } [JsonProperty("extendedKeyUsage", NullValueHandling = NullValueHandling.Ignore)] public string ExtendedKeyUsage { get; set; }
[JsonProperty("keyAlgorithm", NullValueHandling = NullValueHandling.Ignore)] public string[] KeyAlgorithm { get; set; } [JsonProperty("keyAlgorithm", NullValueHandling = NullValueHandling.Ignore)] public string[] KeyAlgorithm { get; set; }
[JsonProperty("signatureAlgorithm", NullValueHandling = NullValueHandling.Ignore)] public string SignatureAlgorithm { get; set; } [JsonProperty("signatureAlgorithm", NullValueHandling = NullValueHandling.Ignore)] public string SignatureAlgorithm { get; set; }
[JsonProperty("keySizes", NullValueHandling = NullValueHandling.Ignore)] public int[] KeySizes { get; set; }
[JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] public string[] Source { get; set; } [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] public string[] Source { get; set; }
[JsonProperty("fromDate", NullValueHandling = NullValueHandling.Ignore)] public string FromDate { get; set; } [JsonProperty("fromDate", NullValueHandling = NullValueHandling.Ignore)] public string FromDate { get; set; }
[JsonProperty("toDate", NullValueHandling = NullValueHandling.Ignore)] public string ToDate { get; set; } [JsonProperty("toDate", NullValueHandling = NullValueHandling.Ignore)] public string ToDate { get; set; }
@@ -82,11 +84,18 @@ namespace PSInfisicalAPI.Pki
[JsonProperty("notAfterTo", NullValueHandling = NullValueHandling.Ignore)] public string NotAfterTo { get; set; } [JsonProperty("notAfterTo", NullValueHandling = NullValueHandling.Ignore)] public string NotAfterTo { get; set; }
[JsonProperty("notBeforeFrom", NullValueHandling = NullValueHandling.Ignore)] public string NotBeforeFrom { get; set; } [JsonProperty("notBeforeFrom", NullValueHandling = NullValueHandling.Ignore)] public string NotBeforeFrom { get; set; }
[JsonProperty("notBeforeTo", NullValueHandling = NullValueHandling.Ignore)] public string NotBeforeTo { get; set; } [JsonProperty("notBeforeTo", NullValueHandling = NullValueHandling.Ignore)] public string NotBeforeTo { get; set; }
[JsonProperty("metadata", NullValueHandling = NullValueHandling.Ignore)] public InfisicalCertificateSearchMetadataEntryDto[] Metadata { get; set; }
[JsonProperty("sortBy", NullValueHandling = NullValueHandling.Ignore)] public string SortBy { get; set; } [JsonProperty("sortBy", NullValueHandling = NullValueHandling.Ignore)] public string SortBy { get; set; }
[JsonProperty("sortOrder", NullValueHandling = NullValueHandling.Ignore)] public string SortOrder { get; set; } [JsonProperty("sortOrder", NullValueHandling = NullValueHandling.Ignore)] public string SortOrder { get; set; }
[JsonProperty("forPkiSync", NullValueHandling = NullValueHandling.Ignore)] public bool? ForPkiSync { get; set; } [JsonProperty("forPkiSync", NullValueHandling = NullValueHandling.Ignore)] public bool? ForPkiSync { get; set; }
} }
internal sealed class InfisicalCertificateSearchMetadataEntryDto
{
[JsonProperty("key")] public string Key { get; set; }
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)] public string Value { get; set; }
}
internal sealed class InfisicalCertificateBundleResponseDto internal sealed class InfisicalCertificateBundleResponseDto
{ {
[JsonProperty("serialNumber")] public string SerialNumber { get; set; } [JsonProperty("serialNumber")] public string SerialNumber { get; set; }
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
namespace PSInfisicalAPI.Pki namespace PSInfisicalAPI.Pki
{ {
@@ -13,11 +14,13 @@ namespace PSInfisicalAPI.Pki
public int? Limit { get; set; } public int? Limit { get; set; }
public string[] CaIds { get; set; } public string[] CaIds { get; set; }
public string[] ProfileIds { get; set; } public string[] ProfileIds { get; set; }
public string ApplicationId { get; set; }
public string[] ApplicationIds { get; set; } public string[] ApplicationIds { get; set; }
public string[] EnrollmentTypes { get; set; } public string[] EnrollmentTypes { get; set; }
public string ExtendedKeyUsage { get; set; } public string ExtendedKeyUsage { get; set; }
public string[] KeyAlgorithm { get; set; } public string[] KeyAlgorithm { get; set; }
public string SignatureAlgorithm { get; set; } public string SignatureAlgorithm { get; set; }
public int[] KeySizes { get; set; }
public string[] Source { get; set; } public string[] Source { get; set; }
public DateTimeOffset? FromDate { get; set; } public DateTimeOffset? FromDate { get; set; }
public DateTimeOffset? ToDate { get; set; } public DateTimeOffset? ToDate { get; set; }
@@ -25,6 +28,7 @@ namespace PSInfisicalAPI.Pki
public DateTimeOffset? NotAfterTo { get; set; } public DateTimeOffset? NotAfterTo { get; set; }
public DateTimeOffset? NotBeforeFrom { get; set; } public DateTimeOffset? NotBeforeFrom { get; set; }
public DateTimeOffset? NotBeforeTo { get; set; } public DateTimeOffset? NotBeforeTo { get; set; }
public IDictionary<string, string> Metadata { get; set; }
public string SortBy { get; set; } public string SortBy { get; set; }
public string SortOrder { get; set; } public string SortOrder { get; set; }
public bool? ForPkiSync { get; set; } public bool? ForPkiSync { get; set; }
@@ -863,11 +863,13 @@ namespace PSInfisicalAPI.Pki
Limit = query.Limit, Limit = query.Limit,
CaIds = query.CaIds, CaIds = query.CaIds,
ProfileIds = query.ProfileIds, ProfileIds = query.ProfileIds,
ApplicationId = query.ApplicationId,
ApplicationIds = query.ApplicationIds, ApplicationIds = query.ApplicationIds,
EnrollmentTypes = query.EnrollmentTypes, EnrollmentTypes = query.EnrollmentTypes,
ExtendedKeyUsage = query.ExtendedKeyUsage, ExtendedKeyUsage = query.ExtendedKeyUsage,
KeyAlgorithm = query.KeyAlgorithm, KeyAlgorithm = query.KeyAlgorithm,
SignatureAlgorithm = query.SignatureAlgorithm, SignatureAlgorithm = query.SignatureAlgorithm,
KeySizes = query.KeySizes,
Source = query.Source, Source = query.Source,
FromDate = FormatTimestamp(query.FromDate), FromDate = FormatTimestamp(query.FromDate),
ToDate = FormatTimestamp(query.ToDate), ToDate = FormatTimestamp(query.ToDate),
@@ -875,12 +877,25 @@ namespace PSInfisicalAPI.Pki
NotAfterTo = FormatTimestamp(query.NotAfterTo), NotAfterTo = FormatTimestamp(query.NotAfterTo),
NotBeforeFrom = FormatTimestamp(query.NotBeforeFrom), NotBeforeFrom = FormatTimestamp(query.NotBeforeFrom),
NotBeforeTo = FormatTimestamp(query.NotBeforeTo), NotBeforeTo = FormatTimestamp(query.NotBeforeTo),
Metadata = BuildMetadataEntries(query.Metadata),
SortBy = query.SortBy, SortBy = query.SortBy,
SortOrder = query.SortOrder, SortOrder = query.SortOrder,
ForPkiSync = query.ForPkiSync ForPkiSync = query.ForPkiSync
}; };
} }
private static InfisicalCertificateSearchMetadataEntryDto[] BuildMetadataEntries(IDictionary<string, string> source)
{
if (source == null || source.Count == 0) { return null; }
List<InfisicalCertificateSearchMetadataEntryDto> entries = new List<InfisicalCertificateSearchMetadataEntryDto>(source.Count);
foreach (KeyValuePair<string, string> pair in source)
{
if (string.IsNullOrEmpty(pair.Key)) { continue; }
entries.Add(new InfisicalCertificateSearchMetadataEntryDto { Key = pair.Key, Value = pair.Value });
}
return entries.Count == 0 ? null : entries.ToArray();
}
private static string FormatTimestamp(DateTimeOffset? value) private static string FormatTimestamp(DateTimeOffset? value)
{ {
if (!value.HasValue) { return null; } if (!value.HasValue) { return null; }