github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/elb/v3/ipgroups/Create.go (about) 1 package ipgroups 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 // CreateOpts is the common options' struct used in this package's Create 9 // operation. 10 type CreateOpts struct { 11 // Specifies the IP address group name. 12 Name string `json:"name,omitempty"` 13 14 // Provides supplementary information about the IP address group. 15 Description string `json:"description,omitempty"` 16 17 // Specifies the project ID of the IP address group. 18 ProjectId string `json:"project_id,omitempty"` 19 20 // Specifies the IP addresses or CIDR blocks in the IP address group. [] indicates any IP address. 21 IpList *[]IpGroupOption `json:"ip_list,omitempty"` 22 } 23 24 type IpGroupOption struct { 25 // Specifies the IP addresses in the IP address group. 26 Ip string `json:"ip" required:"true"` 27 28 // Provides remarks about the IP address group. 29 Description string `json:"description"` 30 } 31 32 type DataStore struct { 33 // Specifies the DB engine. Its value can be any of the following and is case-insensitive: 34 // MySQL 35 // PostgreSQL 36 // SQLServer 37 Type string `json:"type" required:"true"` 38 // Specifies the database version. 39 // Example values: 40 // MySQL: 8.0 41 // PostgreSQL: 13 42 // SQLServer: 2017_SE 43 Version string `json:"version" required:"true"` 44 } 45 46 // Create is an operation which provisions a new IP address group based on the 47 // configuration defined in the CreateOpts struct. Once the request is 48 // validated and progress has started on the provisioning process, a 49 // IpGroup will be returned. 50 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*IpGroup, error) { 51 b, err := golangsdk.BuildRequestBody(opts, "ipgroup") 52 if err != nil { 53 return nil, err 54 } 55 raw, err := c.Post(c.ServiceURL("ipgroups"), b, nil, &golangsdk.RequestOpts{ 56 OkCodes: []int{201}, 57 }) 58 if err != nil { 59 return nil, err 60 } 61 62 var res IpGroup 63 err = extract.IntoStructPtr(raw.Body, &res, "ipgroup") 64 return &res, err 65 }