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

     1  package listeners
     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  // Listener is the primary load balancing configuration object that specifies
    11  // the loadbalancer and port 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 Listener struct {
    14  	// The unique ID for the Listener.
    15  	ID string `json:"id"`
    16  
    17  	// The administrative state of the Listener. A valid value is true (UP) or false (DOWN).
    18  	AdminStateUp bool `json:"admin_state_up"`
    19  
    20  	// The ID of the CA certificate used by the listener.
    21  	CAContainerRef string `json:"client_ca_tls_container_ref"`
    22  
    23  	// The maximum number of connections allowed for the Loadbalancer.
    24  	// Default is -1, meaning no limit.
    25  	ConnectionLimit int `json:"connection_limit"`
    26  
    27  	// Specifies the time when the listener was created.
    28  	CreatedAt string `json:"created_at"`
    29  
    30  	// Specifies the time when the listener was updated.
    31  	UpdatedAt string `json:"updated_at"`
    32  
    33  	// The UUID of default pool. Must have compatible protocol with listener.
    34  	DefaultPoolID string `json:"default_pool_id"`
    35  
    36  	// A reference to a Barbican container of TLS secrets.
    37  	DefaultTlsContainerRef string `json:"default_tls_container_ref"`
    38  
    39  	// Provides supplementary information about the Listener.
    40  	Description string `json:"description"`
    41  
    42  	// whether to use HTTP2.
    43  	Http2Enable bool `json:"http2_enable"`
    44  
    45  	// A list of load balancer IDs.
    46  	Loadbalancers []structs.ResourceRef `json:"loadbalancers"`
    47  
    48  	// Specifies the Listener Name.
    49  	Name string `json:"name"`
    50  
    51  	// Specifies the ProjectID where the listener is used.
    52  	ProjectID string `json:"project_id"`
    53  
    54  	// The protocol to loadbalancer. A valid value is TCP, HTTP, or HTTPS.
    55  	Protocol string `json:"protocol"`
    56  
    57  	// The port on which to listen to client traffic that is associated with the
    58  	// Loadbalancer. A valid value is from 0 to 65535.
    59  	ProtocolPort int `json:"protocol_port"`
    60  
    61  	// The list of references to TLS secrets.
    62  	SniContainerRefs []string `json:"sni_container_refs"`
    63  
    64  	// SNI certificates wildcard.
    65  	SniMatchAlgo string `json:"sni_match_algo"`
    66  
    67  	// Lists the Tags.
    68  	Tags []tags.ResourceTag `json:"tags"`
    69  
    70  	// Specifies the security policy used by the listener.
    71  	TlsCiphersPolicy string `json:"tls_ciphers_policy"`
    72  
    73  	SecurityPolicy string `json:"security_policy_id"`
    74  
    75  	// Whether enable member retry
    76  	EnableMemberRetry bool `json:"enable_member_retry"`
    77  
    78  	// The keepalive timeout of the Listener.
    79  	KeepAliveTimeout int `json:"keepalive_timeout"`
    80  
    81  	// The client timeout of the Listener.
    82  	ClientTimeout int `json:"client_timeout"`
    83  
    84  	// The member timeout of the Listener.
    85  	MemberTimeout int `json:"member_timeout"`
    86  
    87  	// The ipgroup of the Listener.
    88  	IpGroup IpGroup `json:"ipgroup"`
    89  
    90  	// The http insert headers of the Listener.
    91  	InsertHeaders InsertHeaders `json:"insert_headers"`
    92  
    93  	// Transparent client ip enable
    94  	TransparentClientIP bool `json:"transparent_client_ip_enable"`
    95  
    96  	// Enhance L7policy enable
    97  	EnhanceL7policy bool `json:"enhance_l7policy_enable"`
    98  }
    99  
   100  type commonResult struct {
   101  	golangsdk.Result
   102  }
   103  
   104  // Extract is a function that accepts a result and extracts a listener.
   105  func (r commonResult) Extract() (*Listener, error) {
   106  	s := new(Listener)
   107  	err := r.ExtractIntoStructPtr(s, "listener")
   108  	if err != nil {
   109  		return nil, err
   110  	}
   111  	return s, nil
   112  }
   113  
   114  // CreateResult represents the result of a create operation. Call its Extract
   115  // method to interpret it as a Listener.
   116  type CreateResult struct {
   117  	commonResult
   118  }
   119  
   120  // GetResult represents the result of a get operation. Call its Extract
   121  // method to interpret it as a Listener.
   122  type GetResult struct {
   123  	commonResult
   124  }
   125  
   126  // UpdateResult represents the result of an update operation. Call its Extract
   127  // method to interpret it as a Listener.
   128  type UpdateResult struct {
   129  	commonResult
   130  }
   131  
   132  // DeleteResult represents the result of a delete operation. Call its
   133  // ExtractErr method to determine if the request succeeded or failed.
   134  type DeleteResult struct {
   135  	golangsdk.ErrResult
   136  }
   137  
   138  type ListenerPage struct {
   139  	pagination.PageWithInfo
   140  }
   141  
   142  func (p ListenerPage) IsEmpty() (bool, error) {
   143  	l, err := ExtractListeners(p)
   144  	if err != nil {
   145  		return false, err
   146  	}
   147  	return len(l) == 0, nil
   148  }
   149  
   150  func ExtractListeners(r pagination.Page) ([]Listener, error) {
   151  	var s []Listener
   152  	err := (r.(ListenerPage)).ExtractIntoSlicePtr(&s, "listeners")
   153  	if err != nil {
   154  		return nil, err
   155  	}
   156  	return s, nil
   157  }