/
LicenseController.cs
52 lines (40 loc) · 1.6 KB
/
LicenseController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace ServiceControl.Monitoring.Http
{
using Microsoft.AspNetCore.Mvc;
using ServiceControl.Monitoring.Licensing;
[ApiController]
public class LicenseController(ActiveLicense activeLicense) : ControllerBase
{
[Route("license")]
[HttpGet]
public ActionResult<LicenseInfo> License(bool refresh)
{
if (refresh)
{
activeLicense.Refresh();
}
var licenseInfo = new LicenseInfo
{
TrialLicense = activeLicense.Details.IsTrialLicense,
Edition = activeLicense.Details.Edition ?? string.Empty,
RegisteredTo = activeLicense.Details.RegisteredTo ?? string.Empty,
UpgradeProtectionExpiration = activeLicense.Details.UpgradeProtectionExpiration?.ToString("O") ?? string.Empty,
ExpirationDate = activeLicense.Details.ExpirationDate?.ToString("O") ?? string.Empty,
Status = activeLicense.IsValid ? "valid" : "invalid"
};
return licenseInfo;
}
public class LicenseInfo
{
public bool TrialLicense { get; set; }
public string Edition { get; set; }
public string RegisteredTo { get; set; }
public string UpgradeProtectionExpiration { get; set; }
public string ExpirationDate { get; set; }
public string Status { get; set; }
public string LicenseType { get; set; }
public string InstanceName { get; set; }
public string LicenseStatus { get; set; }
}
}
}