File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -1132,8 +1132,9 @@ $ scw inspect myserver | jq '.[0].public_ip.address'
11321132### master (unreleased)
11331133
11341134* Added _ cs ([ #180 ] ( https://github.com/scaleway/scaleway-cli/issues/180 ) )
1135- * Added SCALEWAY_VERBOSE_API to make the API more verbose
1136- * Support of 'scw _ ips' command ... ([ #196 ] ( https://github.com/scaleway/scaleway-cli/issues/196 ) )
1135+ * Report ** quotas** in ` scw info ` ([ #130 ] ( https://github.com/scaleway/scaleway-cli/issues/130 ) )
1136+ * Added ` SCALEWAY_VERBOSE_API ` to make the API more verbose
1137+ * Support of ` scw _ips ` command ... ([ #196 ] ( https://github.com/scaleway/scaleway-cli/issues/196 ) )
11371138* Report ** permissions** in ` scw info ` ([ #191 ] ( https://github.com/scaleway/scaleway-cli/issues/191 ) )
11381139* Report ** dashboard** statistics in ` scw info ` ([ #177 ] ( https://github.com/scaleway/scaleway-cli/issues/177 ) )
11391140* Support of ` scw _userdata name VAR=@/path/to/file ` ([ #183 ] ( https://github.com/scaleway/scaleway-cli/issues/183 ) )
Original file line number Diff line number Diff line change @@ -734,6 +734,13 @@ type ScalewayUserdatas struct {
734734 UserData []string `json:"user_data"`
735735}
736736
737+ type ScalewayQuota map [string ]int
738+
739+ // ScalewayGetQuotas represents the response of GET /organizations/{orga_id}/quotas
740+ type ScalewayGetQuotas struct {
741+ Quotas ScalewayQuota `json:"quotas"`
742+ }
743+
737744// ScalewayUserdata represents []byte
738745type ScalewayUserdata []byte
739746
@@ -2027,6 +2034,28 @@ func (s *ScalewayAPI) GetIP(ipID string) (*ScalewayGetIP, error) {
20272034 return & ip , nil
20282035}
20292036
2037+ // GetQuotas returns a ScalewayGetQuotas
2038+ func (s * ScalewayAPI ) GetQuotas () (* ScalewayGetQuotas , error ) {
2039+ s .EnableAccountAPI ()
2040+ defer s .DisableAccountAPI ()
2041+ resp , err := s .GetResponse (fmt .Sprintf ("organizations/%s/quotas" , s .Organization ))
2042+ if err != nil {
2043+ return nil , err
2044+ }
2045+ defer resp .Body .Close ()
2046+
2047+ body , err := s .handleHTTPError ([]int {200 }, resp )
2048+ if err != nil {
2049+ return nil , err
2050+ }
2051+ var quotas ScalewayGetQuotas
2052+
2053+ if err = json .Unmarshal (body , & quotas ); err != nil {
2054+ return nil , err
2055+ }
2056+ return & quotas , nil
2057+ }
2058+
20302059// GetBootscriptID returns exactly one bootscript matching or dies
20312060func (s * ScalewayAPI ) GetBootscriptID (needle string ) string {
20322061 // Parses optional type prefix, i.e: "bootscript:name" -> "name"
Original file line number Diff line number Diff line change @@ -58,9 +58,8 @@ func RunInfo(ctx CommandContext, args InfoArgs) error {
5858 fingerprint , err := utils .SSHGetFingerprint (key .Key )
5959 if err != nil {
6060 return err
61- } else {
62- fmt .Fprintf (ctx .Stdout , " [%d] %s" , id , fingerprint )
6361 }
62+ fmt .Fprintf (ctx .Stdout , " [%d] %s" , id , fingerprint )
6463 }
6564 fmt .Fprintf (ctx .Stdout , "\n " )
6665 }
@@ -91,5 +90,14 @@ func RunInfo(ctx CommandContext, args InfoArgs) error {
9190 }
9291 }
9392 }
93+ fmt .Fprintf (ctx .Stdout , "\n " )
94+ quotas , err := ctx .API .GetQuotas ()
95+ if err != nil {
96+ return fmt .Errorf ("Unable to get your quotas" )
97+ }
98+ fmt .Fprintln (ctx .Stdout , "Quotas:" )
99+ for key , value := range quotas .Quotas {
100+ fmt .Fprintf (ctx .Stdout , " %-20s: %d\n " , key , value )
101+ }
94102 return nil
95103}
You can’t perform that action at this time.
0 commit comments