github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/extensions/quotasets/get_usage.go (about) 1 package quotasets 2 3 import ( 4 "fmt" 5 6 "github.com/opentelekomcloud/gophertelekomcloud" 7 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 8 ) 9 10 func GetUsage(client *golangsdk.ServiceClient, projectID string) (*QuotaUsageSet, error) { 11 raw, err := client.Get(fmt.Sprintf("%s?usage=true", client.ServiceURL("os-quota-sets", projectID)), nil, nil) 12 if err != nil { 13 return nil, err 14 } 15 16 var res QuotaUsageSet 17 err = extract.IntoStructPtr(raw.Body, &res, "quota_set") 18 return &res, err 19 } 20 21 type QuotaUsageSet struct { 22 // ID is the project ID associated with this QuotaUsageSet. 23 ID string `json:"id"` 24 // Volumes is the volume usage information for this project, including 25 // in_use, limit, reserved and allocated attributes. Note: allocated 26 // attribute is available only when nested quota is enabled. 27 Volumes QuotaUsage `json:"volumes"` 28 // Snapshots is the snapshot usage information for this project, including 29 // in_use, limit, reserved and allocated attributes. Note: allocated 30 // attribute is available only when nested quota is enabled. 31 Snapshots QuotaUsage `json:"snapshots"` 32 // Gigabytes is the size (GB) usage information of volumes and snapshots 33 // for this project, including in_use, limit, reserved and allocated 34 // attributes. Note: allocated attribute is available only when nested 35 // quota is enabled. 36 Gigabytes QuotaUsage `json:"gigabytes"` 37 // PerVolumeGigabytes is the size (GB) usage information for each volume, 38 // including in_use, limit, reserved and allocated attributes. Note: 39 // allocated attribute is available only when nested quota is enabled and 40 // only limit is meaningful here. 41 PerVolumeGigabytes QuotaUsage `json:"per_volume_gigabytes"` 42 // Backups is the backup usage information for this project, including 43 // in_use, limit, reserved and allocated attributes. Note: allocated 44 // attribute is available only when nested quota is enabled. 45 Backups QuotaUsage `json:"backups"` 46 // BackupGigabytes is the size (GB) usage information of backup for this 47 // project, including in_use, limit, reserved and allocated attributes. 48 // Note: allocated attribute is available only when nested quota is 49 // enabled. 50 BackupGigabytes QuotaUsage `json:"backup_gigabytes"` 51 } 52 53 type QuotaUsage struct { 54 // InUse is the current number of provisioned resources of the given type. 55 InUse int `json:"in_use"` 56 // Allocated is the current number of resources of a given type allocated 57 // for use. It is only available when nested quota is enabled. 58 Allocated int `json:"allocated"` 59 // Reserved is a transitional state when a claim against quota has been made 60 // but the resource is not yet fully online. 61 Reserved int `json:"reserved"` 62 // Limit is the maximum number of a given resource that can be 63 // allocated/provisioned. This is what "quota" usually refers to. 64 Limit int `json:"limit"` 65 }