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

     1  package pools
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // Pool represents a logical set of devices, such as web servers, that you
     9  // group together to receive and process traffic. The load balancing function
    10  // chooses a member of the pool according to the configured load balancing
    11  // method to handle the new requests or connections received on the VIP address.
    12  // There is only one pool per virtual IP.
    13  type Pool struct {
    14  	// Status of the pool. Indicates whether the pool is operational.
    15  	Status string
    16  
    17  	// LBMethod is the load-balancer algorithm, which is round-robin,
    18  	// least-connections, and so on. This value, which must be supported, is
    19  	// dependent on the provider.
    20  	LBMethod string `json:"lb_method"`
    21  
    22  	// Protocol of the pool, which is TCP, HTTP, or HTTPS.
    23  	Protocol string
    24  
    25  	// Description for the pool.
    26  	Description string
    27  
    28  	// MonitorIDs are the IDs of associated monitors which check the health of
    29  	// the pool members.
    30  	MonitorIDs []string `json:"health_monitors"`
    31  
    32  	// SubnetID is the network on which the members of the pool will be located.
    33  	// Only members that are on this network can be added to the pool.
    34  	SubnetID string `json:"subnet_id"`
    35  
    36  	// TenantID is the owner of the pool.
    37  	TenantID string `json:"tenant_id"`
    38  
    39  	// AdminStateUp is the administrative state of the pool, which is up
    40  	// (true) or down (false).
    41  	AdminStateUp bool `json:"admin_state_up"`
    42  
    43  	// Name of the pool.
    44  	Name string
    45  
    46  	// MemberIDs is the list of member IDs that belong to the pool.
    47  	MemberIDs []string `json:"members"`
    48  
    49  	// ID is the unique ID for the pool.
    50  	ID string
    51  
    52  	// VIPID is the ID of the virtual IP associated with this pool.
    53  	VIPID string `json:"vip_id"`
    54  
    55  	// The provider.
    56  	Provider string
    57  }
    58  
    59  // PoolPage is the page returned by a pager when traversing over a
    60  // collection of pools.
    61  type PoolPage struct {
    62  	pagination.LinkedPageBase
    63  }
    64  
    65  // NextPageURL is invoked when a paginated collection of pools has reached
    66  // the end of a page and the pager seeks to traverse over a new one. In order
    67  // to do this, it needs to construct the next page's URL.
    68  func (r PoolPage) NextPageURL() (string, error) {
    69  	var s struct {
    70  		Links []golangsdk.Link `json:"pools_links"`
    71  	}
    72  	err := r.ExtractInto(&s)
    73  	if err != nil {
    74  		return "", err
    75  	}
    76  	return golangsdk.ExtractNextURL(s.Links)
    77  }
    78  
    79  // IsEmpty checks whether a PoolPage struct is empty.
    80  func (r PoolPage) IsEmpty() (bool, error) {
    81  	is, err := ExtractPools(r)
    82  	return len(is) == 0, err
    83  }
    84  
    85  // ExtractPools accepts a Page struct, specifically a PoolPage struct,
    86  // and extracts the elements into a slice of Router structs. In other words,
    87  // a generic collection is mapped into a relevant slice.
    88  func ExtractPools(r pagination.Page) ([]Pool, error) {
    89  	var s struct {
    90  		Pools []Pool `json:"pools"`
    91  	}
    92  	err := (r.(PoolPage)).ExtractInto(&s)
    93  	return s.Pools, err
    94  }
    95  
    96  type commonResult struct {
    97  	golangsdk.Result
    98  }
    99  
   100  // Extract is a function that accepts a result and extracts a router.
   101  func (r commonResult) Extract() (*Pool, error) {
   102  	var s struct {
   103  		Pool *Pool `json:"pool"`
   104  	}
   105  	err := r.ExtractInto(&s)
   106  	return s.Pool, err
   107  }
   108  
   109  // CreateResult represents the result of a create operation. Call its Extract
   110  // method to interpret it as a Pool.
   111  type CreateResult struct {
   112  	commonResult
   113  }
   114  
   115  // GetResult represents the result of a get operation. Call its Extract
   116  // method to interpret it as a Pool.
   117  type GetResult struct {
   118  	commonResult
   119  }
   120  
   121  // UpdateResult represents the result of an update operation. Call its Extract
   122  // method to interpret it as a Pool.
   123  type UpdateResult struct {
   124  	commonResult
   125  }
   126  
   127  // DeleteResult represents the result of a delete operation. Call its
   128  // ExtractErr method to interpret it as a Pool.
   129  type DeleteResult struct {
   130  	golangsdk.ErrResult
   131  }
   132  
   133  // AssociateResult represents the result of an association operation. Call its Extract
   134  // method to interpret it as a Pool.
   135  type AssociateResult struct {
   136  	commonResult
   137  }