v1

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	LoadBalancerStateOK      = LoadBalancerState{ID: "0", Text: "OK", Type: 0}
	LoadBalancerStateError   = LoadBalancerState{ID: "1", Text: "Error", Type: 1}
	LoadBalancerStatePending = LoadBalancerState{ID: "2", Text: "Pending", Type: 2}
	LoadBalancerStateCreated = LoadBalancerState{ID: "3", Text: "Created", Type: 3}
)
View Source
var (
	Updating        = State{ID: "0", Text: "Updating", Type: 0}
	Updated         = State{ID: "1", Text: "Updated", Type: 1}
	DeploymentError = State{ID: "2", Text: "DeploymentError", Type: 2}
	Deployed        = State{ID: "3", Text: "Deployed", Type: 3}
	NewlyCreated    = State{ID: "4", Text: "NewlyCreated", Type: 4}
)

Functions

This section is empty.

Types

type ACL added in v0.4.4

type ACL struct {
	HasState

	CustomerIdentifier string `json:"customer_identifier,omitempty"`
	ResellerIdentifier string `json:"reseller_identifier,omitempty"`

	Identifier      string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name            string     `json:"name,omitempty"`
	ParentType      string     `json:"parent_type,omitempty" anxcloud:"filterable"`
	Criterion       string     `json:"criterion,omitempty"`
	Value           string     `json:"value,omitempty"`
	AutomationRules []RuleInfo `json:"automation_rules,omitempty"`

	// Index is *int to allow zero values but also omitempty
	// pkg/utils/pointer can be used to create pointers from primitives
	Index *int `json:"index,omitempty"`

	// Only the name and identifier fields are used and returned.
	Frontend Frontend `json:"frontend,omitempty" anxcloud:"filterable"`
	Backend  Backend  `json:"backend,omitempty" anxcloud:"filterable"`
	// contains filtered or unexported fields
}

ACL represents an LBaaS ACL

Example
package main

import (
	"context"
	"log"

	"go.anx.io/go-anxcloud/pkg/api"
	lbaasv1 "go.anx.io/go-anxcloud/pkg/apis/lbaas/v1"
	"go.anx.io/go-anxcloud/pkg/client"
	"go.anx.io/go-anxcloud/pkg/utils/pointer"
)

func main() {
	a, err := api.NewAPI(api.WithClientOptions(client.AuthFromEnv(false)))
	if err != nil {
		log.Fatalf("failed to initialize api client: %s", err)
	}

	acl := &lbaasv1.ACL{
		Name:       "destination port 8080",
		ParentType: "frontend",
		Index:      pointer.Int(5),
		Criterion:  "dst_port",
		Value:      "8080",
		Frontend: lbaasv1.Frontend{
			Identifier: "<frontend-identifier>",
		},
	}

	if err := a.Create(context.TODO(), acl); err != nil {
		log.Fatalf("failed to create ACL: %s", err)
	}
}
Output:

func (*ACL) EndpointURL added in v0.4.4

func (a *ACL) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type ACL and the identifier of the given ACL. It implements the api.Object interface on *ACL, making it usable with the generic API client.

func (*ACL) FilterAPIRequestBody added in v0.4.4

func (a *ACL) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for ACLs, replacing linked Objects with just their identifier.

func (*ACL) FilterAPIResponse added in v0.4.4

func (cm *ACL) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*ACL) GetIdentifier added in v0.4.5

func (o *ACL) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a ACL object

type Backend

type Backend struct {
	HasState

	CustomerIdentifier string     `json:"customer_identifier,omitempty"`
	ResellerIdentifier string     `json:"reseller_identifier,omitempty"`
	Identifier         string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name               string     `json:"name"`
	HealthCheck        string     `json:"health_check,omitempty"`
	Mode               Mode       `json:"mode"`
	ServerTimeout      int        `json:"server_timeout,omitempty"`
	AutomationRules    []RuleInfo `json:"automation_rules,omitempty"`

	// Only the name and identifier fields are used and returned.
	LoadBalancer LoadBalancer `json:"load_balancer"`
	// contains filtered or unexported fields
}

The Backend resource configures settings common for all specific backend Server resources linked to it.

func (*Backend) EndpointURL

func (b *Backend) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type Backend and the identifier of the given Backend. It implements the api.Object interface on *Backend, making it usable with the generic API client.

func (*Backend) FilterAPIRequestBody

func (b *Backend) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for Backends, replacing linked Objects with just their identifier.

func (*Backend) FilterAPIResponse

func (cm *Backend) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*Backend) GetIdentifier added in v0.4.5

func (o *Backend) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Backend object

type Bind

type Bind struct {
	HasState

	CustomerIdentifier string     `json:"customer_identifier,omitempty"`
	ResellerIdentifier string     `json:"reseller_identifier,omitempty"`
	Identifier         string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name               string     `json:"name"`
	Address            string     `json:"address"`
	Port               int        `json:"port"`
	SSL                bool       `json:"ssl"`
	SslCertificatePath string     `json:"ssl_certificate_path,omitempty"`
	AutomationRules    []RuleInfo `json:"automation_rules,omitempty"`

	// Only the name and identifier fields are used and returned.
	Frontend Frontend `json:"frontend"`
	// contains filtered or unexported fields
}

Bind represents an LBaaS FrontendBind

func (*Bind) EndpointURL

func (b *Bind) EndpointURL(ctx context.Context) (*url.URL, error)

func (*Bind) FilterAPIRequestBody

func (b *Bind) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for Binds, replacing linked Objects with just their identifier.

func (*Bind) FilterAPIResponse

func (cm *Bind) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*Bind) GetIdentifier added in v0.4.5

func (o *Bind) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Bind object

type Frontend

type Frontend struct {
	HasState

	CustomerIdentifier string     `json:"customer_identifier,omitempty"`
	ResellerIdentifier string     `json:"reseller_identifier,omitempty"`
	Identifier         string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name               string     `json:"name"`
	Mode               Mode       `json:"mode"`
	ClientTimeout      string     `json:"client_timeout,omitempty"`
	AutomationRules    []RuleInfo `json:"automation_rules,omitempty"`

	// Only the name and identifier fields are used and returned.
	LoadBalancer *LoadBalancer `json:"load_balancer,omitempty"`

	// Only the name and identifier fields are used and returned.
	DefaultBackend *Backend `json:"default_backend,omitempty"`
	// contains filtered or unexported fields
}

Frontend represents a LBaaS Frontend.

func (*Frontend) EndpointURL

func (f *Frontend) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type Frontend and the identifier of the given Frontend. It implements the api.Object interface on *Frontend, making it usable with the generic API client.

func (*Frontend) FilterAPIRequestBody

func (f *Frontend) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for Frontends, replacing linked Objects with just their identifier.

func (*Frontend) FilterAPIResponse

func (cm *Frontend) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*Frontend) GetIdentifier added in v0.4.5

func (o *Frontend) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Frontend object

type HasState added in v0.4.2

type HasState struct {
	State State `json:"state"`
}

func (HasState) StateFailure added in v0.4.2

func (hs HasState) StateFailure() bool

StateFailure checks if the state is marking any failure

func (HasState) StateProgressing added in v0.4.2

func (hs HasState) StateProgressing() bool

StateProgressing checks if the state is marking any change currently being applied

func (HasState) StateSuccess added in v0.4.2

func (hs HasState) StateSuccess() bool

StateSuccess checks if the state is one of the successful ones

type LoadBalancer

type LoadBalancer struct {
	State LoadBalancerState `json:"state"`

	CustomerIdentifier string     `json:"customer_identifier,omitempty"`
	ResellerIdentifier string     `json:"reseller_identifier,omitempty"`
	Identifier         string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name               string     `json:"name"`
	IpAddress          string     `json:"ip_address"`
	AutomationRules    []RuleInfo `json:"automation_rules,omitempty"`
	// contains filtered or unexported fields
}

LoadBalancer holds the information of a load balancer instance.

func (*LoadBalancer) EndpointURL

func (lb *LoadBalancer) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type LoadBalancer and the identifier of the given Loadbalancer. It implements the api.Object interface on *LoadBalancer, making it usable with the generic API client.

func (*LoadBalancer) FilterAPIRequestBody

func (lb *LoadBalancer) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for creating a new LoadBalancer, which differs from the LoadBalancer object.

func (*LoadBalancer) FilterAPIResponse

func (cm *LoadBalancer) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*LoadBalancer) GetIdentifier added in v0.4.5

func (o *LoadBalancer) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a LoadBalancer object

func (LoadBalancer) StateFailure added in v0.4.3

func (l LoadBalancer) StateFailure() bool

func (LoadBalancer) StateProgressing added in v0.4.3

func (l LoadBalancer) StateProgressing() bool

func (LoadBalancer) StateSuccess added in v0.4.3

func (l LoadBalancer) StateSuccess() bool

type LoadBalancerState added in v0.4.3

type LoadBalancerState struct {
	// programatically usable enum value
	ID string `json:"id"`

	// human readable status text
	Text string `json:"text"`

	Type int `json:"type"`
}

LoadBalancerState is the same as State, but with different states as they are defined differently for LoadBalancer resources. It still implements StateRetriever, so you can use it like the other resources.

func (LoadBalancerState) MarshalJSON added in v0.4.3

func (s LoadBalancerState) MarshalJSON() ([]byte, error)

func (LoadBalancerState) StateFailure added in v0.4.3

func (s LoadBalancerState) StateFailure() bool

StateFailure checks if the state is marking any failure

func (LoadBalancerState) StateProgressing added in v0.4.3

func (s LoadBalancerState) StateProgressing() bool

StateProgressing checks if the state is marking any change currently being applied

func (LoadBalancerState) StateSuccess added in v0.4.3

func (s LoadBalancerState) StateSuccess() bool

StateSuccess checks if the state is one of the successful ones

type Mode

type Mode string

Mode is an enum for the supported LoadBalancer protocols.

const (
	TCP  Mode = "tcp"
	HTTP Mode = "http"
)

type Rule added in v0.4.4

type Rule struct {
	HasState

	CustomerIdentifier string `json:"customer_identifier,omitempty"`
	ResellerIdentifier string `json:"reseller_identifier,omitempty"`

	Identifier       string `json:"identifier,omitempty" anxcloud:"identifier"`
	Name             string `json:"name,omitempty"`
	ParentType       string `json:"parent_type,omitempty" anxcloud:"filterable"`
	Condition        string `json:"condition,omitempty" anxcloud:"filterable"`
	ConditionTest    string `json:"condition_test,omitempty"`
	Type             string `json:"type,omitempty" anxcloud:"filterable"`
	Action           string `json:"action,omitempty" anxcloud:"filterable"`
	RedirectionType  string `json:"redirection_type,omitempty" anxcloud:"filterable"`
	RedirectionValue string `json:"redirection_value,omitempty"`
	RedirectionCode  string `json:"redirection_code,omitempty" anxcloud:"filterable"`
	RuleType         string `json:"rule_type,omitempty" anxcloud:"filterable"`

	// Index is *int to allow zero values but also omitempty
	// pkg/utils/pointer can be used to create pointers from primitives
	Index *int `json:"index,omitempty"`

	// Only the name and identifier fields are used and returned.
	Frontend Frontend `json:"frontend,omitempty" anxcloud:"filterable"`
	Backend  Backend  `json:"backend,omitempty" anxcloud:"filterable"`
	// contains filtered or unexported fields
}

Rule represents an LBaaS Rule

func (*Rule) EndpointURL added in v0.4.4

func (r *Rule) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type Rule and the identifier of the given Rule. It implements the api.Object interface on *Rule, making it usable with the generic API client.

func (*Rule) FilterAPIRequestBody added in v0.4.4

func (r *Rule) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for Rules, replacing linked Objects with just their identifier.

func (*Rule) FilterAPIResponse added in v0.4.4

func (cm *Rule) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*Rule) GetIdentifier added in v0.4.5

func (o *Rule) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Rule object

type RuleInfo

type RuleInfo struct {
	Identifier string `json:"identifier" anxcloud:"identifier"`
	Name       string `json:"name"`
}

RuleInfo holds the name and identifier of a rule.

func (*RuleInfo) GetIdentifier added in v0.4.5

func (o *RuleInfo) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a RuleInfo object

type Server

type Server struct {
	HasState

	CustomerIdentifier string     `json:"customer_identifier,omitempty"`
	ResellerIdentifier string     `json:"reseller_identifier,omitempty"`
	Identifier         string     `json:"identifier,omitempty" anxcloud:"identifier"`
	Name               string     `json:"name"`
	IP                 string     `json:"ip"`
	Port               int        `json:"port"`
	Check              string     `json:"check,omitempty"`
	AutomationRules    []RuleInfo `json:"automation_rules,omitempty"`

	// Only the name and identifier fields are used and returned.
	Backend Backend `json:"backend"`
	// contains filtered or unexported fields
}

Server holds the information of a load balancers backend server

func (*Server) EndpointURL

func (s *Server) EndpointURL(ctx context.Context) (*url.URL, error)

EndpointURL returns the URL where to retrieve objects of type Server and the identifier of the given Server. It implements the api.Object interface on *Server, making it usable with the generic API client.

func (*Server) FilterAPIRequestBody

func (s *Server) FilterAPIRequestBody(ctx context.Context) (interface{}, error)

FilterAPIRequestBody generates the request body for Servers, replacing linked Objects with just their identifier.

func (*Server) FilterAPIResponse

func (cm *Server) FilterAPIResponse(ctx context.Context, res *http.Response) (*http.Response, error)

func (*Server) GetIdentifier added in v0.4.5

func (o *Server) GetIdentifier(ctx context.Context) (string, error)

GetIdentifier returns the primary identifier of a Server object

type State

type State struct {
	// programatically usable enum value
	ID string `json:"id"`

	// human readable status text
	Text string `json:"text"`

	Type int `json:"type"`
}

func (State) MarshalJSON

func (s State) MarshalJSON() ([]byte, error)

func (State) StateFailure added in v0.4.2

func (s State) StateFailure() bool

StateFailure checks if the state is marking any failure

func (State) StateProgressing added in v0.4.2

func (s State) StateProgressing() bool

StateProgressing checks if the state is marking any change currently being applied

func (State) StateSuccess added in v0.4.2

func (s State) StateSuccess() bool

StateSuccess checks if the state is one of the successful ones

type StateRetriever added in v0.4.2

type StateRetriever interface {
	StateSuccess() bool
	StateProgressing() bool
	StateFailure() bool
}

Directories

Path Synopsis
Package test includes testing utilities and is not intended for production code usage.
Package test includes testing utilities and is not intended for production code usage.

Jump to

Keyboard shortcuts

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