blob: 7b9260628175cedca2743fa5c97cf4f61a05e677 [file] [log] [blame]
package secgroups
import (
"github.com/racker/perigee"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
func List(client *gophercloud.ServiceClient) pagination.Pager {
createPage := func(r pagination.PageResult) pagination.Page {
return SecurityGroupPage{pagination.SinglePageBase(r)}
}
return pagination.NewPager(client, rootURL(client), createPage)
}
type CreateOpts struct {
// Optional - the name of your security group. If no value provided, null
// will be set.
Name string `json:"name,omitempty"`
// Optional - the description of your security group. If no value provided,
// null will be set.
Description string `json:"description,omitempty"`
}
func Create(client *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
var result CreateResult
reqBody := struct {
CreateOpts `json:"security_group"`
}{opts}
_, result.Err = perigee.Request("POST", rootURL(client), perigee.Options{
Results: &result.Body,
ReqBody: &reqBody,
MoreHeaders: client.AuthenticatedHeaders(),
OkCodes: []int{200},
})
return result
}