mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
coder features list CLI command (#3533)
* AGPL Entitlements API Signed-off-by: Spike Curtis <spike@coder.com> * Generate typesGenerated.ts Signed-off-by: Spike Curtis <spike@coder.com> * AllFeatures -> FeatureNames Signed-off-by: Spike Curtis <spike@coder.com> * Features CLI command Signed-off-by: Spike Curtis <spike@coder.com> * Validate columns Signed-off-by: Spike Curtis <spike@coder.com> * Tests for features list CLI command Signed-off-by: Spike Curtis <spike@coder.com> * Drop empty EntitlementsRequest Signed-off-by: Spike Curtis <spike@coder.com> * Fix dump.sql generation Signed-off-by: Spike Curtis <spike@coder.com> Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
package codersdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Entitlement string
|
||||
|
||||
const (
|
||||
@ -27,3 +33,16 @@ type Entitlements struct {
|
||||
Warnings []string `json:"warnings"`
|
||||
HasLicense bool `json:"has_license"`
|
||||
}
|
||||
|
||||
func (c *Client) Entitlements(ctx context.Context) (Entitlements, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/entitlements", nil)
|
||||
if err != nil {
|
||||
return Entitlements{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return Entitlements{}, readBodyAsError(res)
|
||||
}
|
||||
var ent Entitlements
|
||||
return ent, json.NewDecoder(res.Body).Decode(&ent)
|
||||
}
|
||||
|
Reference in New Issue
Block a user