github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/elb/v3/loadbalancers/results.go (about) 1 package loadbalancers 2 3 import ( 4 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/openstack/common/structs" 6 "github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags" 7 "github.com/opentelekomcloud/gophertelekomcloud/pagination" 8 ) 9 10 // LoadBalancer is the primary load balancing configuration object that 11 // specifies the virtual IP address on which client traffic is received, as well 12 // as other details such as the load balancing method to be use, protocol, etc. 13 type LoadBalancer struct { 14 // The unique ID for the LoadBalancer. 15 ID string `json:"id"` 16 17 // Human-readable description for the Loadbalancer. 18 Description string `json:"description"` 19 20 // The provisioning status of the LoadBalancer. 21 // This value is ACTIVE, PENDING_CREATE or ERROR. 22 ProvisioningStatus string `json:"provisioning_status"` 23 24 // The administrative state of the Loadbalancer. 25 // A valid value is true (UP) or false (DOWN). 26 AdminStateUp bool `json:"admin_state_up"` 27 28 // The name of the provider. 29 Provider string `json:"provider"` 30 31 // Pools are the pools related to this Loadbalancer. 32 Pools []structs.ResourceRef `json:"pools"` 33 34 // Listeners are the listeners related to this Loadbalancer. 35 Listeners []structs.ResourceRef `json:"listeners"` 36 37 // The operating status of the LoadBalancer. This value is ONLINE or OFFLINE. 38 OperatingStatus string `json:"operating_status"` 39 40 // The IP address of the Loadbalancer. 41 VipAddress string `json:"vip_address"` 42 43 // The UUID of the subnet on which to allocate the virtual IP for the 44 // Loadbalancer address. 45 VipSubnetCidrID string `json:"vip_subnet_cidr_id"` 46 47 // Human-readable name for the LoadBalancer. Does not have to be unique. 48 Name string `json:"name"` 49 50 // Owner of the LoadBalancer. 51 ProjectID string `json:"project_id"` 52 53 // The UUID of the port associated with the IP address. 54 VipPortID string `json:"vip_port_id"` 55 56 // The UUID of a flavor if set. 57 Tags []tags.ResourceTag `json:"tags"` 58 59 // Guaranteed. 60 Guaranteed bool `json:"guaranteed"` 61 62 // The VPC ID. 63 VpcID string `json:"vpc_id"` 64 65 // EIP Info. 66 Eips []EipInfo `json:"eips"` 67 68 // IpV6 Vip Address. 69 IpV6VipAddress string `json:"ipv6_vip_address"` 70 71 // IpV6 Vip VirSubnet ID. 72 IpV6VipSubnetID string `json:"ipv6_vip_virsubnet_id"` 73 74 // IpV6 Vip Port ID. 75 IpV6VipPortID string `json:"ipv6_vip_port_id"` 76 77 // Availability Zone List. 78 AvailabilityZoneList []string `json:"availability_zone_list"` 79 80 // L4 Flavor ID. 81 L4FlavorID string `json:"l4_flavor_id"` 82 83 // L4 Scale Flavor ID. 84 L4ScaleFlavorID string `json:"l4_scale_flavor_id"` 85 86 // L7 Flavor ID. 87 L7FlavorID string `json:"l7_flavor_id"` 88 89 // L7 Scale Flavor ID. 90 L7ScaleFlavorID string `json:"l7_scale_flavor_id"` 91 92 // Public IP Info. 93 PublicIps []PublicIpInfo `json:"publicips"` 94 95 // Elb VirSubnet IDs. 96 ElbSubnetIDs []string `json:"elb_virsubnet_ids"` 97 98 // Elb VirSubnet Type. 99 ElbSubnetType string `json:"elb_virsubnet_type"` 100 101 // Ip Target Enable. 102 IpTargetEnable bool `json:"ip_target_enable"` 103 104 // Frozen Scene. 105 FrozenScene string `json:"frozen_scene"` 106 107 // Ipv6 Bandwidth. 108 IpV6Bandwidth BandwidthRef `json:"ipv6_bandwidth"` 109 110 CreatedAt string `json:"created_at"` 111 UpdatedAt string `json:"updated_at"` 112 113 // Ip Target Enable. 114 DeletionProtectionEnable bool `json:"deletion_protection_enable"` 115 } 116 117 type EipInfo struct { 118 // Eip ID 119 EipID string `json:"eip_id"` 120 // Eip Address 121 EipAddress string `json:"eip_address"` 122 // Eip Address 123 IpVersion int `json:"ip_version"` 124 } 125 126 type PublicIpInfo struct { 127 // Public IP ID 128 PublicIpID string `json:"publicip_id"` 129 // Public IP Address 130 PublicIpAddress string `json:"publicip_address"` 131 // IP Version 132 IpVersion int `json:"ip_version"` 133 } 134 135 // StatusTree represents the status of a loadbalancer. 136 type StatusTree struct { 137 Loadbalancer *LoadBalancer `json:"loadbalancer"` 138 } 139 140 type commonResult struct { 141 golangsdk.Result 142 } 143 144 // Extract is a function that accepts a result and extracts a loadbalancer. 145 func (r commonResult) Extract() (*LoadBalancer, error) { 146 s := new(LoadBalancer) 147 err := r.ExtractIntoStructPtr(s, "loadbalancer") 148 if err != nil { 149 return nil, err 150 } 151 return s, nil 152 } 153 154 // GetStatusesResult represents the result of a GetStatuses operation. 155 // Call its Extract method to interpret it as a StatusTree. 156 type GetStatusesResult struct { 157 golangsdk.Result 158 } 159 160 // Extract is a function that accepts a result and extracts the status of 161 // a Loadbalancer. 162 func (r GetStatusesResult) Extract() (*StatusTree, error) { 163 s := new(StatusTree) 164 err := r.ExtractIntoStructPtr(s, "statuses") 165 if err != nil { 166 return nil, err 167 } 168 return s, nil 169 } 170 171 // LoadbalancerPage is the page returned by a pager when traversing over a 172 // collection of loadbalancer. 173 type LoadbalancerPage struct { 174 pagination.PageWithInfo 175 } 176 177 // IsEmpty checks whether a FlavorsPage struct is empty. 178 func (r LoadbalancerPage) IsEmpty() (bool, error) { 179 is, err := ExtractLoadbalancers(r) 180 return len(is) == 0, err 181 } 182 183 // ExtractLoadbalancers accepts a Page struct, specifically a LoadbalancerPage struct, 184 // and extracts the elements into a slice of loadbalancer structs. In other words, 185 // a generic collection is mapped into a relevant slice. 186 func ExtractLoadbalancers(r pagination.Page) ([]LoadBalancer, error) { 187 var s []LoadBalancer 188 err := (r.(LoadbalancerPage)).ExtractIntoSlicePtr(&s, "loadbalancers") 189 if err != nil { 190 return nil, err 191 } 192 return s, nil 193 } 194 195 // CreateResult represents the result of a create operation. Call its Extract 196 // method to interpret it as a LoadBalancer. 197 type CreateResult struct { 198 commonResult 199 } 200 201 // GetResult represents the result of a get operation. Call its Extract 202 // method to interpret it as a LoadBalancer. 203 type GetResult struct { 204 commonResult 205 } 206 207 // UpdateResult represents the result of an update operation. Call its Extract 208 // method to interpret it as a LoadBalancer. 209 type UpdateResult struct { 210 commonResult 211 } 212 213 // DeleteResult represents the result of a delete operation. Call its 214 // ExtractErr method to determine if the request succeeded or failed. 215 type DeleteResult struct { 216 golangsdk.ErrResult 217 }