fleetdbapi

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 38 Imported by: 12

Documentation

Overview

Package fleetdbapi provides the v1 api for the fleetdb service

Index

Constants

View Source
const (
	// OperatorComparitorEqual means the value has to match the keys exactly
	OperatorComparitorEqual OperatorComparitorType = "eq"
	// OperatorComparitorNotEqual means the value has to match the keys exactly, but then exclude those matches
	OperatorComparitorNotEqual = "!="
	// OperatorComparitorLike allows you to pass in a value with % in it and match anything like it. If your string has no % in it one will be added to the end automatically
	OperatorComparitorLike = "like"
	// OperatorComparitorGreaterThan will convert the value at the given key to an int and return results that are greater than Value
	OperatorComparitorGreaterThan = "gt"
	// OperatorComparitorLessThan will convert the value at the given key to an int and return results that are less than Value
	OperatorComparitorLessThan = "lt"
)

TODO; We really should just make these the same values as qm.operators, or they should just be ints (preferrable option being UINTS)

View Source
const (
	// ServerCredentialTypeBMC returns the slug for the builtin ServerCredentialType used
	// to store BMC passwords
	ServerCredentialTypeBMC = "bmc"
)

Variables

View Source
var (
	// ErrNoNextPage is the error returned when there is not an additional page of resources
	ErrNoNextPage = errors.New("no next page found")
	// ErrUUIDParse is returned when the UUID is invalid.
	ErrUUIDParse = errors.New("UUID parse error")

	ErrRouteServerSku     = fmt.Errorf(errRouteBase, "server sku")
	ErrRouteBiosConfigSet = fmt.Errorf(errRouteBase, "bios config set")
)
View Source
var (
	ErrNilServer  = errors.New("bogus server structure provided")
	ErrBadJSONOut = errors.New("object serializaion failed")
	ErrBadJSONIn  = errors.New("object deserializaion failed")
)
View Source
var (
	// MaxPaginationSize represents the maximum number of records that can be returned per page
	MaxPaginationSize = 1000
	// DefaultPaginationSize represents the default number of records that are returned per page
	DefaultPaginationSize = 100
)
View Source
var (
	ErrFwSetByVendorModel = errors.New("error identifying firmware set by server vendor, model")

	// FleetDB attribute namespace for firmware set labels.
	FirmwareSetAttributeNS = "sh.hollow.firmware_set.labels"
)

Functions

func NewCreateServerMessage

func NewCreateServerMessage(srv *models.Server) ([]byte, error)

NewCreateServerMessage composes a CreateServer message for NATS

func OperatorURLQueryDecoder added in v0.18.0

func OperatorURLQueryDecoder(s string) (reflect.Value, error)

OperatorURLQueryDecoder will be passed to a urlquery decoder to escape Operator types from query strings TODO; If we swap OperatorComparitorType and OperatorLogicalType to ints, this function will not be needed. reflect.Set() doesnt convert custom string types back and forth like it is able to with custom int types So we have escaped them and to get the values back we parse out the escape value and see if the strings are operator constants

func OperatorURLQueryEncoder added in v0.18.0

func OperatorURLQueryEncoder(rv reflect.Value) string

OperatorURLQueryEncoder will be passed to a urlquery encoder to escape Operator types from query strings TODO; If we swap OperatorComparitorType and OperatorLogicalType to ints, this function will not be needed. NOTE: reflect.Set() doesnt convert custom string types back and forth like it is able to with custom int types So we have to escape and workaround these custom string types by escaping them when we parse the query.

Types

type AocMacAddressBom

type AocMacAddressBom struct {
	AocMacAddress string `json:"aoc_mac_address"`
	SerialNum     string `json:"serial_num"`
}

AocMacAddressBom provides a struct to map the aoc_mac_address table.

type AttributeListParams

type AttributeListParams struct {
	Namespace string
	Keys      []string
	Operator  OperatorComparitorType
	Value     string
	// OperatorLogicalType is used to define how this AttributeListParam value should be SQL queried
	// this value defaults to OperatorLogicalAND.
	AttributeOperator OperatorLogicalType
}

AttributeListParams allow you to filter the results based on attributes

type Attributes

type Attributes struct {
	Namespace string          `json:"namespace"`
	Data      json.RawMessage `json:"data"`
	CreatedAt time.Time       `json:"created_at"`
	UpdatedAt time.Time       `json:"updated_at"`
}

Attributes provide the ability to apply namespaced settings to an entity. For example servers could have attributes in the `com.equinixmetal.api` namespace that represents equinix metal specific attributes that are stored in the API. The namespace is meant to define who owns the schema and values.

type AuxDevice added in v1.19.3

type AuxDevice struct {
	Vendor     string `json:"vendor" binding:"required"`
	Model      string `json:"model" binding:"required"`
	DeviceType string `json:"device_type" binding:"required"`
	Details    []byte `json:"details" binding:"required"`
}

AuxDevice represents a Sku Aux Device Layout for a Server

type AuxDeviceQuery added in v1.19.3

type AuxDeviceQuery struct {
	Vendor     string `query:"vendor"`
	Model      string `query:"model"`
	DeviceType string `query:"device_type"`
}

AuxDeviceQuery defines values you can query Aux Devices with. Empty strings are ignored.

type BiosConfigComponent added in v0.18.0

type BiosConfigComponent struct {
	ID        string              `json:"id"`
	Name      string              `json:"name" binding:"required"`
	Vendor    string              `json:"vendor"`
	Model     string              `json:"model"`
	Settings  []BiosConfigSetting `json:"settings" binding:"required"`
	CreatedAt time.Time           `json:"created_at"`
	UpdatedAt time.Time           `json:"updated_at"`
}

BiosConfigComponent represents a BIOS Configuration Component

type BiosConfigComponentQuery added in v0.18.0

type BiosConfigComponentQuery struct {
	Name     string                   `query:"name"`
	Vendor   string                   `query:"vendor"`
	Model    string                   `query:"model"`
	Settings []BiosConfigSettingQuery `query:"settings"`
}

BiosConfigComponentQuery defines values you can query BiosConfigComponents with. Empty strings are ignored.

type BiosConfigSet added in v0.18.0

type BiosConfigSet struct {
	ID         string                `json:"id"`
	Name       string                `json:"name" binding:"required"`
	Version    string                `json:"version" binding:"required"`
	Components []BiosConfigComponent `json:"components" binding:"required"`
	CreatedAt  time.Time             `json:"created_at"`
	UpdatedAt  time.Time             `json:"updated_at"`
}

BiosConfigSet represents a BIOS Configuration Set

type BiosConfigSetListParams added in v0.18.0

type BiosConfigSetListParams struct {
	Params     []BiosConfigSetQueryParams `query:"params"`
	Pagination PaginationParams           `query:"page"`
}

BiosConfigSetListParams params is an array of potential expressions when querying. Each one will have a Set. This Set will define values you want to search on, empty strings will be ignored. The ComparitorOperator will define how you want to compare those values. All values within a single BiosConfigSetQueryParams item will be grouped together and "AND"'ed. The LogicalOperator will define how that BiosConfigSetQueryParams item will be grouped with other BiosConfigSetQueryParams items. Note: You must set PaginationParams.Preload to load BiosConfigComponents and BiosConfigSettings.

type BiosConfigSetQuery added in v0.18.0

type BiosConfigSetQuery struct {
	Name       string                     `query:"name"`
	Version    string                     `query:"version"`
	Components []BiosConfigComponentQuery `query:"components"`
}

BiosConfigSetQuery defines values you can query BiosConfigSets with. Empty strings are ignored.

type BiosConfigSetQueryParams added in v0.18.0

type BiosConfigSetQueryParams struct {
	Set                BiosConfigSetQuery     `query:"set"`
	LogicalOperator    OperatorLogicalType    `query:"logical"`
	ComparitorOperator OperatorComparitorType `query:"comparitor"`
}

BiosConfigSetQueryParams defines a BiosConfigSetQuery struct and operators you can use to query BiosConfigSets with. If LogicalOperator is an empty string, it will default to OperatorLogicalAND. If ComparitorOperator is an empty string, it will default to OperatorComparitorEqual

type BiosConfigSetting added in v0.18.0

type BiosConfigSetting struct {
	ID        string    `json:"id"`
	Key       string    `json:"key" binding:"required"`
	Value     string    `json:"value" binding:"required"`
	Raw       []byte    `json:"raw,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

BiosConfigSetting represents a BIOS Configuration Component Setting

type BiosConfigSettingQuery added in v0.18.0

type BiosConfigSettingQuery struct {
	Key   string `query:"key"`
	Value string `query:"value"`
}

BiosConfigSettingQuery defines values you can query BiosConfigSettings with. Empty strings are ignored.

type BmcMacAddressBom

type BmcMacAddressBom struct {
	BmcMacAddress string `json:"bmc_mac_address"`
	SerialNum     string `json:"serial_num"`
}

BmcMacAddressBom provides a struct to map the bmc_mac_address table.

type Bom

type Bom struct {
	SerialNum     string `json:"serial_num"`      // physical serial number listed outside of a server
	AocMacAddress string `json:"aoc_mac_address"` // Aoc is alternative name of the fiber channel card MAC address
	BmcMacAddress string `json:"bmc_mac_address"`
	NumDefiPmi    string `json:"num_defi_pmi"`
	NumDefPWD     string `json:"num_def_pwd"` // DefPWD is the IPMI Password in the portal
	Metro         string `json:"metro"`
}

Bom provides a struct to map the bom_info table. Naming conversion is strange here just in order to make it consistent with generated BomInfo.

type Client

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

Client has the ability to talk to a fleetdb api server running at the given URI

func NewClient

func NewClient(url string, doerClient Doer) (*Client, error)

NewClient will return a fleetdb client configured to talk to the given URL. This client will not set the authorization header for you automatically and is left to be handled by the Doer that is provided.

Example:

ctx := context.TODO()
provider, _ := oidc.NewProvider(ctx, "https://OIDC_ISSUER.COM")

oauthConfig := clientcredentials.Config{
	ClientID:       "CLIENT_ID",
	ClientSecret:   "CLIENT_SECRET",
	TokenURL:       provider.Endpoint().TokenURL,
	Scopes:         []string{"SCOPE", "SCOPE2"},
	EndpointParams: url.Values{"audience": []string{"HOLLOW_AUDIENCE_VALUE"}},
}

c, _ := fleetdbapi.NewClient("HOLLOW_URI", oauthConfig.Client(ctx))

func NewClientWithToken

func NewClientWithToken(authToken, url string, doerClient Doer) (*Client, error)

NewClientWithToken will initialize a new hollow client with the given auth token and URL

func (*Client) BillOfMaterialsBatchUpload

func (c *Client) BillOfMaterialsBatchUpload(ctx context.Context, boms []Bom) (*ServerResponse, error)

BillOfMaterialsBatchUpload will attempt to write multiple boms to database.

func (*Client) Create

func (c *Client) Create(ctx context.Context, srv Server) (*uuid.UUID, *ServerResponse, error)

Create will attempt to create a server in Hollow and return the new server's UUID

func (*Client) CreateAttributes

func (c *Client) CreateAttributes(ctx context.Context, srvUUID uuid.UUID, attr Attributes) (*ServerResponse, error)

CreateAttributes will to create the given attributes for a given server

func (*Client) CreateComponents

func (c *Client) CreateComponents(ctx context.Context, srvUUID uuid.UUID, components ServerComponentSlice) (*ServerResponse, error)

CreateComponents will create given components for a given server

func (*Client) CreateServerBiosConfigSet added in v0.18.0

func (c *Client) CreateServerBiosConfigSet(ctx context.Context, set BiosConfigSet) (*ServerResponse, error)

CreateServerBiosConfigSet will store the BiosConfigSet, and return the generated UUID of the BiosConfigSet

func (*Client) CreateServerComponentFirmware

func (c *Client) CreateServerComponentFirmware(ctx context.Context, firmware ComponentFirmwareVersion) (*uuid.UUID, *ServerResponse, error)

CreateServerComponentFirmware will attempt to create a firmware in Hollow and return the firmware UUID

func (*Client) CreateServerComponentFirmwareSet

func (c *Client) CreateServerComponentFirmwareSet(ctx context.Context, set ComponentFirmwareSetRequest) (*uuid.UUID, *ServerResponse, error)

CreateServerComponentFirmwareSet will attempt to create a firmware set in Hollow and return the firmware UUID

func (*Client) CreateServerComponentType

func (c *Client) CreateServerComponentType(ctx context.Context, t ServerComponentType) (*ServerResponse, error)

CreateServerComponentType will attempt to create a server component type in Hollow

func (*Client) CreateServerCredentialType

func (c *Client) CreateServerCredentialType(ctx context.Context, sType *ServerCredentialType) (*ServerResponse, error)

CreateServerCredentialType will create a new server secret type

func (*Client) CreateServerSku added in v1.19.3

func (c *Client) CreateServerSku(ctx context.Context, sku ServerSku) (*ServerResponse, error)

CreateServerSku will store the ServerSku, and return the generated UUID of the ServerSku

func (*Client) CreateVersionedAttributes

func (c *Client) CreateVersionedAttributes(ctx context.Context, srvUUID uuid.UUID, va VersionedAttributes) (*ServerResponse, error)

CreateVersionedAttributes will create a new versioned attribute for a given server

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, srv Server) (*ServerResponse, error)

Delete will attempt to delete a server in Hollow and return an error on failure

func (*Client) DeleteAttributes

func (c *Client) DeleteAttributes(ctx context.Context, srvUUID uuid.UUID, ns string) (*ServerResponse, error)

DeleteAttributes will attempt to delete attributes by server uuid and namespace return an error on failure

func (*Client) DeleteCredential

func (c *Client) DeleteCredential(ctx context.Context, srvUUID uuid.UUID, secretSlug string) (*ServerResponse, error)

DeleteCredential will remove the secret for a given server UUID and secret type.

func (*Client) DeleteServerBiosConfigSet added in v0.18.0

func (c *Client) DeleteServerBiosConfigSet(ctx context.Context, id uuid.UUID) (*ServerResponse, error)

DeleteServerBiosConfigSet will delete the BiosConfigSet referred to by the given ID if found

func (*Client) DeleteServerComponentFirmware

func (c *Client) DeleteServerComponentFirmware(ctx context.Context, firmware ComponentFirmwareVersion) (*ServerResponse, error)

DeleteServerComponentFirmware will attempt to delete firmware and return an error on failure

func (*Client) DeleteServerComponentFirmwareSet

func (c *Client) DeleteServerComponentFirmwareSet(ctx context.Context, firmwareSetID uuid.UUID) (*ServerResponse, error)

DeleteServerComponentFirmwareSet will attempt to delete a firmware set and return an error on failure

func (*Client) DeleteServerComponents

func (c *Client) DeleteServerComponents(ctx context.Context, srvUUID uuid.UUID) (*ServerResponse, error)

DeleteServerComponents will delete components for the given server identifier.

func (*Client) DeleteServerSku added in v1.19.3

func (c *Client) DeleteServerSku(ctx context.Context, id uuid.UUID) (*ServerResponse, error)

DeleteServerSku will delete the ServerSku referred to by the given ID if found

func (*Client) Get

func (c *Client) Get(ctx context.Context, srvUUID uuid.UUID) (*Server, *ServerResponse, error)

Get will return a server by it's UUID

func (*Client) GetAttributes

func (c *Client) GetAttributes(ctx context.Context, srvUUID uuid.UUID, ns string) (*Attributes, *ServerResponse, error)

GetAttributes will get all the attributes in a namespace for a given server

func (*Client) GetBomInfoByAOCMacAddr

func (c *Client) GetBomInfoByAOCMacAddr(ctx context.Context, aocMacAddr string) (*Bom, *ServerResponse, error)

GetBomInfoByAOCMacAddr will return the bom info object by the aoc mac address.

func (*Client) GetBomInfoByBMCMacAddr

func (c *Client) GetBomInfoByBMCMacAddr(ctx context.Context, bmcMacAddr string) (*Bom, *ServerResponse, error)

GetBomInfoByBMCMacAddr will return the bom info object by the bmc mac address.

func (*Client) GetComponents

func (c *Client) GetComponents(ctx context.Context, srvUUID uuid.UUID, params *PaginationParams) (ServerComponentSlice, *ServerResponse, error)

GetComponents will get all the components for a given server

func (*Client) GetCredential

func (c *Client) GetCredential(ctx context.Context, srvUUID uuid.UUID, secretSlug string) (*ServerCredential, *ServerResponse, error)

GetCredential will return the secret for the secret type for the given server UUID

func (*Client) GetHistoryByID added in v1.19.1

func (c *Client) GetHistoryByID(ctx context.Context, evtID uuid.UUID) ([]*Event, *ServerResponse, error)

GetHistoryByID returns the details of the event with the given ID

func (*Client) GetServerBiosConfigSet added in v0.18.0

func (c *Client) GetServerBiosConfigSet(ctx context.Context, id uuid.UUID) (*ServerResponse, error)

GetServerBiosConfigSet will retrieve the BiosConfigSet referred to by the given ID if found

func (*Client) GetServerComponentFirmware

func (c *Client) GetServerComponentFirmware(ctx context.Context, fwUUID uuid.UUID) (*ComponentFirmwareVersion, *ServerResponse, error)

GetServerComponentFirmware will return a firmware by its UUID

func (*Client) GetServerComponentFirmwareSet

func (c *Client) GetServerComponentFirmwareSet(ctx context.Context, fwSetUUID uuid.UUID) (*ComponentFirmwareSet, *ServerResponse, error)

GetServerComponentFirmwareSet will return a firmware by its UUID

func (*Client) GetServerEvents added in v1.19.0

func (c *Client) GetServerEvents(ctx context.Context, srvID uuid.UUID,
	params *PaginationParams) ([]*Event, *ServerResponse, error)

GetServerEvents returns the most recent events for the given server ID

func (*Client) GetServerInventory added in v0.17.2

func (c *Client) GetServerInventory(ctx context.Context, srvID uuid.UUID, inband bool) (*rivets.Server, *ServerResponse, error)

GetServerInventory returns the last reported server state of the kind specified by the inband parameter

func (*Client) GetServerSku added in v1.19.3

func (c *Client) GetServerSku(ctx context.Context, id uuid.UUID) (*ServerResponse, error)

GetServerSku will retrieve the ServerSku referred to by the given ID if found

func (*Client) GetVersionedAttributes

func (c *Client) GetVersionedAttributes(ctx context.Context, srvUUID uuid.UUID, ns string) ([]VersionedAttributes, *ServerResponse, error)

GetVersionedAttributes will return all the versioned attributes for a given server

func (*Client) List

func (c *Client) List(ctx context.Context, params *ServerListParams) ([]Server, *ServerResponse, error)

List will return all servers with optional params to filter the results

func (*Client) ListAttributes

func (c *Client) ListAttributes(ctx context.Context, srvUUID uuid.UUID, params *PaginationParams) ([]Attributes, *ServerResponse, error)

ListAttributes will get all the attributes for a given server

func (*Client) ListComponents

ListComponents will get all the components matching the given parameters

func (*Client) ListServerBiosConfigSet added in v0.18.0

func (c *Client) ListServerBiosConfigSet(ctx context.Context, params *BiosConfigSetListParams) (*ServerResponse, error)

ListServerBiosConfigSet will return a list of BiosConfigSets referred to by the given query. More details about querying at the type definition of BiosConfigSetListParams.

func (*Client) ListServerComponentFirmware

func (c *Client) ListServerComponentFirmware(ctx context.Context, params *ComponentFirmwareVersionListParams) ([]ComponentFirmwareVersion, *ServerResponse, error)

ListServerComponentFirmware will return all firmwares with optional params to filter the results

func (*Client) ListServerComponentFirmwareSet

func (c *Client) ListServerComponentFirmwareSet(ctx context.Context, params *ComponentFirmwareSetListParams) ([]ComponentFirmwareSet, *ServerResponse, error)

ListServerComponentFirmwareSet will return all firmwares with optional params to filter the results if AttributeListParams is defined then ignore the main struct fields (Vendor, Model, Labels) otherwise do the selection based on the Vendor, Model, Labelswill return all firmwares with optional params to filter the results vendor and model should be non-empty. arbitraryLabels is formatted as k1=v1,k2=v2,etc. To view the behavior of the default/latest label, please check https://fleet-docs.pages.equinixmetal.net/procedures/firmware-install/#firmware-sets

func (*Client) ListServerComponentTypes

func (c *Client) ListServerComponentTypes(ctx context.Context, params *ServerComponentTypeListParams) (ServerComponentTypeSlice, *ServerResponse, error)

ListServerComponentTypes will return the server component types with optional params

func (*Client) ListServerCredentialTypes

func (c *Client) ListServerCredentialTypes(ctx context.Context, params *PaginationParams) ([]ServerCredentialType, *ServerResponse, error)

ListServerCredentialTypes will return all server secret types

func (*Client) ListServerSku added in v1.19.3

func (c *Client) ListServerSku(ctx context.Context, params *ServerSkuListParams) (*ServerResponse, error)

ListServerSku will return a list of ServerSku referred to by the given More details about querying at the type definition of ServerSkuListParams.

func (*Client) ListVersionedAttributes

func (c *Client) ListVersionedAttributes(ctx context.Context, srvUUID uuid.UUID) ([]VersionedAttributes, *ServerResponse, error)

ListVersionedAttributes will return all the versioned attributes for a given server

func (*Client) NextPage

func (c *Client) NextPage(ctx context.Context, resp ServerResponse, recs interface{}) (*ServerResponse, error)

NextPage will update the server response with the next page of results

func (*Client) RemoveServerComponentFirmwareSetFirmware

func (c *Client) RemoveServerComponentFirmwareSetFirmware(ctx context.Context, fwSetUUID uuid.UUID, firmwareSet ComponentFirmwareSetRequest) (*ServerResponse, error)

RemoveServerComponentFirmwareSetFirmware will update a firmware set by removing the mapping for the firmware id(s) passed in the firmwareSet parameter

func (*Client) SetCredential

func (c *Client) SetCredential(ctx context.Context, srvUUID uuid.UUID, secretSlug, username, password string) (*ServerResponse, error)

SetCredential will set the secret for a given server UUID and secret type.

func (*Client) SetDumper added in v0.18.1

func (c *Client) SetDumper(w io.Writer)

SetDumper sets requests and responses to be written to the given writer (os.Stdout for example) to aid debugging.

func (*Client) SetServerInventory added in v0.17.2

func (c *Client) SetServerInventory(ctx context.Context, srvID uuid.UUID,
	srv *rivets.Server, inband bool) (*ServerResponse, error)

SetServerInventory writes the given server structure back to the database

func (*Client) SetToken

func (c *Client) SetToken(token string)

SetToken allows you to change the token of a client

func (*Client) Update

func (c *Client) Update(ctx context.Context, srvUUID uuid.UUID, srv Server) (*ServerResponse, error)

Update will to update a server with the new values passed in

func (*Client) UpdateAttributes

func (c *Client) UpdateAttributes(ctx context.Context, srvUUID uuid.UUID, ns string, data json.RawMessage) (*ServerResponse, error)

UpdateAttributes will to update the data stored in a given namespace for a given server

func (*Client) UpdateComponentFirmwareSetRequest

func (c *Client) UpdateComponentFirmwareSetRequest(ctx context.Context, fwSetUUID uuid.UUID, firmwareSet ComponentFirmwareSetRequest) (*ServerResponse, error)

UpdateComponentFirmwareSetRequest will add a firmware set with the new firmware id(s) passed in the firmwareSet parameter

func (*Client) UpdateComponents

func (c *Client) UpdateComponents(ctx context.Context, srvUUID uuid.UUID, components ServerComponentSlice) (*ServerResponse, error)

UpdateComponents will update given components for a given server

func (*Client) UpdateEvent added in v1.19.0

func (c *Client) UpdateEvent(ctx context.Context, evt *Event) (*ServerResponse, error)

UpdateEvent adds a new event to the event history

func (*Client) UpdateServerBiosConfigSet added in v0.18.0

func (c *Client) UpdateServerBiosConfigSet(ctx context.Context, id uuid.UUID, set BiosConfigSet) (*ServerResponse, error)

UpdateServerBiosConfigSet will update a config set.

func (*Client) UpdateServerComponentFirmware

func (c *Client) UpdateServerComponentFirmware(ctx context.Context, fwUUID uuid.UUID, firmware ComponentFirmwareVersion) (*ServerResponse, error)

UpdateServerComponentFirmware will to update a firmware with the new values passed in

func (*Client) UpdateServerSku added in v1.19.3

func (c *Client) UpdateServerSku(ctx context.Context, id uuid.UUID, set ServerSku) (*ServerResponse, error)

UpdateServerSku will update a config set. Note: Empty IDs are assumed new items to add. Items not present are assumed to be deleted.

type ClientError

type ClientError struct {
	Message string
}

ClientError is returned when invalid arguments are provided to the client

func (*ClientError) Error

func (e *ClientError) Error() string

Error returns the ClientError in string format

type ClientInterface

type ClientInterface interface {
	Create(context.Context, Server) (*uuid.UUID, *ServerResponse, error)
	Delete(context.Context, Server) (*ServerResponse, error)
	Get(context.Context, uuid.UUID) (*Server, *ServerResponse, error)
	List(context.Context, *ServerListParams) ([]Server, *ServerResponse, error)
	Update(context.Context, uuid.UUID, Server) (*ServerResponse, error)

	CreateAttributes(context.Context, uuid.UUID, Attributes) (*ServerResponse, error)
	DeleteAttributes(ctx context.Context, u uuid.UUID, ns string) (*ServerResponse, error)
	GetAttributes(context.Context, uuid.UUID, string) (*Attributes, *ServerResponse, error)
	ListAttributes(context.Context, uuid.UUID, *PaginationParams) ([]Attributes, *ServerResponse, error)
	UpdateAttributes(ctx context.Context, u uuid.UUID, ns string, data json.RawMessage) (*ServerResponse, error)

	GetComponents(context.Context, uuid.UUID, *PaginationParams) ([]ServerComponent, *ServerResponse, error)
	ListComponents(context.Context, *ServerComponentListParams) ([]ServerComponent, *ServerResponse, error)
	CreateComponents(context.Context, uuid.UUID, ServerComponentSlice) (*ServerResponse, error)
	UpdateComponents(context.Context, uuid.UUID, ServerComponentSlice) (*ServerResponse, error)
	DeleteServerComponents(context.Context, uuid.UUID) (*ServerResponse, error)

	CreateVersionedAttributes(context.Context, uuid.UUID, VersionedAttributes) (*ServerResponse, error)
	GetVersionedAttributes(context.Context, uuid.UUID, string) ([]VersionedAttributes, *ServerResponse, error)
	ListVersionedAttributes(context.Context, uuid.UUID) ([]VersionedAttributes, *ServerResponse, error)

	CreateServerComponentFirmware(context.Context, ComponentFirmwareVersion) (*uuid.UUID, *ServerResponse, error)
	DeleteServerComponentFirmware(context.Context, ComponentFirmwareVersion) (*ServerResponse, error)
	GetServerComponentFirmware(context.Context, uuid.UUID) (*ComponentFirmwareVersion, *ServerResponse, error)
	ListServerComponentFirmware(context.Context, *ComponentFirmwareVersionListParams) ([]ComponentFirmwareVersion, *ServerResponse, error)
	UpdateServerComponentFirmware(context.Context, uuid.UUID, ComponentFirmwareVersion) (*ServerResponse, error)

	CreateServerComponentFirmwareSet(context.Context, ComponentFirmwareSetRequest) (*uuid.UUID, *ServerResponse, error)
	UpdateComponentFirmwareSetRequest(context.Context, ComponentFirmwareSetRequest) (*uuid.UUID, *ServerResponse, error)
	GetServerComponentFirmwareSet(context.Context, uuid.UUID) (*ComponentFirmwareSet, *ServerResponse, error)
	ListServerComponentFirmwareSet(context.Context, *ComponentFirmwareSetListParams) ([]ComponentFirmwareSet, *ServerResponse, error)
	ListFirmwareSets(context.Context, *ComponentFirmwareSetListParams) ([]ComponentFirmwareSet, *ServerResponse, error)
	DeleteServerComponentFirmwareSet(context.Context, uuid.UUID) (*ServerResponse, error)

	GetCredential(context.Context, uuid.UUID, string) (*ServerCredential, *ServerResponse, error)
	SetCredential(context.Context, uuid.UUID, string, string) (*ServerResponse, error)
	DeleteCredential(context.Context, uuid.UUID, string) (*ServerResponse, error)
	ListServerCredentialTypes(context.Context) (*ServerResponse, error)

	BillOfMaterialsBatchUpload(context.Context, []Bom) (*ServerResponse, error)
	GetBomInfoByAOCMacAddr(context.Context, string) (*Bom, *ServerResponse, error)
	GetBomInfoByBMCMacAddr(context.Context, string) (*Bom, *ServerResponse, error)

	GetServerInventory(context.Context, uuid.UUID, bool) (*rivets.Server, *ServerResponse, error)
	SetServerInventory(context.Context, uuid.UUID, *rivets.Server, bool) (*ServerResponse, error)

	GetHistoryByID(context.Context, uuid.UUID) (*Event, *ServerResponse, error)
	GetServerEvents(context.Context, uuid.UUID) ([]*Event, *ServerResponse, error)
	UpdateEvent(context.Context, *Event) (*ServerResponse, error)

	CreateServerBiosConfigSet(context.Context, BiosConfigSet) (*uuid.UUID, *ServerResponse, error)
	GetServerBiosConfigSet(context.Context, uuid.UUID) (*BiosConfigSet, *ServerResponse, error)
	DeleteServerBiosConfigSet(context.Context, uuid.UUID) (*ServerResponse, error)
	ListServerBiosConfigSet(context.Context, *BiosConfigSetListParams) (*ServerResponse, error)
	UpdateServerBiosConfigSet(context.Context, uuid.UUID, BiosConfigSet) (*ServerResponse, error)

	CreateServerSku(context.Context, ServerSku) (*uuid.UUID, *ServerResponse, error)
	GetServerSku(context.Context, uuid.UUID) (*ServerResponse, error)
	UpdateServerSku(context.Context, uuid.UUID, ServerSku) (*ServerResponse, error)
	DeleteServerSku(context.Context, uuid.UUID) (*ServerResponse, error)
	ListServerSkus(context.Context, *ServerSkuListParams) (*ServerResponse, error)
}

ClientInterface provides an interface for the expected calls to interact with a fleetdb api

type ComponentFirmwareSet

type ComponentFirmwareSet struct {
	CreatedAt         time.Time                  `json:"created_at"`
	UpdatedAt         time.Time                  `json:"updated_at"`
	Name              string                     `json:"name"`
	Attributes        []Attributes               `json:"attributes"`
	ComponentFirmware []ComponentFirmwareVersion `json:"component_firmware"`
	UUID              uuid.UUID                  `json:"uuid"`
}

ComponentFirmwareSet represents a group of firmwares

type ComponentFirmwareSetListParams

type ComponentFirmwareSetListParams struct {
	Name                string `form:"name"`
	Vendor              string `form:"vendor"`
	Model               string `form:"model"`
	Labels              string `form:"labels"`
	Pagination          *PaginationParams
	AttributeListParams []AttributeListParams
}

ComponentFirmwareSetListParams allows you to filter the results

type ComponentFirmwareSetRequest

type ComponentFirmwareSetRequest struct {
	Name                   string       `json:"name"`
	Attributes             []Attributes `json:"attributes"`
	ComponentFirmwareUUIDs []string     `json:"component_firmware_uuids"`
	ID                     uuid.UUID    `json:"uuid"`
}

ComponentFirmwareSetRequest represents the payload to create a firmware set

type ComponentFirmwareVersion

type ComponentFirmwareVersion struct {
	UUID          uuid.UUID `json:"uuid"`
	Vendor        string    `json:"vendor" binding:"required,lowercase"`
	Model         []string  `json:"model" binding:"required"`
	Filename      string    `json:"filename" binding:"required"`
	Version       string    `json:"version" binding:"required"`
	Component     string    `json:"component" binding:"required,lowercase"`
	Checksum      string    `json:"checksum" binding:"required,lowercase"`
	UpstreamURL   string    `json:"upstream_url" binding:"required"`
	RepositoryURL string    `json:"repository_url" binding:"required"`
	// The client has to always explicitly set this to true or false
	// for this to work with the validator, it needs to be a bool.
	InstallInband *bool     `json:"install_inband" binding:"required"`
	OEM           *bool     `json:"oem" binding:"required"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
}

ComponentFirmwareVersion represents a firmware file

type ComponentFirmwareVersionListParams

type ComponentFirmwareVersionListParams struct {
	Vendor     string   `form:"vendor"`
	Model      []string `form:"model"`
	Version    string   `form:"version"`
	Filename   string   `form:"filename"`
	Checksum   string   `form:"checksum"`
	Component  string   `form:"component"`
	Pagination *PaginationParams
}

ComponentFirmwareVersionListParams allows you to filter the results

type CreateServer

type CreateServer struct {
	Metadata     *MsgMetadata `json:"metadata,omitempty"`
	Name         null.String  `json:"name"`
	FacilityCode null.String  `json:"facility_code"`
	ID           string       `json:"id"`
}

CreateServer is a message type published via NATS

func DeserializeCreateServer

func DeserializeCreateServer(inc []byte) (*CreateServer, error)

DeserializeCreateServer reconstitutes a CreateServer from raw bytes

type Disk added in v1.19.3

type Disk struct {
	Vendor   string `json:"vendor" binding:"required"`
	Model    string `json:"model" binding:"required"`
	Bytes    int64  `json:"bytes" binding:"required"`
	Protocol string `json:"protocol" binding:"required"`
	Count    int64  `json:"count" binding:"required"`
}

Disk represents a Sku Disk Layout for a Server

type DiskQuery added in v1.19.3

type DiskQuery struct {
	Vendor   string  `query:"vendor"`
	Model    string  `query:"model"`
	Bytes    []int64 `query:"bytes"`
	Protocol string  `query:"protocol"`
	Count    []int64 `query:"count"`
}

DiskQuery defines values you can query Disks with. Empty strings are ignored.

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is an interface for an HTTP client that can make requests

type Event added in v1.19.0

type Event struct {
	EventID     uuid.UUID       `json:"event_id" binding:"required,uuid4_rfc4122"`
	Type        string          `json:"event_type" binding:"required"`
	Start       time.Time       `json:"event_start" binding:"required,ltfield=End"`
	End         time.Time       `json:"event_end" binding:"required,gtfield=Start"`
	Target      uuid.UUID       `json:"target_server" binding:"required,uuid4_rfc4122"`
	Parameters  json.RawMessage `json:"parameters,omitempty" binding:"-"`
	FinalState  string          `json:"final_state" binding:"required"`
	FinalStatus json.RawMessage `json:"final_status,omitempty" binding:"-"`
}
type Link struct {
	Href string `json:"href,omitempty"`
}

Link represents an address to a page

type Memory added in v1.19.3

type Memory struct {
	Vendor string `json:"vendor" binding:"required"`
	Model  string `json:"model" binding:"required"`
	Bytes  int64  `json:"bytes" binding:"required"`
	Count  int64  `json:"count" binding:"required"`
}

Memory represents a Sku Memory Layout for a Server

type MemoryQuery added in v1.19.3

type MemoryQuery struct {
	Vendor string  `query:"vendor"`
	Model  string  `query:"model"`
	Bytes  []int64 `query:"bytes"`
	Count  []int64 `query:"count"`
}

MemoryQuery defines values you can query Memories with. Empty strings are ignored.

type MsgMetadata

type MsgMetadata struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

MsgMetadata captures some message-type agnostic descriptive data a consumer might need

type Nic added in v1.19.3

type Nic struct {
	Vendor        string `json:"vendor" binding:"required"`
	Model         string `json:"model" binding:"required"`
	PortBandwidth int64  `json:"port_bandwidth" binding:"required"`
	PortCount     int64  `json:"port_count" binding:"required"`
	Count         int64  `json:"count" binding:"required"`
}

Nic represents a Sku Nic Layout for a Server

type NicQuery added in v1.19.3

type NicQuery struct {
	Vendor        string  `query:"vendor"`
	Model         string  `query:"model"`
	PortBandwidth []int64 `query:"port_bandwidth"`
	PortCount     []int64 `query:"port_count"`
	Count         []int64 `query:"count"`
}

NicQuery defines values you can query Nic structs with. Empty strings are ignored.

type OperatorComparitorType added in v0.18.0

type OperatorComparitorType string

OperatorComparitorType is used to control what kind of search is performed for any query. (preferrable option being UINTS)

type OperatorLogicalType added in v0.18.0

type OperatorLogicalType string

OperatorLogicalType is used to define how to group a query with other queries. Ex: (query expression) AND (query expression) OR (query expression)

const (
	// OperatorLogicalOR informs the SQL Builder to use OR when adding the param to the SQL Query. Making it Inclusive
	OperatorLogicalOR OperatorLogicalType = "or"
	// OperatorLogicalAND informs the SQL Builder to use AND when adding the param to the SQL Query. Making it Explicitly Inclusive
	OperatorLogicalAND = "and"
)

TODO; Should these just be ints?

type PaginationParams

type PaginationParams struct {
	Limit   int    `json:"limit,omitempty"`
	Page    int    `json:"page,omitempty"`
	Cursor  string `json:"cursor,omitempty"`
	Preload bool   `json:"preload,omitempty"`
	OrderBy string `json:"orderby,omitempty"`
}

PaginationParams allow you to paginate the results. Some tables can have multiple preloadable child tables. Set Preload to true to load them. TODO; Preload should probably be moved over to the params of each individual endpoint. Example: ServerListParams.

type Router

type Router struct {
	AuthMW        *ginauth.MultiTokenMiddleware
	DB            *sqlx.DB
	SecretsKeeper *secrets.Keeper
	Logger        *zap.Logger
}

Router provides a router for the v1 API

func (*Router) Routes

func (r *Router) Routes(rg *gin.RouterGroup)

Routes will add the routes for this API version to a router group

type Server

type Server struct {
	UUID                uuid.UUID             `json:"uuid"`
	Name                string                `json:"name"`
	FacilityCode        string                `json:"facility"`
	Attributes          []Attributes          `json:"attributes"`
	Components          []ServerComponent     `json:"components"`
	VersionedAttributes []VersionedAttributes `json:"versioned_attributes"`
	CreatedAt           time.Time             `json:"created_at"`
	UpdatedAt           time.Time             `json:"updated_at"`
	// DeletedAt is a pointer to a Time in order to be able to support checks for nil time
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

Server represents a server in a facility

type ServerComponent

type ServerComponent struct {
	UUID                uuid.UUID             `json:"uuid"`
	ServerUUID          uuid.UUID             `json:"server_uuid" binding:"required"`
	Name                string                `json:"name" binding:"required"`
	Vendor              string                `json:"vendor"`
	Model               string                `json:"model"`
	Serial              string                `json:"serial" binding:"required"`
	Attributes          []Attributes          `json:"attributes"`
	VersionedAttributes []VersionedAttributes `json:"versioned_attributes"`
	ComponentTypeID     string                `json:"component_type_id" binding:"required"`
	ComponentTypeName   string                `json:"component_type_name" binding:"required"`
	ComponentTypeSlug   string                `json:"component_type_slug" binding:"required"`
	CreatedAt           time.Time             `json:"created_at"`
	UpdatedAt           time.Time             `json:"updated_at"`
}

ServerComponent represents a component of a server. These can be things like processors, NICs, hard drives, etc.

Note: when setting validator struct tags, ensure no extra spaces are present between

comma separated values or validation will fail with a not so useful 500 error.

type ServerComponentListParams

type ServerComponentListParams struct {
	Name                         string
	Vendor                       string
	Model                        string
	Serial                       string
	ServerComponentType          string
	AttributeListParams          []AttributeListParams
	VersionedAttributeListParams []AttributeListParams
	Pagination                   *PaginationParams
}

ServerComponentListParams allows you to filter the results by server components

type ServerComponentSlice

type ServerComponentSlice []ServerComponent

ServerComponentSlice is a slice of ServerComponent objects

type ServerComponentType

type ServerComponentType struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

ServerComponentType provides a way to group server components by the type

type ServerComponentTypeListParams

type ServerComponentTypeListParams struct {
	Name             string
	PaginationParams *PaginationParams
}

ServerComponentTypeListParams allows you to filter the results

type ServerComponentTypeSlice

type ServerComponentTypeSlice []*ServerComponentType

ServerComponentTypeSlice is a slice of the ServerComponentType

func (ServerComponentTypeSlice) ByID

ByID returns the ServerComponentType matched by its ID field value

func (ServerComponentTypeSlice) ByName

ByName returns the ServerComponentType matched by its Name field value

func (ServerComponentTypeSlice) BySlug

BySlug returns the ServerComponentType matched by its Slug field value

type ServerCredential

type ServerCredential struct {
	ServerID   uuid.UUID `json:"uuid,omitempty"`
	SecretType string    `json:"secret_type"`
	Password   string    `json:"password"`
	Username   string    `json:"username"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

ServerCredential provides a way to encrypt secrets about a server in the database

type ServerCredentialType

type ServerCredentialType struct {
	Name      string    `json:"name"`
	Slug      string    `json:"slug"`
	Builtin   bool      `json:"builtin"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

ServerCredentialType represents a type of server secret. There are some built in default secret types, for example a type exists for BMC passwords.

type ServerError

type ServerError struct {
	Message      string `json:"message"`
	ErrorMessage string `json:"error"`
	StatusCode   int
}

ServerError is returned when the client receives an error back from the server

func (ServerError) Error

func (e ServerError) Error() string

Error returns the ServerError in string format

type ServerListParams

type ServerListParams struct {
	FacilityCode                 string `form:"facility-code"`
	ComponentListParams          []ServerComponentListParams
	AttributeListParams          []AttributeListParams
	IncludeDeleted               bool `form:"include-deleted"`
	VersionedAttributeListParams []AttributeListParams
	PaginationParams             *PaginationParams
}

ServerListParams allows you to filter the results. Note: You must set PaginationParams.Preload to load Components, Attributes, and VersionedAttributes

type ServerResponse

type ServerResponse struct {
	PageSize         int                 `json:"page_size,omitempty"`
	Page             int                 `json:"page,omitempty"`
	PageCount        int                 `json:"page_count,omitempty"`
	TotalPages       int                 `json:"total_pages,omitempty"`
	TotalRecordCount int64               `json:"total_record_count,omitempty"`
	Links            ServerResponseLinks `json:"_links,omitempty"`
	Message          string              `json:"message,omitempty"`
	Error            string              `json:"error,omitempty"`
	Slug             string              `json:"slug,omitempty"`
	Record           interface{}         `json:"record,omitempty"`
	Records          interface{}         `json:"records,omitempty"`
}

ServerResponse represents the data that the server will return on any given call

func (*ServerResponse) HasNextPage

func (r *ServerResponse) HasNextPage() bool

HasNextPage will return if there are additional resources to load on additional pages

type ServerResponseLinks struct {
	Self     *Link `json:"self,omitempty"`
	First    *Link `json:"first,omitempty"`
	Previous *Link `json:"previous,omitempty"`
	Next     *Link `json:"next,omitempty"`
	Last     *Link `json:"last,omitempty"`
}

ServerResponseLinks represent links that could be returned on a page

type ServerSku added in v1.19.3

type ServerSku struct {
	Name             string      `json:"name" binding:"required"`
	Version          string      `json:"version" binding:"required"`
	Vendor           string      `json:"vendor" binding:"required"`
	Chassis          string      `json:"chassis" binding:"required"`
	BMCModel         string      `json:"bmc_model" binding:"required"`
	MotherboardModel string      `json:"motherboard_model" binding:"required"`
	CPUVendor        string      `json:"cpu_vendor" binding:"required"`
	CPUModel         string      `json:"cpu_model" binding:"required"`
	CPUCores         int64       `json:"cpu_cores" binding:"required"`
	CPUHertz         int64       `json:"cpu_hertz" binding:"required"`
	CPUCount         int64       `json:"cpu_count" binding:"required"`
	AuxDevices       []AuxDevice `json:"aux_devices" binding:"required"`
	Disks            []Disk      `json:"disks" binding:"required"`
	Memory           []Memory    `json:"memory" binding:"required"`
	Nics             []Nic       `json:"nics" binding:"required"`
}

ServerSku represents a SKU for a Server

type ServerSkuListParams added in v1.19.3

type ServerSkuListParams struct {
	Params     []ServerSkuQueryParams `query:"params"`
	Pagination PaginationParams       `query:"page"`
}

ServerSkuListParams params is an array of potential expressions when querying. Each one will have a Sku. This Sku will define values you want to search on, empty strings will be ignored, empty arrays will be ignored. The ComparitorOperator will define how you want to compare those values. All values within a single ServerSkuQueryParams item will be grouped together and "AND"'ed. The LogicalOperator will define how that ServerSkuQueryParams item will be grouped with other ServerSkuQueryParams items. Note: You must set PaginationParams.Preload to load AuxDevices, Disks, Memory, and Nics.

type ServerSkuQuery added in v1.19.3

type ServerSkuQuery struct {
	Name             string           `query:"name"`
	Version          string           `query:"version"`
	Vendor           string           `query:"vendor"`
	Chassis          string           `query:"chassis"`
	BMCModel         string           `query:"bmc_model"`
	MotherboardModel string           `query:"motherboard_model"`
	CPUVendor        string           `query:"cpu_vendor"`
	CPUModel         string           `query:"cpu_model"`
	CPUCores         []int64          `query:"cpu_cores"`
	CPUHertz         []int64          `query:"cpu_hertz"`
	CPUCount         []int64          `query:"cpu_count"`
	AuxDevices       []AuxDeviceQuery `query:"aux_devices"`
	Disks            []DiskQuery      `query:"disks"`
	Memory           []MemoryQuery    `query:"memory"`
	Nics             []NicQuery       `query:"nics"`
}

ServerSkuQuery defines values you can query ServerSkus with. Empty strings are ignored. Empty Arrays are ignored.

type ServerSkuQueryParams added in v1.19.3

type ServerSkuQueryParams struct {
	Sku                ServerSkuQuery         `query:"sku"`
	LogicalOperator    OperatorLogicalType    `query:"logical"`
	ComparitorOperator OperatorComparitorType `query:"comparitor"`
}

ServerSkuQueryParams defines a ServerSkuQuery struct and operators you can use to query ServerSkus with. If LogicalOperator is an empty string, it will default to OperatorLogicalAND. If ComparitorOperator is an empty string, it will default to OperatorComparitorEqual

type VersionedAttributes

type VersionedAttributes struct {
	Namespace      string          `json:"namespace" binding:"required"`
	Data           json.RawMessage `json:"data" binding:"required"`
	Tally          int             `json:"tally"`
	LastReportedAt time.Time       `json:"last_reported_at"`
	CreatedAt      time.Time       `json:"created_at"`
}

VersionedAttributes represents a set of attributes of an entity at a given time

Jump to

Keyboard shortcuts

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