FeaturesClaims provides the feature claims in license. This only returns the explicit claims. If checking for actual usage, also check `AllFeaturesClaim`.
()
| 74 | // This only returns the explicit claims. If checking for actual usage, |
| 75 | // also check `AllFeaturesClaim`. |
| 76 | func (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 | |
| 99 | func (c *Client) AddLicense(ctx context.Context, r AddLicenseRequest) (License, error) { |
| 100 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/licenses", r) |