github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcaas/v2/dc-endpoint-group/Create.go (about) 1 package dc_endpoint_group 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 7 ) 8 9 type CreateOpts struct { 10 // Specifies the project ID. 11 TenantId string `json:"tenant_id" required:"true"` 12 // Specifies the name of the Direct Connect endpoint group. 13 Name string `json:"name,omitempty"` 14 // Provides supplementary information about the Direct Connect endpoint group. 15 Description string `json:"description,omitempty"` 16 // Specifies the list of the endpoints in a Direct Connect endpoint group. 17 Endpoints []string `json:"endpoints" required:"true"` 18 // Specifies the type of the Direct Connect endpoints. The value can only be cidr. 19 Type string `json:"type,omitempty"` 20 } 21 22 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*DCEndpointGroup, error) { 23 b, err := build.RequestBody(opts, "dc_endpoint_group") 24 if err != nil { 25 return nil, err 26 } 27 raw, err := c.Post(c.ServiceURL("dcaas", "dc-endpoint-groups"), b, nil, &golangsdk.RequestOpts{ 28 OkCodes: []int{201}, 29 }) 30 if err != nil { 31 return nil, err 32 } 33 34 var res DCEndpointGroup 35 err = extract.IntoStructPtr(raw.Body, &res, "dc_endpoint_group") 36 return &res, err 37 }