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

     1  package loadbalancer_elbs
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	// "github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/elbaas/listeners"
     6  	"github.com/huaweicloud/golangsdk/pagination"
     7  	//"fmt"
     8  )
     9  
    10  // LoadBalancer is the primary load balancing configuration object that specifies
    11  // 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  	// Specifies the IP address used by ELB for providing services.
    15  	VipAddress string `json:"vip_address"`
    16  	// Specifies the time when information about the load balancer was updated.
    17  	UpdateTime string `json:"update_time"`
    18  	// Specifies the time when the load balancer was created.
    19  	CreateTime string `json:"create_time"`
    20  	// Specifies the load balancer ID.
    21  	ID string `json:"id"`
    22  	// Specifies the status of the load balancer.
    23  	// The value can be ACTIVE, PENDING_CREATE, or ERROR.
    24  	Status string `json:"status"`
    25  	// Specifies the bandwidth (Mbit/s).
    26  	Bandwidth int `json:"bandwidth"`
    27  	// Specifies the VPC ID.
    28  	VpcID string `json:"vpc_id"`
    29  	// Specifies the status of the load balancer.
    30  	// Optional values:
    31  	// 0: The load balancer is disabled.
    32  	// 1: The load balancer is running properly.
    33  	// 2: The load balancer is frozen.
    34  	AdminStateUp int `json:"admin_state_up"`
    35  	// Specifies the subnet ID of backend ECSs.
    36  	VipSubnetID string `json:"vip_subnet_id"`
    37  	// Specifies the load balancer type.
    38  	Type string `json:"type"`
    39  	// Specifies the load balancer name.
    40  	Name string `json:"name"`
    41  	// Provides supplementary information about the load balancer.
    42  	Description string `json:"description"`
    43  	// Specifies the security group ID.
    44  	SecurityGroupID string `json:"security_group_id"`
    45  	// Specifies the ID of the availability zone (AZ).
    46  	AZ string `json:"az"`
    47  }
    48  
    49  // LoadBalancerPage is the page returned by a pager when traversing over a
    50  // collection of routers.
    51  type LoadBalancerPage struct {
    52  	pagination.LinkedPageBase
    53  }
    54  
    55  // NextPageURL is invoked when a paginated collection of routers has reached
    56  // the end of a page and the pager seeks to traverse over a new one. In order
    57  // to do this, it needs to construct the next page's URL.
    58  /* func (r LoadBalancerPage) NextPageURL() (string, error) {
    59  	return "", nil
    60  } */
    61  
    62  // IsEmpty checks whether a LoadBalancerPage struct is empty.
    63  func (p LoadBalancerPage) IsEmpty() (bool, error) {
    64  	is, err := ExtractLoadBalancers(p)
    65  	return len(is) == 0, err
    66  }
    67  
    68  // ExtractLoadBalancers accepts a Page struct, specifically a LoadbalancerPage struct,
    69  // and extracts the elements into a slice of LoadBalancer structs. In other words,
    70  // a generic collection is mapped into a relevant slice.
    71  func ExtractLoadBalancers(r pagination.Page) ([]LoadBalancer, error) {
    72  	var s struct {
    73  		LoadBalancers []LoadBalancer `json:"loadbalancers"`
    74  	}
    75  	err := (r.(LoadBalancerPage)).ExtractInto(&s)
    76  	return s.LoadBalancers, err
    77  }
    78  
    79  type commonResult struct {
    80  	golangsdk.Result
    81  }
    82  
    83  // Extract is a function that accepts a result and extracts a loadbalancer.
    84  func (r commonResult) Extract() (*LoadBalancer, error) {
    85  	//fmt.Printf("Extracting...\n")
    86  	lb := new(LoadBalancer)
    87  	err := r.ExtractInto(lb)
    88  	if err != nil {
    89  		//fmt.Printf("Error: %s.\n", err.Error())
    90  		return nil, err
    91  	} else {
    92  		//fmt.Printf("Returning extract: %+v.\n", lb)
    93  		return lb, nil
    94  	}
    95  }
    96  
    97  type GetStatusesResult struct {
    98  	golangsdk.Result
    99  }
   100  
   101  // CreateResult represents the result of a create operation.
   102  type CreateResult struct {
   103  	commonResult
   104  }
   105  
   106  // GetResult represents the result of a get operation.
   107  type GetResult struct {
   108  	commonResult
   109  }
   110  
   111  // UpdateResult represents the result of an update operation.
   112  type UpdateResult struct {
   113  	commonResult
   114  }
   115  
   116  // DeleteResult represents the result of a delete operation.
   117  type DeleteResult struct {
   118  	commonResult
   119  }