github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/elb/v3/pools/results.go (about)

     1  package pools
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/structs"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/pagination"
     7  )
     8  
     9  // Pool represents a logical set of devices, such as web servers, that you
    10  // group together to receive and process traffic. The load balancing function
    11  // chooses a Member of the Pool according to the configured load balancing
    12  // method to handle the new requests or connections received on the VIP address.
    13  type Pool struct {
    14  	// The load-balancer algorithm, which is round-robin, least-connections, and
    15  	// so on. This value, which must be supported, is dependent on the provider.
    16  	// Round-robin must be supported.
    17  	LBMethod string `json:"lb_algorithm"`
    18  
    19  	// The protocol of the Pool, which is TCP, HTTP, or HTTPS.
    20  	Protocol string `json:"protocol"`
    21  
    22  	// Description for the Pool.
    23  	Description string `json:"description"`
    24  
    25  	// A list of listeners objects IDs.
    26  	Listeners []structs.ResourceRef `json:"listeners"`
    27  
    28  	// A list of member objects IDs.
    29  	Members []structs.ResourceRef `json:"members"`
    30  
    31  	// The ID of associated health monitor.
    32  	MonitorID string `json:"healthmonitor_id"`
    33  
    34  	// The administrative state of the Pool, which is up (true) or down (false).
    35  	AdminStateUp bool `json:"admin_state_up"`
    36  
    37  	// Pool name. Does not have to be unique.
    38  	Name string `json:"name"`
    39  
    40  	ProjectID string `json:"project_id"`
    41  
    42  	// The unique ID for the Pool.
    43  	ID string `json:"id"`
    44  
    45  	// A list of load balancer objects IDs.
    46  	Loadbalancers []structs.ResourceRef `json:"loadbalancers"`
    47  
    48  	// Indicates whether connections in the same session will be processed by the
    49  	// same Pool member or not.
    50  	Persistence *SessionPersistence `json:"session_persistence"`
    51  
    52  	IpVersion string `json:"ip_version"`
    53  
    54  	SlowStart *SlowStart `json:"slow_start"`
    55  
    56  	// Deletion protection for the pool.
    57  	DeletionProtectionEnable bool `json:"member_deletion_protection_enable"`
    58  
    59  	// ID of the VPC where the backend server group works.
    60  	VpcId string `json:"vpc_id"`
    61  
    62  	// Type of the backend server group.
    63  	Type string `json:"type"`
    64  }
    65  
    66  // PoolPage is the page returned by a pager when traversing over a
    67  // collection of pools.
    68  type PoolPage struct {
    69  	pagination.PageWithInfo
    70  }
    71  
    72  // IsEmpty checks whether a PoolPage struct is empty.
    73  func (r PoolPage) IsEmpty() (bool, error) {
    74  	is, err := ExtractPools(r)
    75  	return len(is) == 0, err
    76  }
    77  
    78  // ExtractPools accepts a Page struct, specifically a PoolPage struct,
    79  // and extracts the elements into a slice of Pool structs. In other words,
    80  // a generic collection is mapped into a relevant slice.
    81  func ExtractPools(r pagination.Page) ([]Pool, error) {
    82  	var s []Pool
    83  	err := (r.(PoolPage)).ExtractIntoSlicePtr(&s, "pools")
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  	return s, nil
    88  }
    89  
    90  type commonResult struct {
    91  	golangsdk.Result
    92  }
    93  
    94  // Extract is a function that accepts a result and extracts a pool.
    95  func (r commonResult) Extract() (*Pool, error) {
    96  	s := new(Pool)
    97  	err := r.ExtractIntoStructPtr(s, "pool")
    98  	if err != nil {
    99  		return nil, err
   100  	}
   101  	return s, nil
   102  }
   103  
   104  // CreateResult represents the result of a Create operation. Call its Extract
   105  // method to interpret the result as a Pool.
   106  type CreateResult struct {
   107  	commonResult
   108  }
   109  
   110  // GetResult represents the result of a Get operation. Call its Extract
   111  // method to interpret the result as a Pool.
   112  type GetResult struct {
   113  	commonResult
   114  }
   115  
   116  // UpdateResult represents the result of an Update operation. Call its Extract
   117  // method to interpret the result as a Pool.
   118  type UpdateResult struct {
   119  	commonResult
   120  }
   121  
   122  // DeleteResult represents the result of a Delete operation. Call its
   123  // ExtractErr method to determine if the request succeeded or failed.
   124  type DeleteResult struct {
   125  	golangsdk.ErrResult
   126  }