1package limits 2 3import ( 4 "github.com/gophercloud/gophercloud" 5) 6 7// Limits is a struct that contains the response of a limit query. 8type Limits struct { 9 // Absolute contains the limits and usage information. 10 // An absolute limit value of -1 indicates that the absolute limit for the item is infinite. 11 Absolute Absolute `json:"absolute"` 12 // Rate contains rate-limit volume copy bandwidth, used to mitigate slow down of data access from the instances. 13 Rate []Rate `json:"rate"` 14} 15 16// Absolute is a struct that contains the current resource usage and limits 17// of a project. 18type Absolute struct { 19 // MaxTotalVolumes is the maximum number of volumes. 20 MaxTotalVolumes int `json:"maxTotalVolumes"` 21 22 // MaxTotalSnapshots is the maximum number of snapshots. 23 MaxTotalSnapshots int `json:"maxTotalSnapshots"` 24 25 // MaxTotalVolumeGigabytes is the maximum total amount of volumes, in gibibytes (GiB). 26 MaxTotalVolumeGigabytes int `json:"maxTotalVolumeGigabytes"` 27 28 // MaxTotalBackups is the maximum number of backups. 29 MaxTotalBackups int `json:"maxTotalBackups"` 30 31 // MaxTotalBackupGigabytes is the maximum total amount of backups, in gibibytes (GiB). 32 MaxTotalBackupGigabytes int `json:"maxTotalBackupGigabytes"` 33 34 // TotalVolumesUsed is the total number of volumes used. 35 TotalVolumesUsed int `json:"totalVolumesUsed"` 36 37 // TotalGigabytesUsed is the total number of gibibytes (GiB) used. 38 TotalGigabytesUsed int `json:"totalGigabytesUsed"` 39 40 // TotalSnapshotsUsed the total number of snapshots used. 41 TotalSnapshotsUsed int `json:"totalSnapshotsUsed"` 42 43 // TotalBackupsUsed is the total number of backups used. 44 TotalBackupsUsed int `json:"totalBackupsUsed"` 45 46 // TotalBackupGigabytesUsed is the total number of backups gibibytes (GiB) used. 47 TotalBackupGigabytesUsed int `json:"totalBackupGigabytesUsed"` 48} 49 50// Rate is a struct that contains the 51// rate-limit volume copy bandwidth, used to mitigate slow down of data access from the instances. 52type Rate struct { 53 Regex string `json:"regex"` 54 URI string `json:"uri"` 55 Limit []Limit `json:"limit"` 56} 57 58// Limit struct contains Limit values for the Rate struct 59type Limit struct { 60 Verb string `json:"verb"` 61 NextAvailable string `json:"next-available"` 62 Unit string `json:"unit"` 63 Value int `json:"value"` 64 Remaining int `json:"remaining"` 65} 66 67// Extract interprets a limits result as a Limits. 68func (r GetResult) Extract() (*Limits, error) { 69 var s struct { 70 Limits *Limits `json:"limits"` 71 } 72 err := r.ExtractInto(&s) 73 return s.Limits, err 74} 75 76// GetResult is the response from a Get operation. Call its Extract 77// method to interpret it as an Absolute. 78type GetResult struct { 79 gophercloud.Result 80} 81