github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/quotasets/requests.go (about) 1 package quotasets 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 ) 6 7 // Get returns public data about a previously created QuotaSet. 8 func Get(client *golangsdk.ServiceClient, tenantID string) (r GetResult) { 9 _, r.Err = client.Get(getURL(client, tenantID), &r.Body, nil) 10 return 11 } 12 13 // GetDetail returns detailed public data about a previously created QuotaSet. 14 func GetDetail(client *golangsdk.ServiceClient, tenantID string) (r GetDetailResult) { 15 _, r.Err = client.Get(getDetailURL(client, tenantID), &r.Body, nil) 16 return 17 } 18 19 // Updates the quotas for the given tenantID and returns the new QuotaSet. 20 func Update(client *golangsdk.ServiceClient, tenantID string, opts UpdateOptsBuilder) (r UpdateResult) { 21 reqBody, err := opts.ToComputeQuotaUpdateMap() 22 if err != nil { 23 r.Err = err 24 return 25 } 26 27 _, r.Err = client.Put(updateURL(client, tenantID), reqBody, &r.Body, &golangsdk.RequestOpts{OkCodes: []int{200}}) 28 return 29 } 30 31 // Resets the quotas for the given tenant to their default values. 32 func Delete(client *golangsdk.ServiceClient, tenantID string) (r DeleteResult) { 33 _, r.Err = client.Delete(deleteURL(client, tenantID), nil) 34 return 35 } 36 37 // Options for Updating the quotas of a Tenant. 38 // All int-values are pointers so they can be nil if they are not needed. 39 // You can use gopercloud.IntToPointer() for convenience 40 type UpdateOpts struct { 41 // FixedIPs is number of fixed ips alloted this quota_set. 42 FixedIPs *int `json:"fixed_ips,omitempty"` 43 44 // FloatingIPs is number of floating ips alloted this quota_set. 45 FloatingIPs *int `json:"floating_ips,omitempty"` 46 47 // InjectedFileContentBytes is content bytes allowed for each injected file. 48 InjectedFileContentBytes *int `json:"injected_file_content_bytes,omitempty"` 49 50 // InjectedFilePathBytes is allowed bytes for each injected file path. 51 InjectedFilePathBytes *int `json:"injected_file_path_bytes,omitempty"` 52 53 // InjectedFiles is injected files allowed for each project. 54 InjectedFiles *int `json:"injected_files,omitempty"` 55 56 // KeyPairs is number of ssh keypairs. 57 KeyPairs *int `json:"key_pairs,omitempty"` 58 59 // MetadataItems is number of metadata items allowed for each instance. 60 MetadataItems *int `json:"metadata_items,omitempty"` 61 62 // RAM is megabytes allowed for each instance. 63 RAM *int `json:"ram,omitempty"` 64 65 // SecurityGroupRules is rules allowed for each security group. 66 SecurityGroupRules *int `json:"security_group_rules,omitempty"` 67 68 // SecurityGroups security groups allowed for each project. 69 SecurityGroups *int `json:"security_groups,omitempty"` 70 71 // Cores is number of instance cores allowed for each project. 72 Cores *int `json:"cores,omitempty"` 73 74 // Instances is number of instances allowed for each project. 75 Instances *int `json:"instances,omitempty"` 76 77 // Number of ServerGroups allowed for the project. 78 ServerGroups *int `json:"server_groups,omitempty"` 79 80 // Max number of Members for each ServerGroup. 81 ServerGroupMembers *int `json:"server_group_members,omitempty"` 82 83 // Force will update the quotaset even if the quota has already been used 84 // and the reserved quota exceeds the new quota. 85 Force bool `json:"force,omitempty"` 86 } 87 88 // UpdateOptsBuilder enables extensins to add parameters to the update request. 89 type UpdateOptsBuilder interface { 90 // Extra specific name to prevent collisions with interfaces for other quotas 91 // (e.g. neutron) 92 ToComputeQuotaUpdateMap() (map[string]interface{}, error) 93 } 94 95 // ToComputeQuotaUpdateMap builds the update options into a serializable 96 // format. 97 func (opts UpdateOpts) ToComputeQuotaUpdateMap() (map[string]interface{}, error) { 98 return golangsdk.BuildRequestBody(opts, "quota_set") 99 }