diff --git a/.changes/next-release/feature-vks-edyyr5ol.json b/.changes/next-release/feature-vks-edyyr5ol.json new file mode 100644 index 0000000..e99aa39 --- /dev/null +++ b/.changes/next-release/feature-vks-edyyr5ol.json @@ -0,0 +1,5 @@ +{ + "type": "feature", + "category": "vks", + "description": "Add get-quota command to retrieve VKS quota limits and current usage" +} diff --git a/go/cmd/vks/get_quota.go b/go/cmd/vks/get_quota.go new file mode 100644 index 0000000..78788a0 --- /dev/null +++ b/go/cmd/vks/get_quota.go @@ -0,0 +1,29 @@ +package vks + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var getQuotaCmd = &cobra.Command{ + Use: "get-quota", + Short: "Get VKS quota for the current user", + RunE: runGetQuota, +} + +func runGetQuota(cmd *cobra.Command, args []string) error { + apiClient, err := createClient(cmd) + if err != nil { + return err + } + + result, err := apiClient.Get("/v1/quota", nil) + if err != nil { + fmt.Fprintf(os.Stderr, "Error: %v\n", err) + os.Exit(1) + } + + return outputResult(cmd, result) +} diff --git a/go/cmd/vks/vks.go b/go/cmd/vks/vks.go index 0198ada..b0f5101 100644 --- a/go/cmd/vks/vks.go +++ b/go/cmd/vks/vks.go @@ -35,4 +35,7 @@ func init() { // Auto-upgrade commands VksCmd.AddCommand(setAutoUpgradeConfigCmd) VksCmd.AddCommand(deleteAutoUpgradeConfigCmd) + + // Quota commands + VksCmd.AddCommand(getQuotaCmd) }