ipamclient

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package ipamclient provides a client for interacting with the IPAM service

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIPAMHTTPUnauthorized is returned when the request is not authorized
	ErrIPAMHTTPUnauthorized = errors.New("ipam api received unauthorized request")

	// ErrIPAMHTTPNotfound is returned when the load balancer ID not found
	ErrIPAMHTTPNotfound = errors.New("ipam ID not found")

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

	// ErrNoAvailableIPs is returned when there are no available IPs within the specified block
	ErrNoAvailableIPs = errors.New("no available IPS within specified block")
)

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 New added in v0.1.0

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

New creates a new ipam api client

func (*Client) CreateIPAddressFromBlock

func (c *Client) CreateIPAddressFromBlock(ctx context.Context, blockid string, nodeid string, nodeownerid string, reserve bool) (*CreateIPAddressResult, error)

CreateIPAddressFromBlock creates an IP Address from the next available address in a given block

func (*Client) DeleteIPAddress

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

DeleteIPAddress deletes an IP Address by id

func (*Client) GetIPAddress

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

GetIPAddress returns an IP Address by id

func (*Client) GetIPAddresses

func (c *Client) GetIPAddresses(ctx context.Context, nodeID string) ([]IPAddressNode, error)

GetIPAddresses returns a list of loadbalancer IP Addresses from node id

func (*Client) GetIPBlock

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

GetIPBlock returns an IP Block by id

func (*Client) GetNextAvailableAddressFromBlock

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

GetNextAvailableAddressFromBlock returns the next available address from a block

type CreateIPAddress

type CreateIPAddress struct {
	CreateIPAddressResult `graphql:"createIPAddress(input: $input)"`
}

CreateIPAddress is the mutation for creating an IP Address

type CreateIPAddressInput

type CreateIPAddressInput struct {
	IP          string `graphql:"ip" json:"ip"`
	IPBlockID   string `graphql:"ipBlockID" json:"ipBlockID"`
	NodeID      string `graphql:"nodeID" json:"nodeID"`
	NodeOwnerID string `graphql:"nodeOwnerID" json:"nodeOwnerID"`
	Reserved    bool   `graphql:"reserved" json:"reserved"`
}

CreateIPAddressInput is the set of input required for creating an IP address

type CreateIPAddressResult

type CreateIPAddressResult struct {
	// IPAddress MyIPAddress `graphql:"ipAddress"`
	IPAddress struct {
		IPAddressNode
		IPBlock IPBlock
	} `graphql:"ipAddress"`
}

CreateIPAddressResult is the result of the mutation to create an IP Address

type DeleteIPAddress

type DeleteIPAddress struct {
	DeleteIPAddress DeleteIPAddressResult `graphql:"deleteIPAddress(id: $id)"`
}

DeleteIPAddress is the mutation for deleting an IP Address

type DeleteIPAddressResult

type DeleteIPAddressResult struct {
	DeletedID string `graphql:"deletedID"`
}

DeleteIPAddressResult is the result of the mutation to delete an IP Address

type GQLClient

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

GQLClient is an interface for a graphql client

type GetIPAddress

type GetIPAddress struct {
	IPAddress GetIPAddressResult `graphql:"ipAddress(id: $id)"`
}

GetIPAddress is the query used for getting an IP Address

type GetIPAddressResult

type GetIPAddressResult struct {
	IPAddressNode
	IPBlock IPBlock `graphql:"ipBlock" json:"ipBlock"`
}

GetIPAddressResult is the result of a query for an IP Address

type GetIPAddressesByNode

type GetIPAddressesByNode struct {
	NodeIPAddress struct {
		ID string `graphql:"id" json:"id"`

		LoadBalancerFragment struct {
			IPAddressableFragment
		} `graphql:"... on LoadBalancer"`
	} `graphql:"node(id: $id)"`
}

GetIPAddressesByNode query for getting IP Addresses by node

type GetIPBlock

type GetIPBlock struct {
	IPBlock GetIPBlockResult `graphql:"ipBlock(id: $id)"`
}

GetIPBlock is the query used for getting an IP Block

type GetIPBlockResult

type GetIPBlockResult struct {
	IPBlock

	IPAddress IPAddresses `graphql:"ipAddress" json:"ipAddress"`
}

GetIPBlockResult is the result of a query for an IP Block

type IPAddressEdge

type IPAddressEdge struct {
	Node IPAddressNode `graphql:"node" json:"node"`
}

IPAddressEdge is part of a returned query including an edge(s) associated to an IP Address

type IPAddressNode

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

IPAddressNode is part of a returned query including an associated IP address

type IPAddressableFragment

type IPAddressableFragment struct {
	IPAddresses []IPAddressNode `graphql:"IPAddresses"`
}

IPAddressableFragment fragment for getting IP Addresses by node

type IPAddresses

type IPAddresses struct {
	Edges []IPAddressEdge `graphql:"edges" json:"edges"`
}

IPAddresses is part of a returned query including the edges of an associated IP Address

type IPBlock

type IPBlock struct {
	ID                string      `graphql:"id" json:"id"`
	Prefix            string      `graphql:"prefix" json:"prefix"`
	AllowAutoSubnet   bool        `graphql:"allowAutoSubnet" json:"allowAutoSubnet"`
	AllowAutoAllocate bool        `graphql:"allowAutoAllocate" json:"allowAutoAllocate"`
	IPBlockType       IPBlockType `graphql:"ipBlockType" json:"ipBlockType"`
}

IPBlock is part of a returned query including an associated block

type IPBlockType

type IPBlockType struct {
	ID    string `graphql:"id" json:"id"`
	Name  string `graphql:"name" json:"name"`
	Owner Owner  `graphql:"owner" json:"owner"`
}

IPBlockType is part of a returned query including an associated block type

type Option added in v0.1.0

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 Owner

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

Owner is part of a returned query including an associated owner

Directories

Path Synopsis
internal
mock
Package mock provides mock implementations of the ipam api client
Package mock provides mock implementations of the ipam api client

Jump to

Keyboard shortcuts

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