From 69c7d6470107c505396409f9bcb67eee5537fbcb Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Mon, 12 Aug 2019 15:24:02 -0400 Subject: [PATCH] Add missing LicenseReset API function (#6311) --- api/operator_license.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/api/operator_license.go b/api/operator_license.go index 3d1497aa82..25aa702e8a 100644 --- a/api/operator_license.go +++ b/api/operator_license.go @@ -73,6 +73,25 @@ func (op *Operator) LicenseGetSigned(q *QueryOptions) (string, error) { return string(data), nil } +// LicenseReset will reset the license to the builtin one if it is still valid. +// If the builtin license is invalid, the current license stays active. +func (op *Operator) LicenseReset(opts *WriteOptions) (*LicenseReply, error) { + var reply LicenseReply + r := op.c.newRequest("DELETE", "/v1/operator/license") + r.setWriteOptions(opts) + _, resp, err := requireOK(op.c.doRequest(r)) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if err := decodeBody(resp, &reply); err != nil { + return nil, err + } + + return &reply, nil +} + func (op *Operator) LicensePut(license string, opts *WriteOptions) (*LicenseReply, error) { var reply LicenseReply r := op.c.newRequest("PUT", "/v1/operator/license")