listeners

package
v2.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package listeners contains functionality for working with ECL Managed Load Balancer resources.

Example to list listeners

listOpts := listeners.ListOpts{}

allPages, err := listeners.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allListeners, err := listeners.ExtractListeners(allPages)
if err != nil {
	panic(err)
}

for _, listener := range allListeners {
	fmt.Printf("%+v\n", listener)
}

Example to create a listener

var tags map[string]interface{}
tagsJson := `{"key":"value"}`
err := json.Unmarshal([]byte(tagsJson), &tags)
if err != nil {
	panic(err)
}

createOpts := listeners.CreateOpts{
	Name: "listener",
	Description: "description",
	Tags: tags,
	IPAddress: "10.0.0.1",
	Port: 443,
	Protocol: "https",
	LoadBalancerID: "67fea379-cff0-4191-9175-de7d6941a040",
}

listener, err := listeners.Create(managedLoadBalancerClient, createOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listener)

Example to show a listener

showOpts := listeners.ShowOpts{}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
listener, err := listeners.Show(managedLoadBalancerClient, id, showOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listener)

Example to update a listener

name := "listener"
description := "description"

var tags map[string]interface{}
tagsJson := `{"key":"value"}`
err := json.Unmarshal([]byte(tagsJson), &tags)
if err != nil {
	panic(err)
}

updateOpts := listeners.UpdateOpts{
	Name: &name,
	Description: &description,
	Tags: &tags,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
listener, err := listeners.Update(managedLoadBalancerClient, updateOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listener)

Example to delete a listener

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := listeners.Delete(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
	panic(err)
}

Example to create staged listener configurations

createStagedOpts := listeners.CreateStagedOpts{
	IPAddress: "10.0.0.1",
	Port: 443,
	Protocol: "https",
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
listenerConfigurations, err := listeners.CreateStaged(managedLoadBalancerClient, id, createStagedOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listenerConfigurations)

Example to show staged listener configurations

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
listenerConfigurations, err := listeners.ShowStaged(managedLoadBalancerClient, id).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listenerConfigurations)

Example to update staged listener configurations

ipAddress := "10.0.0.1"
port := 443
protocol := "https"
updateStagedOpts := listeners.UpdateStagedOpts{
	IPAddress: &ipAddress,
	Port: &port,
	Protocol: &protocol,
}

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
listenerConfigurations, err := listeners.UpdateStaged(managedLoadBalancerClient, updateStagedOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", listenerConfigurations)

Example to cancel staged listener configurations

id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
err := listeners.CancelStaged(managedLoadBalancerClient, id).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractListenersInto

func ExtractListenersInto(r pagination.Page, v interface{}) error

ExtractListenersInto interprets the results of a single page from a List() call, producing a slice of listener entities.

func List

func List(c *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns a Pager which allows you to iterate over a collection of listeners. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type CancelStagedResult

type CancelStagedResult struct {
	eclcloud.ErrResult
}

CancelStagedResult represents the result of a CancelStaged operation. Call its ExtractErr method to determine if the request succeeded or failed.

func CancelStaged

func CancelStaged(c *eclcloud.ServiceClient, id string) (r CancelStagedResult)

CancelStaged accepts a unique ID and deletes listener configurations associated with it.

type ConfigurationInResponse

type ConfigurationInResponse struct {

	// - IP address of the listener for listening
	IPAddress string `json:"ip_address,omitempty"`

	// - Port number of the listener for listening
	Port int `json:"port,omitempty"`

	// - Protocol of the listener for listening
	Protocol string `json:"protocol,omitempty"`
}

ConfigurationInResponse represents a configuration in a listener.

type CreateOpts

type CreateOpts struct {

	// - Name of the listener
	// - This field accepts single-byte characters only
	Name string `json:"name,omitempty"`

	// - Description of the listener
	// - This field accepts single-byte characters only
	Description string `json:"description,omitempty"`

	// - Tags of the listener
	// - Set JSON object up to 32,768 characters
	//   - Nested structure is permitted
	// - This field accepts single-byte characters only
	Tags map[string]interface{} `json:"tags,omitempty"`

	// - IP address of the listener for listening
	// - Set an unique combination of IP address and port in all listeners which belong to the same load balancer
	// - Must not set a IP address which is included in `virtual_ip_address` and `reserved_fixed_ips` of load balancer interfaces that the listener belongs to
	// - Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
	IPAddress string `json:"ip_address"`

	// - Port number of the listener for listening
	// - Combination of IP address and port must be unique for all listeners which belong to the same load balancer
	Port int `json:"port"`

	// - Protocol of the listener for listening
	Protocol string `json:"protocol"`

	// - ID of the load balancer which the listener belongs to
	LoadBalancerID string `json:"load_balancer_id"`
}

CreateOpts represents options used to create a new listener.

func (CreateOpts) ToListenerCreateMap

func (opts CreateOpts) ToListenerCreateMap() (map[string]interface{}, error)

ToListenerCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToListenerCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult represents the result of a Create operation. Call its Extract method to interpret it as a Listener.

func Create

func Create(c *eclcloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create accepts a CreateOpts struct and creates a new listener using the values provided.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (CreateResult) ExtractInto

func (r CreateResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

type CreateStagedOpts

type CreateStagedOpts struct {

	// - IP address of the listener for listening
	// - Set an unique combination of IP address and port in all listeners which belong to the same load balancer
	// - Must not set a IP address which is included in `virtual_ip_address` and `reserved_fixed_ips` of load balancer interfaces that the listener belongs to
	// - Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
	IPAddress string `json:"ip_address,omitempty"`

	// - Port number of the listener for listening
	// - Combination of IP address and port must be unique for all listeners which belong to the same load balancer
	Port int `json:"port,omitempty"`

	// - Protocol of the listener for listening
	Protocol string `json:"protocol,omitempty"`
}

CreateStagedOpts represents options used to create new listener configurations.

func (CreateStagedOpts) ToListenerCreateStagedMap

func (opts CreateStagedOpts) ToListenerCreateStagedMap() (map[string]interface{}, error)

ToListenerCreateStagedMap builds a request body from CreateStagedOpts.

type CreateStagedOptsBuilder

type CreateStagedOptsBuilder interface {
	ToListenerCreateStagedMap() (map[string]interface{}, error)
}

CreateStagedOptsBuilder allows extensions to add additional parameters to the CreateStaged request.

type CreateStagedResult

type CreateStagedResult struct {
	// contains filtered or unexported fields
}

CreateStagedResult represents the result of a CreateStaged operation. Call its Extract method to interpret it as a Listener.

func CreateStaged

func CreateStaged(c *eclcloud.ServiceClient, id string, opts CreateStagedOptsBuilder) (r CreateStagedResult)

CreateStaged accepts a CreateStagedOpts struct and creates new listener configurations using the values provided.

func (CreateStagedResult) Extract

func (r CreateStagedResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (CreateStagedResult) ExtractInto

func (r CreateStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult represents the result of a Delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult)

Delete accepts a unique ID and deletes the listener associated with it.

type ListOpts

type ListOpts struct {

	// - ID of the resource
	ID string `q:"id"`

	// - Name of the resource
	// - This field accepts single-byte characters only
	Name string `q:"name"`

	// - Description of the resource
	// - This field accepts single-byte characters only
	Description string `q:"description"`

	// - Configuration status of the resource
	ConfigurationStatus string `q:"configuration_status"`

	// - Operation status of the resource
	OperationStatus string `q:"operation_status"`

	// - IP address of the resource for listening
	IPAddress string `q:"ip_address"`

	// - Port number of the resource for healthchecking or listening
	Port int `q:"port"`

	// - Protocol of the resource for healthchecking or listening
	Protocol string `q:"protocol"`

	// - ID of the load balancer which the resource belongs to
	LoadBalancerID string `q:"load_balancer_id"`

	// - ID of the owner tenant of the resource
	TenantID string `q:"tenant_id"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the listener attributes you want to see returned.

func (ListOpts) ToListenerListQuery

func (opts ListOpts) ToListenerListQuery() (string, error)

ToListenerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToListenerListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Listener

type Listener struct {

	// - ID of the listener
	ID string `json:"id"`

	// - Name of the listener
	Name string `json:"name"`

	// - Description of the listener
	Description string `json:"description"`

	// - Tags of the listener (JSON object format)
	Tags map[string]interface{} `json:"tags"`

	// - Configuration status of the listener
	//   - `"ACTIVE"`
	//     - There are no configurations of the listener that waiting to be applied
	//   - `"CREATE_STAGED"`
	//     - The listener has been added and waiting to be applied
	//   - `"UPDATE_STAGED"`
	//     - Changed configurations of the listener exists that waiting to be applied
	//   - `"DELETE_STAGED"`
	//     - The listener has been removed and waiting to be applied
	ConfigurationStatus string `json:"configuration_status"`

	// - Operation status of the load balancer which the listener belongs to
	//   - `"NONE"` :
	//     - There are no operations of the load balancer
	//     - The load balancer and related resources can be operated
	//   - `"PROCESSING"`
	//     - The latest operation of the load balancer is processing
	//     - The load balancer and related resources cannot be operated
	//   - `"COMPLETE"`
	//     - The latest operation of the load balancer has been succeeded
	//     - The load balancer and related resources can be operated
	//   - `"STUCK"`
	//     - The latest operation of the load balancer has been stopped
	//     - Operators of NTT Communications will investigate the operation
	//     - The load balancer and related resources cannot be operated
	//   - `"ERROR"`
	//     - The latest operation of the load balancer has been failed
	//     - The operation was roll backed normally
	//     - The load balancer and related resources can be operated
	OperationStatus string `json:"operation_status"`

	// - ID of the load balancer which the listener belongs to
	LoadBalancerID string `json:"load_balancer_id"`

	// - ID of the owner tenant of the listener
	TenantID string `json:"tenant_id"`

	// - IP address of the listener for listening
	IPAddress string `json:"ip_address,omitempty"`

	// - Port number of the listener for listening
	Port int `json:"port,omitempty"`

	// - Protocol of the listener for listening
	Protocol string `json:"protocol,omitempty"`

	// - Running configurations of the listener
	// - If `changes` is `true`, return object
	// - If current configuration does not exist, return `null`
	Current ConfigurationInResponse `json:"current,omitempty"`

	// - Added or changed configurations of the listener that waiting to be applied
	// - If `changes` is `true`, return object
	// - If staged configuration does not exist, return `null`
	Staged ConfigurationInResponse `json:"staged,omitempty"`
}

Listener represents a listener.

func ExtractListeners

func ExtractListeners(r pagination.Page) ([]Listener, error)

ExtractListeners accepts a Page struct, specifically a NetworkPage struct, and extracts the elements into a slice of Listener structs. In other words, a generic collection is mapped into a relevant slice.

type ListenerPage

type ListenerPage struct {
	pagination.LinkedPageBase
}

ListenerPage is the page returned by a pager when traversing over a collection of listener.

func (ListenerPage) IsEmpty

func (r ListenerPage) IsEmpty() (bool, error)

IsEmpty checks whether a ListenerPage struct is empty.

type ShowOpts

type ShowOpts struct {

	// - If `true` is set, `current` and `staged` are returned in response body
	Changes bool `q:"changes"`
}

ShowOpts represents options used to show a listener.

func (ShowOpts) ToListenerShowQuery

func (opts ShowOpts) ToListenerShowQuery() (string, error)

ToListenerShowQuery formats a ShowOpts into a query string.

type ShowOptsBuilder

type ShowOptsBuilder interface {
	ToListenerShowQuery() (string, error)
}

ShowOptsBuilder allows extensions to add additional parameters to the Show request.

type ShowResult

type ShowResult struct {
	// contains filtered or unexported fields
}

ShowResult represents the result of a Show operation. Call its Extract method to interpret it as a Listener.

func Show

func Show(c *eclcloud.ServiceClient, id string, opts ShowOptsBuilder) (r ShowResult)

Show retrieves a specific listener based on its unique ID.

func (ShowResult) Extract

func (r ShowResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (ShowResult) ExtractInto

func (r ShowResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

type ShowStagedResult

type ShowStagedResult struct {
	// contains filtered or unexported fields
}

ShowStagedResult represents the result of a ShowStaged operation. Call its Extract method to interpret it as a Listener.

func ShowStaged

func ShowStaged(c *eclcloud.ServiceClient, id string) (r ShowStagedResult)

ShowStaged retrieves specific listener configurations based on its unique ID.

func (ShowStagedResult) Extract

func (r ShowStagedResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (ShowStagedResult) ExtractInto

func (r ShowStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

type UpdateOpts

type UpdateOpts struct {

	// - Name of the listener
	// - This field accepts single-byte characters only
	Name *string `json:"name,omitempty"`

	// - Description of the listener
	// - This field accepts single-byte characters only
	Description *string `json:"description,omitempty"`

	// - Tags of the listener
	// - Set JSON object up to 32,768 characters
	//   - Nested structure is permitted
	// - This field accepts single-byte characters only
	Tags *map[string]interface{} `json:"tags,omitempty"`
}

UpdateOpts represents options used to update a existing listener.

func (UpdateOpts) ToListenerUpdateMap

func (opts UpdateOpts) ToListenerUpdateMap() (map[string]interface{}, error)

ToListenerUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToListenerUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult represents the result of a Update operation. Call its Extract method to interpret it as a Listener.

func Update

func Update(c *eclcloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates a existing listener using the values provided.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (UpdateResult) ExtractInto

func (r UpdateResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

type UpdateStagedOpts

type UpdateStagedOpts struct {

	// - IP address of the listener for listening
	// - Set an unique combination of IP address and port in all listeners which belong to the same load balancer
	// - Must not set a IP address which is included in `virtual_ip_address` and `reserved_fixed_ips` of load balancer interfaces that the listener belongs to
	// - Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
	IPAddress *string `json:"ip_address,omitempty"`

	// - Port number of the listener for listening
	// - Combination of IP address and port must be unique for all listeners which belong to the same load balancer
	Port *int `json:"port,omitempty"`

	// - Protocol of the listener for listening
	Protocol *string `json:"protocol,omitempty"`
}

UpdateStagedOpts represents options used to update existing Listener configurations.

func (UpdateStagedOpts) ToListenerUpdateStagedMap

func (opts UpdateStagedOpts) ToListenerUpdateStagedMap() (map[string]interface{}, error)

ToListenerUpdateStagedMap builds a request body from UpdateStagedOpts.

type UpdateStagedOptsBuilder

type UpdateStagedOptsBuilder interface {
	ToListenerUpdateStagedMap() (map[string]interface{}, error)
}

UpdateStagedOptsBuilder allows extensions to add additional parameters to the UpdateStaged request.

type UpdateStagedResult

type UpdateStagedResult struct {
	// contains filtered or unexported fields
}

UpdateStagedResult represents the result of a UpdateStaged operation. Call its Extract method to interpret it as a Listener.

func UpdateStaged

func UpdateStaged(c *eclcloud.ServiceClient, id string, opts UpdateStagedOptsBuilder) (r UpdateStagedResult)

UpdateStaged accepts a UpdateStagedOpts struct and updates existing Listener configurations using the values provided.

func (UpdateStagedResult) Extract

func (r UpdateStagedResult) Extract() (*Listener, error)

Extract is a function that accepts a result and extracts a Listener resource.

func (UpdateStagedResult) ExtractInto

func (r UpdateStagedResult) ExtractInto(v interface{}) error

ExtractInto interprets any commonResult as a listener, if possible.

Directories

Path Synopsis
Package testing contains listener unit tests
Package testing contains listener unit tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL