github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/instances/AttachEip.go (about) 1 package instances 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/build" 6 ) 7 8 type AttachEipOpts struct { 9 InstanceId string `json:"-"` 10 // NOTICE 11 // When is_bind is true, public_ip is mandatory. 12 // Specifies the EIP to be bound. The value must be in the standard IP address format. 13 PublicIp string `json:"public_ip,omitempty"` 14 // NOTICE 15 // When is_bind is true, public_ip_id is mandatory. 16 // Specifies the EIP ID. The value must be in the standard UUID format. 17 PublicIpId string `json:"public_ip_id,omitempty"` 18 // true: Bind an EIP. 19 // false: Unbind an EIP. 20 IsBind *bool `json:"is_bind" required:"true"` 21 } 22 23 func AttachEip(client *golangsdk.ServiceClient, opts AttachEipOpts) (err error) { 24 b, err := build.RequestBody(opts, "") 25 if err != nil { 26 return 27 } 28 29 // PUT https://{Endpoint}/v3/{project_id}/instances/{instance_id}/public-ip 30 _, err = client.Put(client.ServiceURL("instances", opts.InstanceId, "public-ip"), b, nil, &golangsdk.RequestOpts{ 31 OkCodes: []int{200}, 32 }) 33 return 34 }