github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/waf-premium/v1/instances/Create.go (about) 1 package instances 2 3 import ( 4 "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 // Billing mode. Currently, only pay-per-use billing (30) is 11 // supported. Make sure your account balance is enough, or 12 // the dedicated WAF engine will forward requests directly to 13 // the origin server without inspection. 14 ChargeMode int `json:"chargemode"` 15 // Region where a dedicated engine is to be created. Its 16 // value is EU-DE. 17 Region string `json:"region" required:"true"` 18 // AZ where the dedicated engine is to be created. 19 AvailabilityZone string `json:"available_zone" required:"true"` 20 // Dedicated engine CPU architecture. Its value can be x86. 21 Architecture string `json:"arch" required:"true"` 22 // Prefix of the dedicated WAF engine name, which is user-defined 23 InstanceName string `json:"instancename" required:"true"` 24 // Specification of the dedicated engine version. The value can be 25 // waf.instance.enterprise or waf.instance.professional. An 26 // enterprise edition dedicated engine has more functions 27 // than a professional edition one. For more details, see the 28 // Web Application Firewall (WAF) User Guide 29 Specification string `json:"specification" required:"true"` 30 // ID of the specification of the ECS hosting the dedicated 31 // engine. It can be obtained by calling the ECS ListFlavors API. 32 // For the enterprise edition, ECS specification with 8 vCPUs 33 // and 16 GB memory are used. For the professional edition, 34 // ECS specification with 2 vCPUs and 4 GB memory are used. 35 Flavor string `json:"cpu_flavor" required:"true"` 36 // ID of the VPC where the dedicated engine is located. It 37 // can be obtained by calling the ListVpcs API. 38 VpcId string `json:"vpc_id" required:"true"` 39 // ID of the VPC subnet where the dedicated engine is 40 // located. It can be obtained by calling the ListSubnets API. 41 // subnet_id has the same value as network_id obtained by 42 // calling the OpenStack APIs. 43 SubnetId string `json:"subnet_id" required:"true"` 44 // ID of the security group where the dedicated engine is 45 // located. It can be obtained by calling the ListSecurityGroups API. 46 SecurityGroupsId []string `json:"security_group" required:"true"` 47 // Number of dedicated engines to be provisioned 48 Count int `json:"count" required:"true"` 49 // Whether to create a dedicated engine instance of the network interface type. 50 // Its value has to be true. 51 ResTenant *bool `json:"res_tenant" required:"true"` 52 } 53 54 // Create will create a new instance on the values in CreateOpts. 55 func Create(client *golangsdk.ServiceClient, opts CreateOpts) (*InstanceResponse, error) { 56 b, err := build.RequestBody(opts, "") 57 if err != nil { 58 return nil, err 59 } 60 61 // POST /v1/{project_id}/premium-waf/instance 62 raw, err := client.Post(client.ServiceURL("premium-waf", "instance"), b, 63 nil, &golangsdk.RequestOpts{ 64 OkCodes: []int{201}, 65 }) 66 if err != nil { 67 return nil, err 68 } 69 70 var res InstanceResponse 71 err = extract.Into(raw.Body, &res) 72 return &res, err 73 } 74 75 type InstanceResponse struct { 76 Instances []Info `json:"instances"` 77 } 78 79 type Info struct { 80 // Instance id 81 Id string `json:"id"` 82 // Instance name 83 Name string `json:"name"` 84 }