Skip to content

Commit 36736b0

Browse files
authored
provide licensed endpoint information to SP when available in the license file (#5529)
1 parent f3dae00 commit 36736b0

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
6262
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
6363
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.1.1" />
64-
<PackageVersion Include="Particular.Licensing.Sources" Version="6.1.1" />
64+
<PackageVersion Include="Particular.Licensing.Sources" Version="6.2.1" />
6565
<PackageVersion Include="Particular.Obsoletes" Version="1.1.0" />
6666
<PackageVersion Include="Particular.ServicePulse.Core" Version="2.7.2" />
6767
<PackageVersion Include="Polly.Core" Version="8.6.6" />

src/ServiceControl.LicenseManagement/LicenseDetails.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace ServiceControl.LicenseManagement
22
{
33
using System;
4+
using System.Linq;
5+
using System.Text.RegularExpressions;
46
using Particular.Licensing;
57

68
public class LicenseDetails
@@ -24,6 +26,7 @@ public class LicenseDetails
2426
public bool WarnUserUpgradeProtectionIsExpiring { get; private init; }
2527
public bool WarnUserUpgradeProtectionHasExpired { get; private init; }
2628
public string Status { get; private init; }
29+
public LicensedProduct[] Products { get; private init; }
2730

2831
public static LicenseDetails TrialFromEndDate(DateOnly endDate)
2932
{
@@ -64,6 +67,8 @@ internal static LicenseDetails FromLicense(License license)
6467
IsTrialLicense = license.IsTrialLicense,
6568
LicenseType = license.LicenseType,
6669
Edition = license.Edition,
70+
//strip any internal prefix from what gets displayed to the customer
71+
Products = license.LicensedEndpoints?.Select(le => new LicensedProduct(le.Size.EndsWith("U") ? "Unlimited" : Regex.Replace(le.Size, @"^\D*", ""), le.Quantity)).ToArray(),
6772
ValidForServiceControl = license.ValidForApplication("ServiceControl"),
6873
DaysUntilSubscriptionExpires = license.GetDaysUntilLicenseExpires(),
6974
DaysUntilUpgradeProtectionExpires = license.GetDaysUntilUpgradeProtectionExpires(),
@@ -95,4 +100,6 @@ static bool HasLicenseDateExpired(DateTime licenseDate)
95100
return oneDayGrace < DateTime.UtcNow.Date;
96101
}
97102
}
103+
104+
public record LicensedProduct(string Name, int Quantity);
98105
}

src/ServiceControl/Licensing/LicenseController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Monitoring.HeartbeatMonitoring;
77
using Particular.ServiceControl.Licensing;
88
using ServiceBus.Management.Infrastructure.Settings;
9+
using ServiceControl.LicenseManagement;
910

1011
[ApiController]
1112
[Route("api")]
@@ -31,6 +32,7 @@ public async Task<ActionResult<LicenseInfo>> License(bool refresh, string client
3132
LicenseType = activeLicense.Details.LicenseType ?? string.Empty,
3233
InstanceName = settings.InstanceName ?? string.Empty,
3334
LicenseStatus = activeLicense.Details.Status,
35+
Products = activeLicense.Details.Products,
3436
LicenseExtensionUrl = connectorHeartbeatStatus.LastHeartbeat == null
3537
? $"https://particular.net/extend-your-trial?p={clientName}"
3638
: $"https://particular.net/license/mt?p={clientName}&t={(activeLicense.IsEvaluation ? 0 : 1)}"
@@ -53,6 +55,8 @@ public class LicenseInfo
5355

5456
public string Status { get; set; }
5557

58+
public LicensedProduct[] Products { get; set; }
59+
5660
public string LicenseType { get; set; }
5761

5862
public string InstanceName { get; set; }

0 commit comments

Comments
 (0)