github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/networking/v2/extensions/elb/backendecs/results.go (about)

     1  package backendecs
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/huaweicloud/golangsdk"
     7  )
     8  
     9  type Listener struct {
    10  	ID string `json:"id"`
    11  }
    12  
    13  type Backend struct {
    14  	ServerAddress string     `json:"server_address"`
    15  	ID            string     `json:"id"`
    16  	Address       string     `json:"address"`
    17  	Status        string     `json:"status"`
    18  	HealthStatus  string     `json:"health_status"`
    19  	UpdateTime    string     `json:"update_time"`
    20  	CreateTime    string     `json:"create_time"`
    21  	ServerName    string     `json:"server_name"`
    22  	ServerID      string     `json:"server_id"`
    23  	Listeners     []Listener `json:"listeners"`
    24  }
    25  
    26  // GetResult represents the result of a get operation.
    27  type GetResult struct {
    28  	golangsdk.Result
    29  }
    30  
    31  func (r GetResult) Extract() (*Backend, error) {
    32  	var s []Backend
    33  	err := r.ExtractInto(&s)
    34  	if err == nil {
    35  		if len(s) != 1 {
    36  			return nil, fmt.Errorf("get %d backends: %#v", len(s), s)
    37  		}
    38  		return &(s[0]), nil
    39  	}
    40  	return nil, err
    41  }