github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcaas/v2/virtual-gateway/Create.go (about) 1 package virtual_gateway 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 virtual gateway name. 11 Name string `json:"name,omitempty"` 12 // Provides supplementary information about the virtual gateway. 13 Description string `json:"description,omitempty"` 14 // Specifies the ID of the VPC to be accessed. 15 VpcId string `json:"vpc_id" required:"true"` 16 // Specifies the ID of the local endpoint group that records CIDR blocks of the VPC subnets. 17 LocalEndpointGroupId string `json:"local_ep_group_id" required:"true"` 18 // Specifies the BGP ASN of the virtual gateway. 19 BgpAsn int `json:"bgp_asn,omitempty"` 20 // Specifies the ID of the physical device used by the virtual gateway. 21 DeviceId string `json:"device_id,omitempty"` 22 // Specifies the ID of the redundant physical device used by the virtual gateway. 23 RedundantDeviceId string `json:"redundant_device_id,omitempty"` 24 // Specifies the virtual gateway type. The value can only be default. 25 Type string `json:"type"` 26 // Specifies the project ID. 27 ProjectId string `json:"tenant_id,omitempty"` 28 // Specifies the administrative status of the virtual gateway. 29 AdminStateUp *bool `json:"admin_state_up,omitempty"` 30 } 31 32 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*VirtualGateway, error) { 33 b, err := build.RequestBody(opts, "virtual_gateway") 34 if err != nil { 35 return nil, err 36 } 37 raw, err := c.Post(c.ServiceURL("dcaas", "virtual-gateways"), b, nil, &golangsdk.RequestOpts{ 38 OkCodes: []int{201}, 39 }) 40 if err != nil { 41 return nil, err 42 } 43 44 var res VirtualGateway 45 err = extract.IntoStructPtr(raw.Body, &res, "virtual_gateway") 46 return &res, err 47 }