client

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Overview

Package client provides a client for interacting with the load balancer api

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized returned when the request is not authorized
	ErrUnauthorized = errors.New("client is unauthorized")

	// ErrPermissionDenied returned when the subject does not permissions to access the resource
	ErrPermissionDenied = errors.New("client does not have permissions")

	// ErrLBNotfound returned when the load balancer ID not found
	ErrLBNotfound = errors.New("loadbalancer ID not found")

	// ErrHTTPError returned when the http response is an error
	ErrHTTPError = errors.New("loadbalancer api http error")
)

Functions

This section is empty.

Types

type Client

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

Client creates a new lb api client against a specific endpoint

func NewClient

func NewClient(url string, opts ...Option) *Client

NewClient creates a new lb api client

func (*Client) GetLoadBalancer

func (c *Client) GetLoadBalancer(ctx context.Context, id string) (*LoadBalancer, error)

GetLoadBalancer returns a load balancer by id

type GQLClient

type GQLClient interface {
	Query(tx context.Context, q interface{}, variables map[string]interface{}, options ...graphql.Option) error
}

GQLClient is an interface for a graphql client

type GetLoadBalancer

type GetLoadBalancer struct {
	LoadBalancer LoadBalancer `graphql:"loadBalancer(id: $id)"`
}

GetLoadBalancer is a struct that represents the GetLoadBalancer GraphQL query

type IPAddress

type IPAddress struct {
	ID       string `graphql:"id" json:"id"`
	IP       string `graphql:"ip" json:"ip"`
	Reserved bool   `graphql:"reserved" json:"reserved"`
}

IPAddress is a struct that represents the IPAddress GraphQL type

type LoadBalancer

type LoadBalancer struct {
	ID          string       `graphql:"id" json:"id"`
	Name        string       `graphql:"name" json:"name"`
	Owner       OwnerNode    `graphql:"owner" json:"owner"`
	Location    LocationNode `graphql:"location" json:"location"`
	IPAddresses []IPAddress  `graphql:"IPAddresses" json:"IPAddresses"`
	Metadata    Metadata     `graphql:"metadata" json:"metadata"`
	Ports       Ports        `graphql:"ports" json:"ports"`
}

LoadBalancer is a struct that represents the LoadBalancer GraphQL type

type LocationNode

type LocationNode struct {
	ID string `graphql:"id" json:"id"`
}

LocationNode is a struct that represents the LocationNode GraphQL type

type Metadata added in v0.0.33

type Metadata struct {
	ID       string           `graphql:"id" json:"id"`
	NodeID   string           `graphql:"nodeID" json:"nodeID"`
	Statuses MetadataStatuses `graphql:"statuses" json:"statuses"`
}

Metadata is a struct that represents the metadata GraphQL type

type MetadataStatusEdges added in v0.0.33

type MetadataStatusEdges struct {
	Node MetadataStatusNode `graphql:"node" json:"node"`
}

MetadataStatusEdges is a struct that represents the Metadata status edges GraphQL type

type MetadataStatusNode added in v0.0.33

type MetadataStatusNode struct {
	ID                string          `graphql:"id" json:"id"`
	Data              json.RawMessage `graphql:"data"`
	Source            string          `graphql:"source" json:"source"`
	StatusNamespaceID string          `graphql:"statusNamespaceID" json:"statusNamespaceID"`
}

MetadataStatusNode is a struct that represents the Metadata status node GraphQL type

type MetadataStatuses added in v0.0.33

type MetadataStatuses struct {
	Edges []MetadataStatusEdges `graphql:"edges" json:"edges"`
}

MetadataStatuses is a struct that represents the Metadata statuses GraphQL type

type Option

type Option func(*Client)

Option is a function that modifies a client

func WithHTTPClient

func WithHTTPClient(cli *http.Client) Option

WithHTTPClient functional option to set the http client

type OriginEdges

type OriginEdges struct {
	Node OriginNode `graphql:"node" json:"node"`
}

OriginEdges is a struct that represents the OriginEdges GraphQL type

type OriginNode

type OriginNode struct {
	ID         string `graphql:"id" json:"id"`
	Name       string `graphql:"name" json:"name"`
	Target     string `graphql:"target" json:"target"`
	PortNumber int64  `graphql:"portNumber" json:"portNumber"`
	Weight     int64  `graphql:"weight" json:"weight"`
	Active     bool   `graphql:"active" json:"active"`
}

OriginNode is a struct that represents the OriginNode GraphQL type

type Origins

type Origins struct {
	Edges []OriginEdges `graphql:"edges" json:"edges"`
}

Origins is a struct that represents the Origins GraphQL type

type OwnerNode

type OwnerNode struct {
	ID string `graphql:"id" json:"id"`
}

OwnerNode is a struct that represents the OwnerNode GraphQL type

type Pool

type Pool struct {
	ID       string  `graphql:"id"`
	Name     string  `graphql:"name" json:"name"`
	Protocol string  `graphql:"protocol" json:"protocol"`
	Origins  Origins `graphql:"origins" json:"origins"`
}

Pool is a struct that represents the Pool GraphQL type

type PortEdges

type PortEdges struct {
	Node PortNode `graphql:"node" json:"node"`
}

PortEdges is a struct that represents the PortEdges GraphQL type

type PortNode

type PortNode struct {
	ID     string `graphql:"id" json:"id"`
	Name   string `graphql:"name" json:"name"`
	Number int64  `graphql:"number" json:"number"`
	Pools  []Pool `graphql:"pools" json:"pools"`
}

PortNode is a struct that represents the PortNode GraphQL type

type Ports

type Ports struct {
	Edges []PortEdges `graphql:"edges" json:"edges"`
}

Ports is a struct that represents the Ports GraphQL type

Jump to

Keyboard shortcuts

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