blob: 7b9260628175cedca2743fa5c97cf4f61a05e677 [file] [log] [blame]
Jamie Hannaford924c09d2014-11-19 12:05:38 +01001package secgroups
2
3import (
Jamie Hannaforda493e642014-11-19 12:40:30 +01004 "github.com/racker/perigee"
5
Jamie Hannaford924c09d2014-11-19 12:05:38 +01006 "github.com/rackspace/gophercloud"
7 "github.com/rackspace/gophercloud/pagination"
8)
9
10func List(client *gophercloud.ServiceClient) pagination.Pager {
11 createPage := func(r pagination.PageResult) pagination.Page {
12 return SecurityGroupPage{pagination.SinglePageBase(r)}
13 }
14
15 return pagination.NewPager(client, rootURL(client), createPage)
16}
Jamie Hannaforda493e642014-11-19 12:40:30 +010017
18type CreateOpts struct {
19 // Optional - the name of your security group. If no value provided, null
20 // will be set.
21 Name string `json:"name,omitempty"`
22
23 // Optional - the description of your security group. If no value provided,
24 // null will be set.
25 Description string `json:"description,omitempty"`
26}
27
28func Create(client *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
29 var result CreateResult
30
31 reqBody := struct {
32 CreateOpts `json:"security_group"`
33 }{opts}
34
35 _, result.Err = perigee.Request("POST", rootURL(client), perigee.Options{
36 Results: &result.Body,
37 ReqBody: &reqBody,
38 MoreHeaders: client.AuthenticatedHeaders(),
39 OkCodes: []int{200},
40 })
41
42 return result
43}