mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: workspace quotas (#4184)
This commit is contained in:
@ -15,13 +15,20 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
FeatureUserLimit = "user_limit"
|
||||
FeatureAuditLog = "audit_log"
|
||||
FeatureBrowserOnly = "browser_only"
|
||||
FeatureSCIM = "scim"
|
||||
FeatureUserLimit = "user_limit"
|
||||
FeatureAuditLog = "audit_log"
|
||||
FeatureBrowserOnly = "browser_only"
|
||||
FeatureSCIM = "scim"
|
||||
FeatureWorkspaceQuota = "workspace_quota"
|
||||
)
|
||||
|
||||
var FeatureNames = []string{FeatureUserLimit, FeatureAuditLog, FeatureBrowserOnly, FeatureSCIM}
|
||||
var FeatureNames = []string{
|
||||
FeatureUserLimit,
|
||||
FeatureAuditLog,
|
||||
FeatureBrowserOnly,
|
||||
FeatureSCIM,
|
||||
FeatureWorkspaceQuota,
|
||||
}
|
||||
|
||||
type Feature struct {
|
||||
Entitlement Entitlement `json:"entitlement"`
|
||||
|
26
codersdk/workspacequota.go
Normal file
26
codersdk/workspacequota.go
Normal file
@ -0,0 +1,26 @@
|
||||
package codersdk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type WorkspaceQuota struct {
|
||||
UserWorkspaceCount int `json:"user_workspace_count"`
|
||||
UserWorkspaceLimit int `json:"user_workspace_limit"`
|
||||
}
|
||||
|
||||
func (c *Client) WorkspaceQuota(ctx context.Context, userID string) (WorkspaceQuota, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/workspace-quota/%s", userID), nil)
|
||||
if err != nil {
|
||||
return WorkspaceQuota{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return WorkspaceQuota{}, readBodyAsError(res)
|
||||
}
|
||||
var quota WorkspaceQuota
|
||||
return quota, json.NewDecoder(res.Body).Decode("a)
|
||||
}
|
Reference in New Issue
Block a user