Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.15.3" />
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.1.1" />
<PackageVersion Include="Particular.Licensing.Sources" Version="6.1.1" />
<PackageVersion Include="Particular.Licensing.Sources" Version="6.2.1" />
<PackageVersion Include="Particular.Obsoletes" Version="1.1.0" />
<PackageVersion Include="Particular.ServicePulse.Core" Version="2.7.1" />
<PackageVersion Include="Polly.Core" Version="8.6.6" />
Expand Down
7 changes: 7 additions & 0 deletions src/ServiceControl.LicenseManagement/LicenseDetails.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace ServiceControl.LicenseManagement
{
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Particular.Licensing;

public class LicenseDetails
Expand All @@ -24,6 +26,7 @@ public class LicenseDetails
public bool WarnUserUpgradeProtectionIsExpiring { get; private init; }
public bool WarnUserUpgradeProtectionHasExpired { get; private init; }
public string Status { get; private init; }
public LicensedProduct[] Products { get; private init; }

public static LicenseDetails TrialFromEndDate(DateOnly endDate)
{
Expand Down Expand Up @@ -64,6 +67,8 @@ internal static LicenseDetails FromLicense(License license)
IsTrialLicense = license.IsTrialLicense,
LicenseType = license.LicenseType,
Edition = license.Edition,
//strip any internal prefix from what gets displayed to the customer
Products = license.LicensedEndpoints?.Select(le => new LicensedProduct(le.Size.EndsWith("U") ? "Unlimited" : Regex.Replace(le.Size, @"^\D*", ""), le.Quantity)).ToArray(),
ValidForServiceControl = license.ValidForApplication("ServiceControl"),
DaysUntilSubscriptionExpires = license.GetDaysUntilLicenseExpires(),
DaysUntilUpgradeProtectionExpires = license.GetDaysUntilUpgradeProtectionExpires(),
Expand Down Expand Up @@ -95,4 +100,6 @@ static bool HasLicenseDateExpired(DateTime licenseDate)
return oneDayGrace < DateTime.UtcNow.Date;
}
}

public record LicensedProduct(string Name, int Quantity);
}
4 changes: 4 additions & 0 deletions src/ServiceControl/Licensing/LicenseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Monitoring.HeartbeatMonitoring;
using Particular.ServiceControl.Licensing;
using ServiceBus.Management.Infrastructure.Settings;
using ServiceControl.LicenseManagement;

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

public string Status { get; set; }

public LicensedProduct[] Products { get; set; }

public string LicenseType { get; set; }

public string InstanceName { get; set; }
Expand Down
Loading