1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
package quotas
import (
"github.com/gophercloud/gophercloud"
)
// CreateOptsBuilder Builder.
type CreateOptsBuilder interface {
ToQuotaCreateMap() (map[string]interface{}, error)
}
// CreateOpts params
type CreateOpts struct {
ProjectID string `json:"project_id"`
Resource string `json:"resource"`
HardLimit int `json:"hard_limit"`
}
// ToQuotaCreateMap constructs a request body from CreateOpts.
func (opts CreateOpts) ToQuotaCreateMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}
// Create requests the creation of a new quota.
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
b, err := opts.ToQuotaCreateMap()
if err != nil {
r.Err = err
return
}
resp, err := client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{201},
})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
|