quota.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package google
  15. import (
  16. "strings"
  17. "yunion.io/x/cloudmux/pkg/cloudprovider"
  18. )
  19. type SQuota struct {
  20. Metric string
  21. Limit int
  22. Usage int
  23. Owner string
  24. }
  25. func (q *SQuota) GetGlobalId() string {
  26. return strings.ToLower(q.Metric)
  27. }
  28. func (q *SQuota) GetName() string {
  29. return q.Metric
  30. }
  31. func (q *SQuota) GetDesc() string {
  32. return q.Metric
  33. }
  34. func (q *SQuota) GetQuotaType() string {
  35. return q.Metric
  36. }
  37. func (q *SQuota) GetMaxQuotaCount() int {
  38. return q.Limit
  39. }
  40. func (q *SQuota) GetCurrentQuotaUsedCount() int {
  41. return q.Usage
  42. }
  43. func (region *SRegion) GetICloudQuotas() ([]cloudprovider.ICloudQuota, error) {
  44. ret := []cloudprovider.ICloudQuota{}
  45. for i := range region.Quotas {
  46. ret = append(ret, &region.Quotas[i])
  47. }
  48. return ret, nil
  49. }