github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/quotasets/results.go (about) 1 package quotasets 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 // QuotaSet is a set of operational limits that allow for control of compute 9 // usage. 10 type QuotaSet struct { 11 // ID is tenant associated with this QuotaSet. 12 ID string `json:"id"` 13 14 // FixedIPs is number of fixed ips alloted this QuotaSet. 15 FixedIPs int `json:"fixed_ips"` 16 17 // FloatingIPs is number of floating ips alloted this QuotaSet. 18 FloatingIPs int `json:"floating_ips"` 19 20 // InjectedFileContentBytes is the allowed bytes for each injected file. 21 InjectedFileContentBytes int `json:"injected_file_content_bytes"` 22 23 // InjectedFilePathBytes is allowed bytes for each injected file path. 24 InjectedFilePathBytes int `json:"injected_file_path_bytes"` 25 26 // InjectedFiles is the number of injected files allowed for each project. 27 InjectedFiles int `json:"injected_files"` 28 29 // KeyPairs is number of ssh keypairs. 30 KeyPairs int `json:"key_pairs"` 31 32 // MetadataItems is number of metadata items allowed for each instance. 33 MetadataItems int `json:"metadata_items"` 34 35 // RAM is megabytes allowed for each instance. 36 RAM int `json:"ram"` 37 38 // SecurityGroupRules is number of security group rules allowed for each 39 // security group. 40 SecurityGroupRules int `json:"security_group_rules"` 41 42 // SecurityGroups is the number of security groups allowed for each project. 43 SecurityGroups int `json:"security_groups"` 44 45 // Cores is number of instance cores allowed for each project. 46 Cores int `json:"cores"` 47 48 // Instances is number of instances allowed for each project. 49 Instances int `json:"instances"` 50 51 // ServerGroups is the number of ServerGroups allowed for the project. 52 ServerGroups int `json:"server_groups"` 53 54 // ServerGroupMembers is the number of members for each ServerGroup. 55 ServerGroupMembers int `json:"server_group_members"` 56 } 57 58 // QuotaDetailSet represents details of both operational limits of compute 59 // resources and the current usage of those resources. 60 type QuotaDetailSet struct { 61 // ID is the tenant ID associated with this QuotaDetailSet. 62 ID string `json:"id"` 63 64 // FixedIPs is number of fixed ips alloted this QuotaDetailSet. 65 FixedIPs QuotaDetail `json:"fixed_ips"` 66 67 // FloatingIPs is number of floating ips alloted this QuotaDetailSet. 68 FloatingIPs QuotaDetail `json:"floating_ips"` 69 70 // InjectedFileContentBytes is the allowed bytes for each injected file. 71 InjectedFileContentBytes QuotaDetail `json:"injected_file_content_bytes"` 72 73 // InjectedFilePathBytes is allowed bytes for each injected file path. 74 InjectedFilePathBytes QuotaDetail `json:"injected_file_path_bytes"` 75 76 // InjectedFiles is the number of injected files allowed for each project. 77 InjectedFiles QuotaDetail `json:"injected_files"` 78 79 // KeyPairs is number of ssh keypairs. 80 KeyPairs QuotaDetail `json:"key_pairs"` 81 82 // MetadataItems is number of metadata items allowed for each instance. 83 MetadataItems QuotaDetail `json:"metadata_items"` 84 85 // RAM is megabytes allowed for each instance. 86 RAM QuotaDetail `json:"ram"` 87 88 // SecurityGroupRules is number of security group rules allowed for each 89 // security group. 90 SecurityGroupRules QuotaDetail `json:"security_group_rules"` 91 92 // SecurityGroups is the number of security groups allowed for each project. 93 SecurityGroups QuotaDetail `json:"security_groups"` 94 95 // Cores is number of instance cores allowed for each project. 96 Cores QuotaDetail `json:"cores"` 97 98 // Instances is number of instances allowed for each project. 99 Instances QuotaDetail `json:"instances"` 100 101 // ServerGroups is the number of ServerGroups allowed for the project. 102 ServerGroups QuotaDetail `json:"server_groups"` 103 104 // ServerGroupMembers is the number of members for each ServerGroup. 105 ServerGroupMembers QuotaDetail `json:"server_group_members"` 106 } 107 108 // QuotaDetail is a set of details about a single operational limit that allows 109 // for control of compute usage. 110 type QuotaDetail struct { 111 // InUse is the current number of provisioned/allocated resources of the 112 // given type. 113 InUse int `json:"in_use"` 114 115 // Reserved is a transitional state when a claim against quota has been made 116 // but the resource is not yet fully online. 117 Reserved int `json:"reserved"` 118 119 // Limit is the maximum number of a given resource that can be 120 // allocated/provisioned. This is what "quota" usually refers to. 121 Limit int `json:"limit"` 122 } 123 124 // QuotaSetPage stores a single page of all QuotaSet results from a List call. 125 type QuotaSetPage struct { 126 pagination.SinglePageBase 127 } 128 129 // IsEmpty determines whether or not a QuotaSetsetPage is empty. 130 func (page QuotaSetPage) IsEmpty() (bool, error) { 131 ks, err := ExtractQuotaSets(page) 132 return len(ks) == 0, err 133 } 134 135 // ExtractQuotaSets interprets a page of results as a slice of QuotaSets. 136 func ExtractQuotaSets(r pagination.Page) ([]QuotaSet, error) { 137 var s struct { 138 QuotaSets []QuotaSet `json:"quotas"` 139 } 140 err := (r.(QuotaSetPage)).ExtractInto(&s) 141 return s.QuotaSets, err 142 } 143 144 type quotaResult struct { 145 golangsdk.Result 146 } 147 148 // Extract is a method that attempts to interpret any QuotaSet resource response 149 // as a QuotaSet struct. 150 func (r quotaResult) Extract() (*QuotaSet, error) { 151 var s struct { 152 QuotaSet *QuotaSet `json:"quota_set"` 153 } 154 err := r.ExtractInto(&s) 155 return s.QuotaSet, err 156 } 157 158 // GetResult is the response from a Get operation. Call its Extract method to 159 // interpret it as a QuotaSet. 160 type GetResult struct { 161 quotaResult 162 } 163 164 // UpdateResult is the response from a Update operation. Call its Extract method 165 // to interpret it as a QuotaSet. 166 type UpdateResult struct { 167 quotaResult 168 } 169 170 // DeleteResult is the response from a Delete operation. Call its Extract method 171 // to interpret it as a QuotaSet. 172 type DeleteResult struct { 173 quotaResult 174 } 175 176 type quotaDetailResult struct { 177 golangsdk.Result 178 } 179 180 // GetDetailResult is the response from a Get operation. Call its Extract 181 // method to interpret it as a QuotaSet. 182 type GetDetailResult struct { 183 quotaDetailResult 184 } 185 186 // Extract is a method that attempts to interpret any QuotaDetailSet 187 // resource response as a set of QuotaDetailSet structs. 188 func (r quotaDetailResult) Extract() (QuotaDetailSet, error) { 189 var s struct { 190 QuotaData QuotaDetailSet `json:"quota_set"` 191 } 192 err := r.ExtractInto(&s) 193 return s.QuotaData, err 194 }