members

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package members provides information and interaction with Members of the Load Balancer as a Service extension for the OpenStack Networking service.

Example to List Members

listOpts := members.ListOpts{
	ProtocolPort: 80,
}

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

allMembers, err := members.ExtractMembers(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Member

createOpts := members.CreateOpts{
	Address:      "192.168.2.14",
	ProtocolPort: 80,
	PoolID:       "0b266a12-0fdf-4434-bd11-649d84e54bd5"
}

member, err := members.Create(networkClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Update a Member

memberID := "46592c54-03f7-40ef-9cdf-b1fcf2775ddf"

updateOpts := members.UpdateOpts{
	AdminStateUp: gophercloud.Disabled,
}

member, err := members.Update(networkClient, memberID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Member

memberID := "46592c54-03f7-40ef-9cdf-b1fcf2775ddf"
err := members.Delete(networkClient, memberID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

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

Default policy settings return only those members that are owned by the tenant who submits the request, unless an admin user submits the request.

Types

type CreateOpts

type CreateOpts struct {
	// Address is the IP address of the member.
	Address string `json:"address" required:"true"`

	// ProtocolPort is the port on which the application is hosted.
	ProtocolPort int `json:"protocol_port" required:"true"`

	// PoolID is the pool to which this member will belong.
	PoolID string `json:"pool_id" required:"true"`

	// TenantID is only required if the caller has an admin role and wants
	// to create a pool for another tenant.
	TenantID string `json:"tenant_id,omitempty"`
}

CreateOpts contains all the values needed to create a new pool member.

func (CreateOpts) ToLBMemberCreateMap

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

ToLBMemberCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToLBMemberCreateMap() (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 Member.

func Create

Create accepts a CreateOpts struct and uses the values to create a new load balancer pool member.

func (CreateResult) Extract

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

Extract is a function that accepts a result and extracts a member.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

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

func Delete

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

Delete will permanently delete a particular member based on its unique ID.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Member.

func Get

func Get(c *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves a particular pool member based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Member, error)

Extract is a function that accepts a result and extracts a member.

type ListOpts

type ListOpts struct {
	Status       string `q:"status"`
	Weight       int    `q:"weight"`
	AdminStateUp *bool  `q:"admin_state_up"`
	TenantID     string `q:"tenant_id"`
	PoolID       string `q:"pool_id"`
	Address      string `q:"address"`
	ProtocolPort int    `q:"protocol_port"`
	ID           string `q:"id"`
	Limit        int    `q:"limit"`
	Marker       string `q:"marker"`
	SortKey      string `q:"sort_key"`
	SortDir      string `q:"sort_dir"`
}

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 floating IP attributes you want to see returned. SortKey allows you to sort by a particular network attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

type Member

type Member struct {
	// Status is the status of the member. Indicates whether the member
	// is operational.
	Status string

	// Weight is the weight of member.
	Weight int

	// AdminStateUp is the administrative state of the member, which is up
	// (true) or down (false).
	AdminStateUp bool `json:"admin_state_up"`

	// TenantID is the owner of the member.
	TenantID string `json:"tenant_id"`

	// PoolID is the pool to which the member belongs.
	PoolID string `json:"pool_id"`

	// Address is the IP address of the member.
	Address string

	// ProtocolPort is the port on which the application is hosted.
	ProtocolPort int `json:"protocol_port"`

	// ID is the unique ID for the member.
	ID string
}

Member represents the application running on a backend server.

func ExtractMembers

func ExtractMembers(r pagination.Page) ([]Member, error)

ExtractMembers accepts a Page struct, specifically a MemberPage struct, and extracts the elements into a slice of Member structs. In other words, a generic collection is mapped into a relevant slice.

type MemberPage

type MemberPage struct {
	pagination.LinkedPageBase
}

MemberPage is the page returned by a pager when traversing over a collection of pool members.

func (MemberPage) IsEmpty

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

IsEmpty checks whether a MemberPage struct is empty.

func (MemberPage) NextPageURL

func (r MemberPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of members has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type UpdateOpts

type UpdateOpts struct {
	// The administrative state of the member, which is up (true) or down (false).
	AdminStateUp *bool `json:"admin_state_up,omitempty"`
}

UpdateOpts contains the values used when updating a pool member.

func (UpdateOpts) ToLBMemberUpdateMap

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

ToLBMemberUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToLBMemberUpdateMap() (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 an update operation. Call its Extract method to interpret it as a Member.

func Update

Update allows members to be updated.

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts a member.

Directories

Path Synopsis
members unit tests
members unit tests

Jump to

Keyboard shortcuts

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