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 @@ -69,7 +69,7 @@
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.2.0" />
<PackageVersion Include="Particular.Licensing.Sources" Version="7.3.0" />
<PackageVersion Include="Particular.Licensing.Sources" Version="7.4.0" />
<PackageVersion Include="Particular.Obsoletes" Version="1.1.0" />
<PackageVersion Include="Particular.ServicePulse.Core" Version="2.9.2" />
<PackageVersion Include="Polly.Core" Version="8.7.0" />
Expand Down
3 changes: 3 additions & 0 deletions src/ServiceControl.LicenseManagement/LicenseDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class LicenseDetails

public LicensedProduct[] Products { get; private init; }

public bool HasEndpointMetadata { get; private init; }

public static LicenseDetails TrialFromEndDate(DateOnly endDate)
{
return FromLicense(new License
Expand Down Expand Up @@ -82,6 +84,7 @@ internal static LicenseDetails FromLicense(License license)
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(),
HasEndpointMetadata = license.Capabilities.Contains("EndpointMetadataFile"),
ValidForServiceControl = license.ValidForApplication("ServiceControl"),
DaysUntilSubscriptionExpires = license.GetDaysUntilLicenseExpires(),
WarnUserTrialIsExpiring = licenseStatus == LicenseStatus.ValidWithExpiringTrial,
Expand Down
6 changes: 6 additions & 0 deletions src/ServiceControl/Licensing/LicenseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public async Task<ActionResult<LicenseInfo>> License(bool refresh, string client
InstanceName = settings.InstanceName ?? string.Empty,
LicenseStatus = activeLicense.Details.Status,
Products = activeLicense.Details.Products,
HasEndpointMetadata = activeLicense.Details.HasEndpointMetadata,
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 @@ -57,6 +58,11 @@ public async Task<ActionResult<LicenseInfo>> License(bool refresh, string client
[Route("license/details")]
public async Task<ActionResult<LicensedEndpointDetails?>> LicenseDetails(CancellationToken cancellationToken)
{
if (activeLicense.Details.Edition != "Endpoint Size" || !activeLicense.Details.HasEndpointMetadata)
{
return (LicensedEndpointDetails?)null;
}

var licenseDetails = await dataStore.GetLicensedEndpointDetails(cancellationToken);
if (licenseDetails is null)
{
Expand Down
2 changes: 2 additions & 0 deletions src/ServiceControl/Licensing/LicenseControllerTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class LicenseInfo

public LicensedProduct[] Products { get; set; }

public bool HasEndpointMetadata { get; set; }

public string LicenseType { get; set; }

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