fleetdbapi

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 34 Imported by: 8

Documentation

Overview

Package fleetdbapi provides the v1 api for the fleetdb service

Index

Constants

View Source
const (
	// OperatorEqual means the value has to match the keys exactly
	OperatorEqual OperatorType = "eq"
	// OperatorLike 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
	OperatorLike = "like"
	// OperatorGreaterThan will convert the value at the given key to an int and return results that are greater than Value
	OperatorGreaterThan = "gt"
	// OperatorLessThan will convert the value at the given key to an int and return results that are less than Value
	OperatorLessThan = "lt"
)
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")
)
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
)

Functions

func NewCreateServerMessage

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

NewCreateServerMessage composes a CreateServer message for NATS

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  OperatorType
	Value     string
	// AttributeOperatorType is used to define how this AttributeListParam value should be SQL queried
	// this value defaults to AttributeLogicalAND.
	AttributeOperator AttributeOperatorType
}

AttributeListParams allow you to filter the results based on attributes

type AttributeOperatorType

type AttributeOperatorType string

AttributeOperatorType is used to define how one or more AttributeListParam values should be SQL queried.

const (
	// AttributeLogicalOR can be passed into a AttributeListParam to SQL select the attribute an OR clause.
	AttributeLogicalOR AttributeOperatorType = "or"
	// AttributeLogicalAND is the default attribute operator, it can be passed into a AttributeListParam to SQL select the attribute a AND clause.
	AttributeLogicalAND AttributeOperatorType = "and"
)

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

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

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

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"`
	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"`
	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"`
	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 Doer

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

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

type Link struct {
	Href string `json:"href,omitempty"`
}

Link represents an address to a page

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 OperatorType

type OperatorType string

OperatorType is used to control what kind of search is performed for an AttributeListParams value.

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

type Router

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

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

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