github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/nat/v3/gateways/requests.go (about) 1 package gateways 2 3 import ( 4 "github.com/chnsz/golangsdk" 5 "github.com/chnsz/golangsdk/openstack/common/tags" 6 ) 7 8 // CreateOpts is the structure used to create a new private NAT gateway. 9 type CreateOpts struct { 10 // The name of the private NAT gateway. 11 // The valid length is limited from `1` to `64`, only letters, digits, hyphens (-) and underscores (_) are allowed. 12 Name string `json:"name" required:"true"` 13 // The subnet configuration of the private NAT gateway. 14 DownLinkVpcs []DownLinkVpc `json:"downlink_vpcs" required:"true"` 15 // The description of the private NAT gateway, which contain maximum of `255` characters, and 16 // angle brackets (<) and (>) are not allowed. 17 Description string `json:"description,omitempty"` 18 // The specification of the private NAT gateway. 19 // The valid values are as follows: 20 // + **Small**: Small type, which supports up to `20` rules, `200 Mbit/s` bandwidth, `20,000` PPS and `2,000` SNAT 21 // connections. 22 // + **Medium**: Medium type, which supports up to `50` rules, `500 Mbit/s` bandwidth, `50,000` PPS and `5,000` SNAT 23 // connections. 24 // + **Large**: Large type, which supports up to `200` rules, `2 Gbit/s` bandwidth, `200,000` PPS and `20,000` SNAT 25 // connections. 26 // + **Extra-Large**: Extra-large type, which supports up to `500` rules, `5 Gbit/s` bandwidth, `500,000` PPS and 27 // `50,000` SNAT connections. 28 Spec string `json:"spec,omitempty"` 29 // The enterprise project ID to which the private NAT gateway belongs. 30 EnterpriseProjectId string `json:"enterprise_project_id,omitempty"` 31 // The key/value pairs to associate with the NAT geteway. 32 Tags []tags.ResourceTag `json:"tags,omitempty"` 33 } 34 35 // DownLinkVpc is an object that represents the subnet configuration to which private NAT gateway belongs. 36 type DownLinkVpc struct { 37 SubnetId string `json:"virsubnet_id" required:"true"` 38 } 39 40 var requestOpts = golangsdk.RequestOpts{ 41 MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"}, 42 } 43 44 // Create is a method used to create a new private NAT gateway using given parameters. 45 func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*Gateway, error) { 46 b, err := golangsdk.BuildRequestBody(opts, "gateway") 47 if err != nil { 48 return nil, err 49 } 50 51 var r createResp 52 _, err = c.Post(rootURL(c), b, &r, &golangsdk.RequestOpts{ 53 MoreHeaders: requestOpts.MoreHeaders, 54 }) 55 return &r.Gateway, err 56 } 57 58 // Get is a method used to obtain the private NAT gateway detail by its ID. 59 func Get(c *golangsdk.ServiceClient, gatewayId string) (*Gateway, error) { 60 var r queryResp 61 _, err := c.Get(resourceURL(c, gatewayId), &r, &golangsdk.RequestOpts{ 62 MoreHeaders: requestOpts.MoreHeaders, 63 }) 64 return &r.Gateway, err 65 } 66 67 // UpdateOpts is the structure used to modify an existing private NAT gateway. 68 type UpdateOpts struct { 69 // The name of the private NAT gateway. 70 // The valid length is limited from `1` to `64`, only letters, digits, hyphens (-) and underscores (_) are allowed. 71 Name string `json:"name,omitempty"` 72 // The description of the private NAT gateway, which contain maximum of `255` characters, and 73 // angle brackets (<) and (>) are not allowed. 74 Description *string `json:"description,omitempty"` 75 // The specification of the private NAT gateway. 76 // The valid values are as follows: 77 // + **Small**: Small type, which supports up to `20` rules, `200 Mbit/s` bandwidth, `20,000` PPS and `2,000` SNAT 78 // connections. 79 // + **Medium**: Medium type, which supports up to `50` rules, `500 Mbit/s` bandwidth, `50,000` PPS and `5,000` SNAT 80 // connections. 81 // + **Large**: Large type, which supports up to `200` rules, `2 Gbit/s` bandwidth, `200,000` PPS and `20,000` SNAT 82 // connections. 83 // + **Extra-Large**: Extra-large type, which supports up to `500` rules, `5 Gbit/s` bandwidth, `500,000` PPS and 84 // `50,000` SNAT connections. 85 Spec string `json:"spec,omitempty"` 86 } 87 88 // Update is a method used to modify an existing private NAT gateway using given parameters. 89 func Update(c *golangsdk.ServiceClient, gatewayId string, opts UpdateOpts) (*Gateway, error) { 90 b, err := golangsdk.BuildRequestBody(opts, "gateway") 91 if err != nil { 92 return nil, err 93 } 94 95 var r updateResp 96 _, err = c.Put(resourceURL(c, gatewayId), b, &r, &golangsdk.RequestOpts{ 97 MoreHeaders: requestOpts.MoreHeaders, 98 }) 99 return &r.Gateway, err 100 } 101 102 // Delete is a method to remove the specified private NAT gateway using its ID. 103 func Delete(c *golangsdk.ServiceClient, gatewayId string) error { 104 _, err := c.Delete(resourceURL(c, gatewayId), &golangsdk.RequestOpts{ 105 MoreHeaders: requestOpts.MoreHeaders, 106 }) 107 return err 108 }