Skip to content

Commit a5c0119

Browse files
committed
add license support
Add function GetNginxLicense() which returns a struct of type NginxLicense
1 parent d68685e commit a5c0119

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

client/nginx.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ type NginxInfo struct {
193193
ParentProcessID uint64 `json:"ppid"`
194194
}
195195

196+
// LicenseReporting contains information about license status for NGINX Plus.
197+
type LicenseReporting struct {
198+
Healthy bool
199+
Fails uint64
200+
Grace uint64
201+
}
202+
203+
// NginxLicense contains licensing information about NGINX Plus.
204+
type NginxLicense struct {
205+
ActiveTill uint64 `json:"active_till"`
206+
Eval bool
207+
Reporting LicenseReporting
208+
}
209+
196210
// Caches is a map of cache stats by cache zone.
197211
type Caches = map[string]HTTPCache
198212

@@ -1553,6 +1567,16 @@ func (client *NginxClient) GetNginxInfo(ctx context.Context) (*NginxInfo, error)
15531567
return &info, nil
15541568
}
15551569

1570+
// GetNginxLicense returns Nginx License data with a context.
1571+
func (client *NginxClient) GetNginxLicense(ctx context.Context) (*NginxLicense, error) {
1572+
var info NginxLicense
1573+
err := client.get(ctx, "license", &info)
1574+
if err != nil {
1575+
return nil, fmt.Errorf("failed to get info: %w", err)
1576+
}
1577+
return &info, nil
1578+
}
1579+
15561580
// GetCaches returns Cache stats with a context.
15571581
func (client *NginxClient) GetCaches(ctx context.Context) (*Caches, error) {
15581582
var caches Caches

0 commit comments

Comments
 (0)