sdk

package
v1.20.8 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LoadBalancerForwardApplication application type loadbalance
	LoadBalancerForwardApplication = 1
	// LoadBalancerForwardClassic classic type loadbalance
	LoadBalancerForwardClassic = 0

	// LoadBalancerNetworkPublic public network
	LoadBalancerNetworkPublic = "OPEN"
	// LoadBalancerNetworkInternal internal network
	LoadBalancerNetworkInternal = "INTERNAL"

	// ListenerProtocolHTTP http protocol listener
	ListenerProtocolHTTP = "HTTP"
	// ListenerProtocolHTTPS https protocol listener
	ListenerProtocolHTTPS = "HTTPS"
	// ListenerProtocolTCP tcp protocol listener
	ListenerProtocolTCP = "TCP"
	// ListenerProtocolUDP udp protocol listener
	ListenerProtocolUDP = "UDP"

	// ListenerSSLModeUnidirectional unidirectional ssl mode
	ListenerSSLModeUnidirectional = "UNIDIRECTIONAL"
	// ListenerSSLModeMutual mutual ssl mode
	ListenerSSLModeMutual = "MUTUAL"

	// LBAlgorithmLeastConn least connection policy
	LBAlgorithmLeastConn = "LEAST_CONN"
	// LBAlgorithmRoundRobin wrr policy
	LBAlgorithmRoundRobin = "WRR"
	// LBAlgorithmIPHash ip hash policy
	LBAlgorithmIPHash = "IP_HASH"

	// RequestLimitExceededCode code for request exceeded limit
	RequestLimitExceededCode = "4400"
	// WrongStatusCode code for incorrect status
	WrongStatusCode = "4000"
)
View Source
const (
	// DescribeFilterNamePrivateIP filter name for private IP
	DescribeFilterNamePrivateIP = "private-ip-address"
	// ClbBackendTargetTypeCVM clb backend type is cvm
	// clb backend type defined the way to call register backend to listener or rule
	// when use "CVM": register backend with instance id which is get from cvm ip
	// when use "ENI": register backend with eni IP
	ClbBackendTargetTypeCVM = "CVM"
	// ClbBackendTargetTypeENI clb backend type is elastic network interface
	ClbBackendTargetTypeENI = "ENI"
	// TaskStatusDealing  task is dealing
	TaskStatusDealing = 2
	// TaskStatusFailed task is failed
	TaskStatusFailed = 1
	// TaskStatusSucceed task is successful
	TaskStatusSucceed = 0
	// ClbStatusCreating clb instance is creating
	ClbStatusCreating = 0
	// ClbStatusNormal clb instance is normal
	ClbStatusNormal = 1
)

Variables

LBAlgorithmTypeBcs2SDKMap map for bcs lb policy to sdk lb policy

LBAlgorithmTypeSDK2BcsMap map for sdk lb policy to bcs lb policy

ProtocolBcs2SDKMap map for bcs protocol type to sdk protocol type

ProtocolSDK2BcsMap map for sdk protocol type to bcs protocol type

SSLModeBcs2SDKMap map for bcs ssl mode to sdk ssl mode

SSLModeSDK2BcsMap map for sdk ssl mode to bcs ssl mode

Functions

func NewClient

func NewClient(sc *Config) qcloudif.ClbAdapter

NewClient create client for tencent cloud sdk

Types

type Client

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

Client client for call tencent cloud sdk

func (*Client) CreateListener

func (c *Client) CreateListener(listener *cloudListenerType.CloudListener) (listenerID string, err error)

CreateListener create listener create7LayerListener and create4LayerListener only return request object CreateListener does request action and waits for result

func (*Client) CreateLoadBalance

func (c *Client) CreateLoadBalance(lb *cloudListenerType.CloudLoadBalancer) (lbID string, vips []string, err error)

CreateLoadBalance call sdk to create clb, return clb id TODO: deal with vips

func (*Client) CreateRules

func (c *Client) CreateRules(lbID, listenerID string, rules cloudListenerType.RuleList) error

CreateRules create rules for clb listener

func (*Client) DeRegister4LayerBackends

func (c *Client) DeRegister4LayerBackends(lbID, listenerID string,
	backendsDeRegister cloudListenerType.BackendList) error

DeRegister4LayerBackends deregister 4 layer

func (*Client) DeRegister7LayerBackends

func (c *Client) DeRegister7LayerBackends(lbID, listenerID, ruleID string,
	backendsDeRegister cloudListenerType.BackendList) error

DeRegister7LayerBackends deregister 7 layer backend

func (*Client) DeleteListener

func (c *Client) DeleteListener(lbID, listenerID string) error

DeleteListener delete listener by loadbalance id and listener id

func (*Client) DeleteRule

func (c *Client) DeleteRule(lbID, listenerID, domain, url string) error

DeleteRule delete rule of clb listener by domain and url, loadbalance id and listener id

func (*Client) DescribeListener

func (c *Client) DescribeListener(lbID, listenerID string, port int) (
	listener *cloudListenerType.CloudListener, isExisted bool, err error)

DescribeListener describe listener by loadbalance id, either listener id or listener port this function does different conversion for 4 layer listener and 7 layer listener.

func (*Client) DescribeLoadBalance

func (c *Client) DescribeLoadBalance(name string) (*cloudListenerType.CloudLoadBalancer, bool, error)

DescribeLoadBalance describe clb by name, return clb info, and return true if it is existed

func (*Client) DescribeRuleByDomainAndURL

func (c *Client) DescribeRuleByDomainAndURL(loadBalanceID, listenerID, domain, url string) (
	rule *cloudListenerType.Rule, isExisted bool, err error)

DescribeRuleByDomainAndURL describe rule by domain and url call DescribeListener api to find the certain listener traverse all the rules in listener with certain domain and url

func (*Client) ListListener

func (c *Client) ListListener(lbID string) ([]*cloudListenerType.CloudListener, error)

ListListener listener listeners in tencent cloud 1. list listener infos 2. list backends 3. list listener health status info

func (*Client) ModifyListenerAttribute

func (c *Client) ModifyListenerAttribute(listener *cloudListenerType.CloudListener) error

ModifyListenerAttribute modify listener attribute modify7LayerListenerAttribute can only modify https listener tls config, leave other modify actions to ModifyRuleAttribute modify4LayerListenerAttribute can modify health check, session, lb policy for 4 layer listener

func (*Client) ModifyRuleAttribute

func (c *Client) ModifyRuleAttribute(loadBalanceID, listenerID string, rule *cloudListenerType.Rule) error

ModifyRuleAttribute modify rule attributes

func (*Client) Register4LayerBackends

func (c *Client) Register4LayerBackends(lbID, listenerID string, backendsRegister cloudListenerType.BackendList) error

Register4LayerBackends 4 layer backend

func (*Client) Register7LayerBackends

func (c *Client) Register7LayerBackends(lbID, listenerID, ruleID string,
	backendsRegister cloudListenerType.BackendList) error

Register7LayerBackends register 7 layer backend

type Config

type Config struct {
	// Region tencent cloud region
	Region string
	// ProjectID project id for tencent cloud
	ProjectID int
	// SubnetID subent id for tencent cloud vpc, only for creating private clb instance
	// it is useless when take over a existed private clb intance
	SubnetID string
	// VpcID vpc id for tencent cloud
	VpcID string
	// SecretID secret id for tencent cloud
	SecretID string
	// SecretKey secret key for tencent cloud
	SecretKey string
	// BackendType cvm or eni
	BackendType string
	// MaxTimeout times for retrying query asynchronous task result
	MaxTimeout int
	// WaitPeriodExceedLimit wait second when exceed api limit
	WaitPeriodExceedLimit int
	// WaitPeriodLBDealing wait second when retrying query asynchronous task result
	WaitPeriodLBDealing int
}

Config config for sdk client

Jump to

Keyboard shortcuts

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