MCPcopy Index your code
hub / github.com/coder/coder / FeaturesClaims

Method FeaturesClaims

codersdk/licenses.go:76–97  ·  view source on GitHub ↗

FeaturesClaims provides the feature claims in license. This only returns the explicit claims. If checking for actual usage, also check `AllFeaturesClaim`.

()

Source from the content-addressed store, hash-verified

74// This only returns the explicit claims. If checking for actual usage,
75// also check `AllFeaturesClaim`.
76func (l *License) FeaturesClaims() (map[FeatureName]int64, error) {
77 strMap, ok := l.Claims["features"].(map[string]interface{})
78 if !ok {
79 return nil, xerrors.New("features key is unexpected type")
80 }
81 fMap := make(map[FeatureName]int64)
82 for k, v := range strMap {
83 jn, ok := v.(json.Number)
84 if !ok {
85 return nil, xerrors.Errorf("feature %q has unexpected type", k)
86 }
87
88 n, err := jn.Int64()
89 if err != nil {
90 return nil, err
91 }
92
93 fMap[FeatureName(k)] = n
94 }
95
96 return fMap, nil
97}
98
99func (c *Client) AddLicense(ctx context.Context, r AddLicenseRequest) (License, error) {
100 res, err := c.Request(ctx, http.MethodPost, "/api/v2/licenses", r)

Callers 3

NewLicenseFormatterFunction · 0.80
TestPostLicenseFunction · 0.80
TestGetLicenseFunction · 0.80

Calls 4

FeatureNameTypeAlias · 0.85
Int64Method · 0.80
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by 2

TestPostLicenseFunction · 0.64
TestGetLicenseFunction · 0.64