blob: f551861f3b8b66d7b105f2e016f73cade8d70132 [file] [log] [blame]
ehdou10f1f852016-10-14 20:58:23 +03001package sharenetworks
2
3import "github.com/gophercloud/gophercloud"
4
5// CreateOptsBuilder allows extensions to add additional parameters to the
6// Create request.
7type CreateOptsBuilder interface {
8 ToShareNetworkCreateMap() (map[string]interface{}, error)
9}
10
11// CreateOpts contains options for creating a ShareNetwork. This object is
12// passed to the sharenetworks.Create function. For more information about
13// these parameters, see the ShareNetwork object.
14type CreateOpts struct {
15 // The UUID of the Neutron network to set up for share servers
16 NeutronNetID string `json:"neutron_net_id,omitempty"`
17 // The UUID of the Neutron subnet to set up for share servers
18 NeutronSubnetID string `json:"neutron_subnet_id,omitempty"`
19 // The UUID of the nova network to set up for share servers
20 NovaNetID string `json:"nova_net_id,omitempty"`
21 // The share network name
22 Name string `json:"name"`
23 // The share network description
24 Description string `json:"description"`
25}
26
27// ToShareNetworkCreateMap assembles a request body based on the contents of a
28// CreateOpts.
29func (opts CreateOpts) ToShareNetworkCreateMap() (map[string]interface{}, error) {
30 return gophercloud.BuildRequestBody(opts, "share_network")
31}
32
33// Create will create a new ShareNetwork based on the values in CreateOpts. To
34// extract the ShareNetwork object from the response, call the Extract method
35// on the CreateResult.
36func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
37 b, err := opts.ToShareNetworkCreateMap()
38 if err != nil {
39 r.Err = err
40 return
41 }
42 _, r.Err = client.Post(createURL(client), b, &r.Body, &gophercloud.RequestOpts{
43 OkCodes: []int{200, 202},
44 })
45 return
46}