v1

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Updating        = gs.State{ID: "0", Text: "Updating", Type: gs.StateTypeOK}
	Updated         = gs.State{ID: "1", Text: "Updated", Type: gs.StateTypeOK}
	DeploymentError = gs.State{ID: "2", Text: "DeploymentError", Type: gs.StateTypeError}
	Deployed        = gs.State{ID: "3", Text: "Deployed", Type: gs.StateTypeOK}
	NewlyCreated    = gs.State{ID: "4", Text: "NewlyCreated", Type: gs.StateTypePending}
)

Functions

This section is empty.

Types

type ACL added in v0.4.4

type ACL struct {
	gs.GenericService
	gs.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"`
}

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) 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 {
	gs.GenericService
	gs.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"`
}

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) 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 {
	gs.GenericService
	gs.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"`
}

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) 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 {
	gs.GenericService
	gs.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"`
}

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) 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 LoadBalancer

type LoadBalancer struct {
	gs.GenericService
	State gs.HasState `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"`
}

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) GetIdentifier added in v0.4.5

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

GetIdentifier returns the primary identifier of a LoadBalancer object

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 {
	gs.GenericService
	gs.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"`
}

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) 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 {
	gs.GenericService
	gs.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"`
}

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) 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 deprecated

type State gs.State

Deprecated: use gs.State instead

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