client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 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")

	// ErrInternalServerError returned when the server returns an internal server error
	ErrInternalServerError = errors.New("internal server error")

	// ErrMetadataStatusNotFound returned when the status data is invalid
	ErrMetadataStatusNotFound = errors.New("metadata status not found")
)

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

func (Client) NodeMetadata added in v0.0.35

func (c Client) NodeMetadata(ctx context.Context, id string) (*Metadata, error)

NodeMetadata return the metadata-api subgraph node for a load balancer. Once a load balancer is deleted, it is gone. There are no soft-deletes. However, it's metadata remains to query via the node-resolver metadata-api subgraph. TODO: Move this to a supergraph client

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 GetMetadataNode added in v0.0.35

type GetMetadataNode struct {
	MetadataNode MetadataNode `graphql:"node(id: $id)"`
}

GetMetadataNode is a struct that represents the node-resolver subgraph 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 MetadataNode added in v0.0.35

type MetadataNode struct {
	MetadataNodeFragment `graphql:"... on MetadataNode"`
}

MetadataNode is a struct that represents the MetadataNode GraphQL type

type MetadataNodeFragment added in v0.0.35

type MetadataNodeFragment struct {
	Metadata Metadata `graphql:"metadata" json:"metadata"`
}

MetadataNodeFragment is a struct that represents the MetadataNodeFragment GraphQL fragment

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 {
	TotalCount int                   `graphql:"totalCount" json:"totalCount"`
	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