conch

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package conch provides access to the Conch API

Index

Constants

View Source
const (
	ValidationReportStatusFail = 0
	ValidationReportStatusOK   = 1
)

ValidationReport vars provide an abstraction to make sense of the 'status' field in ValidationReports

View Source
const (
	// MinimumAPIVersion sets the earliest API version that we support.
	MinimumAPIVersion = "2.6.0"
)

Variables

View Source
var (
	// ErrLoginFailed indicates that the login process failed for unspecified
	// reasons
	ErrLoginFailed = errors.New("Login Failed")

	// ErrNoSessionData indicates that an auth related error occurred where
	// either the user did not provide session data or no data was returned
	// from the API
	ErrNoSessionData = errors.New("No Session Data Provided")

	// ErrHTTPNotOk indicates that the API returned a non-200 status code that
	// we don't know how to handle
	ErrHTTPNotOk = errors.New("Non-200 HTTP status code returned")

	// ErrDataNotFound inidicates that the API returned a status code
	// inidicating that the requested data does not exist or is not available.
	// NOTE: The API will also return this error if the user is not allowed to
	// access the data in question.
	ErrDataNotFound = errors.New("API could not find the data requested")

	// ErrBadInput indicates that the user passed incomplete or bad data to a
	// routine. This typicallly only occurs when a struct parameter isn't
	// filled out with enough data.
	ErrBadInput = errors.New("Incomplete data passed to the routine")

	// ErrSemVerParse indicates that a semantic version string could not be
	// parsed
	ErrSemVerParse = errors.New("Could not parse semantic version string")

	// ErrNotSupported indicates that the API server does not support this
	// command. This is typically determined via checks on conch.apiVersion
	ErrNotSupported = errors.New("This function is not supported")

	// ErrNotAuthorized indicates that the API server returned a 401
	ErrNotAuthorized = errors.New("Not authorized for this endpoint")

	// ErrForbidden indicates that the API server returned a 403
	ErrForbidden = errors.New("Access to this endpoint is forbidden")

	// ErrMustChangePassword is used to signal that the user must change their
	// password before proceeding. Typically, the existing auth credentials
	// will continue to work for a few minutes.
	ErrMustChangePassword = errors.New("Password must be changed")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	ErrorMsg string `json:"error"`
}

APIError matches the structure of request errors reported by the Conch API

func (*APIError) Error

func (ai *APIError) Error() error

Return a new error with Conch Error message as the text

type Conch

type Conch struct {
	Session string // DEPRECATED
	BaseURL string
	UA      string
	JWToken string
	Expires int // This will be overwritten by JWT claims

	HTTPClient *http.Client
	CookieJar  *cookiejar.Jar
	// contains filtered or unexported fields
}

Conch contains auth and configuration data

func (*Conch) AddRackToWorkspace

func (c *Conch) AddRackToWorkspace(workspaceUUID fmt.Stringer, rackUUID fmt.Stringer) error

AddRackToWorkspace adds an existing rack to an existing workspace, via /workspace/:uuid/rack

func (*Conch) AddUserToWorkspace added in v1.7.0

func (c *Conch) AddUserToWorkspace(workspaceUUID fmt.Stringer, user string, role string) error

AddUserToWorkspace adds a user to a workspace via /workspace/:uuid/user

func (*Conch) AddValidationToPlan

func (c *Conch) AddValidationToPlan(validationPlanUUID fmt.Stringer, validationUUID fmt.Stringer) error

AddValidationToPlan associates a validation with a validation plan

func (*Conch) ChangePassword added in v1.4.0

func (c *Conch) ChangePassword(password string) error

ChangePassword changes the password for the currently active profile

func (*Conch) CreateSubWorkspace

func (c *Conch) CreateSubWorkspace(parent Workspace, sub Workspace) (Workspace, error)

CreateSubWorkspace creates a sub workspace under the parent, via /workspace/:uuid/child If the provided parent lacks an ID, ErrBadInput is returned Currently, if an attempt to create a workspace with a conflicting name happens, the API returns a 500 rather than something useful. The routine will return ErrHTTPNotOk in that case.

func (*Conch) CreateUser added in v1.4.0

func (c *Conch) CreateUser(email string, password string, name string) error

CreateUser creates a new user. They are *not* added to a workspace. The 'name' argument is optional and will be omitted if set to "" The 'password' argument is optional and will be omitted if set to ""

func (*Conch) CreateValidationPlan

func (c *Conch) CreateValidationPlan(newValidationPlan ValidationPlan) (ValidationPlan, error)

CreateValidationPlan creates a new validation plan in Conch

func (*Conch) DeleteDBHardwareProduct added in v1.3.0

func (c *Conch) DeleteDBHardwareProduct(hwUUID fmt.Stringer) error

DeleteDBHardwareProduct deletes a hardware product by marking it as deactivated

func (*Conch) DeleteDeviceSetting added in v1.4.0

func (c *Conch) DeleteDeviceSetting(deviceID string, key string) error

DeleteDeviceSetting deletes a single setting for a device via /device/:deviceID/settings/:key Settings that begin with "tag." cannot be processed by this routine and will always return ErrDataNotFound

func (*Conch) DeleteDeviceTag added in v1.4.0

func (c *Conch) DeleteDeviceTag(deviceID string, key string) error

DeleteDeviceTag deletes a single tag for a device via /device/:deviceID/settings/:key Settings that do NOT begin with "tag." cannot be processed by this routine and will always return ErrDataNotFound

func (*Conch) DeleteGlobalDatacenter

func (c *Conch) DeleteGlobalDatacenter(id fmt.Stringer) error

DeleteGlobalDatacenter deletes a datacenter

func (*Conch) DeleteGlobalRack

func (c *Conch) DeleteGlobalRack(id fmt.Stringer) error

DeleteGlobalRack deletes a rack

func (*Conch) DeleteGlobalRackLayoutSlot

func (c *Conch) DeleteGlobalRackLayoutSlot(id fmt.Stringer) error

DeleteGlobalRackLayoutSlot deletes a rack layout

func (*Conch) DeleteGlobalRackRole

func (c *Conch) DeleteGlobalRackRole(id fmt.Stringer) error

DeleteGlobalRackRole deletes a rack role

func (*Conch) DeleteGlobalRoom

func (c *Conch) DeleteGlobalRoom(id fmt.Stringer) error

DeleteGlobalRoom deletes a room

func (*Conch) DeleteHardwareVendor added in v1.5.0

func (c *Conch) DeleteHardwareVendor(name string) error

DeleteHardwareVendor ...

func (*Conch) DeleteRackFromWorkspace

func (c *Conch) DeleteRackFromWorkspace(workspaceUUID fmt.Stringer, rackUUID fmt.Stringer) error

DeleteRackFromWorkspace removes an existing rack from an existing workplace, via /workspace/:uuid/rack/:uuid

func (*Conch) DeleteUser added in v1.4.0

func (c *Conch) DeleteUser(emailAddress string, clearTokens bool) error

DeleteUser deletes a user and, optionally, clears their JWT credentials

func (*Conch) DeleteUserSetting

func (c *Conch) DeleteUserSetting(name string) error

DeleteUserSetting deletes a user setting via /user/me/settings/:name

func (*Conch) DeviceTritonReboot

func (c *Conch) DeviceTritonReboot(serial string) error

DeviceTritonReboot sets the 'triton_reboot' field for the given device, via /device/:serial/triton_reboot WARNING: This is a one way operation and cannot currently be undone via the API

func (*Conch) DeviceValidationStates

func (c *Conch) DeviceValidationStates(deviceSerial string) ([]ValidationState, error)

DeviceValidationStates returns the stored validation states for a device

func (*Conch) FillInDevice

func (c *Conch) FillInDevice(d Device) (Device, error)

FillInDevice takes an existing device and fills in its data using "/device"

This exists because the API hands back partial devices in most cases. It's likely, though, that any client utility will eventually want all the data about a device and not just bits

func (*Conch) GetAllRelays

func (c *Conch) GetAllRelays() ([]Relay, error)

GetAllRelays uses the /relay endpoint to get a list of all relays devices known in the system. This endpoint is only supported in API versions >=2.1.0 and will return ErrNotSupported if the API version is not compliant. This endpoint is also limited to Administrators on the GLOBAL workspace. If permissions are not met, ErrNotAuthorized will be returned

func (*Conch) GetAllRelaysWithoutDevices

func (c *Conch) GetAllRelaysWithoutDevices() ([]Relay, error)

GetAllRelaysWithoutDevices uses the /relay endpoint to get a list of all relays, but without their assigned devices.

func (*Conch) GetAllUsers added in v1.7.0

func (c *Conch) GetAllUsers() ([]UserDetailed, error)

GetAllUsers retrieves a list of all users, if the user has the right permissions, in the system. Returns UserDetailed structs

func (*Conch) GetDBHardwareProduct added in v1.3.0

func (c *Conch) GetDBHardwareProduct(hardwareProductUUID fmt.Stringer) (DBHardwareProduct, error)

GetDBHardwareProduct fetches a single new-style hardware product

func (*Conch) GetDBHardwareProducts added in v1.3.0

func (c *Conch) GetDBHardwareProducts() ([]DBHardwareProduct, error)

GetDBHardwareProducts fetches all new-style hardware products

func (*Conch) GetDevice

func (c *Conch) GetDevice(serial string) (Device, error)

GetDevice returns a Device given a specific serial/id

func (*Conch) GetDeviceIPMI added in v1.5.0

func (c *Conch) GetDeviceIPMI(serial string) (string, error)

GetDeviceIPMI retrieves "/device/:serial/interface/impi1/ipaddr"

func (*Conch) GetDeviceLocation

func (c *Conch) GetDeviceLocation(serial string) (DeviceLocation, error)

GetDeviceLocation fetches the location for a device, via /device/:serial/location

func (*Conch) GetDeviceSetting

func (c *Conch) GetDeviceSetting(serial string, key string) (string, error)

GetDeviceSetting fetches a single setting for a device, via /device/:serial/settings/:key Device settings that begin with 'tag.' are filtered out.

func (*Conch) GetDeviceSettings

func (c *Conch) GetDeviceSettings(serial string) (map[string]string, error)

GetDeviceSettings fetches settings for a device, via /device/:serial/settings Device settings that begin with 'tag.' are filtered out.

func (*Conch) GetDeviceTag added in v1.4.0

func (c *Conch) GetDeviceTag(serial string, key string) (string, error)

GetDeviceTag fetches a single tag for a device, via /device/:serial/settings/:key The key must either begin with 'tag.' or it will be prepended

func (*Conch) GetDeviceTags added in v1.4.0

func (c *Conch) GetDeviceTags(serial string) (map[string]string, error)

GetDeviceTags fetches tags for a device, via /device/:serial/settings Device settings that do NOT begin with 'tag.' are filtered out.

func (*Conch) GetGlobalDatacenter

func (c *Conch) GetGlobalDatacenter(id fmt.Stringer) (GlobalDatacenter, error)

GetGlobalDatacenter fetches a single datacenter in the global domain, by its UUID

func (*Conch) GetGlobalDatacenterRooms

func (c *Conch) GetGlobalDatacenterRooms(d GlobalDatacenter) ([]GlobalRoom, error)

GetGlobalDatacenterRooms gets the global rooms assigned to a global datacenter

func (*Conch) GetGlobalDatacenters

func (c *Conch) GetGlobalDatacenters() ([]GlobalDatacenter, error)

GetGlobalDatacenters fetches a list of all datacenters in the global domain

func (*Conch) GetGlobalRack

func (c *Conch) GetGlobalRack(id fmt.Stringer) (GlobalRack, error)

GetGlobalRack fetches a single rack in the global domain, by its UUID

func (*Conch) GetGlobalRackLayout

func (c *Conch) GetGlobalRackLayout(r GlobalRack) ([]GlobalRackLayoutSlot, error)

GetGlobalRackLayout fetches the layout entries for a rack in the global domain

func (*Conch) GetGlobalRackLayoutSlot

func (c *Conch) GetGlobalRackLayoutSlot(id fmt.Stringer) (*GlobalRackLayoutSlot, error)

GetGlobalRackLayoutSlot fetches a single rack layout in the global domain, by its UUID

func (*Conch) GetGlobalRackLayoutSlots

func (c *Conch) GetGlobalRackLayoutSlots() ([]GlobalRackLayoutSlot, error)

GetGlobalRackLayoutSlots fetches a list of all rack layouts in the global domain

func (*Conch) GetGlobalRackRole

func (c *Conch) GetGlobalRackRole(id fmt.Stringer) (*GlobalRackRole, error)

GetGlobalRackRole fetches a single rack role in the global domain, by its UUID

func (*Conch) GetGlobalRackRoles

func (c *Conch) GetGlobalRackRoles() ([]GlobalRackRole, error)

GetGlobalRackRoles fetches a list of all rack roles in the global domain

func (*Conch) GetGlobalRacks

func (c *Conch) GetGlobalRacks() ([]GlobalRack, error)

GetGlobalRacks fetches a list of all racks in the global domain

func (*Conch) GetGlobalRoom

func (c *Conch) GetGlobalRoom(id fmt.Stringer) (GlobalRoom, error)

GetGlobalRoom fetches a single room in the global domain, by its UUID

func (*Conch) GetGlobalRoomRacks

func (c *Conch) GetGlobalRoomRacks(r GlobalRoom) ([]GlobalRack, error)

GetGlobalRoomRacks retrieves the racks assigned to a room in the global domain

func (*Conch) GetGlobalRooms

func (c *Conch) GetGlobalRooms() ([]GlobalRoom, error)

GetGlobalRooms fetches a list of all rooms in the global domain

func (*Conch) GetHardwareProduct

func (c *Conch) GetHardwareProduct(hardwareProductUUID fmt.Stringer) (HardwareProduct, error)

GetHardwareProduct fetches a single hardware product via /hardware/product/:uuid

func (*Conch) GetHardwareProducts

func (c *Conch) GetHardwareProducts() ([]HardwareProduct, error)

GetHardwareProducts fetches a single hardware product via /hardware_product

func (*Conch) GetHardwareVendor added in v1.5.0

func (c *Conch) GetHardwareVendor(name string) (HardwareVendor, error)

GetHardwareVendor ...

func (*Conch) GetHardwareVendors added in v1.5.0

func (c *Conch) GetHardwareVendors() ([]HardwareVendor, error)

GetHardwareVendors ...

func (*Conch) GetSubWorkspaces

func (c *Conch) GetSubWorkspaces(workspaceUUID fmt.Stringer) ([]Workspace, error)

GetSubWorkspaces returns the contents of /workspace/:uuid/child, getting a list of subworkspaces for the given workspace id

func (*Conch) GetUserSetting

func (c *Conch) GetUserSetting(key string) (interface{}, error)

GetUserSetting returns the results of /user/me/settings/:key The return is an interface{} because the database structure is a string name and a jsonb data field. There is no way for this library to know in advanace what's in that data so here there be dragons.

func (*Conch) GetUserSettings

func (c *Conch) GetUserSettings() (map[string]interface{}, error)

GetUserSettings returns the results of /user/me/settings The return is a map[string]interface{} because the database structure is a string name and a jsonb data field. There is no way for this library to know in advanace what's in that data so here there be dragons.

func (*Conch) GetValidationPlan

func (c *Conch) GetValidationPlan(validationPlanUUID fmt.Stringer) (*ValidationPlan, error)

GetValidationPlan returns the contents of /validation_plan/:uuid, getting information about a single validation plan

func (*Conch) GetValidationPlanValidations

func (c *Conch) GetValidationPlanValidations(validationPlanUUID fmt.Stringer) ([]Validation, error)

GetValidationPlanValidations gets the list of validations associated with a validation plan

func (*Conch) GetValidationPlans

func (c *Conch) GetValidationPlans() ([]ValidationPlan, error)

GetValidationPlans returns the contents of /validation_plan, getting the list of all validations plans loaded in the system

func (*Conch) GetValidations

func (c *Conch) GetValidations() ([]Validation, error)

GetValidations returns the contents of /validation, getting the list of all validations loaded in the system

func (*Conch) GetWorkspace

func (c *Conch) GetWorkspace(workspaceUUID fmt.Stringer) (*Workspace, error)

GetWorkspace returns the contents of /workspace/:uuid, getting information about a single workspace

func (*Conch) GetWorkspaceDevices

func (c *Conch) GetWorkspaceDevices(workspaceUUID fmt.Stringer, idsOnly bool, graduated string, health string) ([]Device, error)

GetWorkspaceDevices retrieves a list of Devices for the given workspace. Pass true for 'IDsOnly' to get Devices with only the ID field populated Pass a string for 'graduated' to filter devices by graduated value, as per https://conch.joyent.us/doc#getdevices Pass a string for 'health' to filter devices by health value, as per https://conch.joyent.us/doc#getdevices

func (*Conch) GetWorkspaceRack

func (c *Conch) GetWorkspaceRack(workspaceUUID fmt.Stringer, rackUUID fmt.Stringer) (Rack, error)

GetWorkspaceRack fetches a single rack for a workspace, via /workspace/:uuid/rack/:id

func (*Conch) GetWorkspaceRacks

func (c *Conch) GetWorkspaceRacks(workspaceUUID fmt.Stringer) ([]Rack, error)

GetWorkspaceRacks fetchest the list of racks for a workspace, via /workspace/:uuid/rack

NOTE: The API currently returns a hash of arrays where the key is the datacenter/az. This routine copies that key into the Datacenter field in the Rack struct.

func (*Conch) GetWorkspaceRelays

func (c *Conch) GetWorkspaceRelays(workspaceUUID fmt.Stringer, activeOnly bool) ([]Relay, error)

GetWorkspaceRelays returns all Relays associated with the given workspace

func (*Conch) GetWorkspaceRooms

func (c *Conch) GetWorkspaceRooms(workspaceUUID fmt.Stringer) ([]Room, error)

GetWorkspaceRooms returns the contents of /workspace/:uuid/room, getting a list of rooms for the given workspace id

func (*Conch) GetWorkspaceUsers

func (c *Conch) GetWorkspaceUsers(workspaceUUID fmt.Stringer) ([]WorkspaceUser, error)

GetWorkspaceUsers returns the contents of /workspace/:uuid/users, getting a list of users for the given workspace id

func (*Conch) GetWorkspaces

func (c *Conch) GetWorkspaces() ([]Workspace, error)

GetWorkspaces returns the contents of /workspace, getting the list of all workspaces that the user has access to

func (*Conch) GraduateDevice

func (c *Conch) GraduateDevice(serial string) error

GraduateDevice sets the 'graduated' field for the given device, via /device/:serial/graduate WARNING: This is a one way operation and cannot currently be undone via the API

func (*Conch) Login

func (c *Conch) Login(user string, password string) error

Login uses the User, as listed in the Conch struct, and the provided password to log into the Conch API and populate the Session entry in the Conch struct

func (*Conch) MarkDeviceTritonSetup

func (c *Conch) MarkDeviceTritonSetup(serial string) error

MarkDeviceTritonSetup marks the device as setup for Triton For this action to succeed, the device must have its Triton UUID set and marked as rebooted into Triton. If these conditions are not met, this function will return ErrBadInput

func (*Conch) RawDelete

func (c *Conch) RawDelete(url string) (*http.Response, error)

RawDelete allows the user to perform an HTTP DELETE against the API, with the library handling all auth but *not* processing the response.

func (*Conch) RawGet

func (c *Conch) RawGet(url string) (*http.Response, error)

RawGet allows the user to perform an HTTP GET against the API, with the library handling all auth but *not* processing the response.

func (*Conch) RawPost

func (c *Conch) RawPost(url string, body io.Reader) (*http.Response, error)

RawPost allows the user to perform an HTTP POST against the API, with the library handling all auth but *not* processing the response. The provided body *must* be JSON for the server to accept it.

func (*Conch) RegisterRelay

func (c *Conch) RegisterRelay(r Relay) error

RegisterRelay registers/updates a Relay via /relay/:serial/register If the provided relay does not have an IP, SSHPort, and Version, ErrBadInput will be returned

func (*Conch) RemoveUserFromWorkspace added in v1.7.0

func (c *Conch) RemoveUserFromWorkspace(workspaceUUID fmt.Stringer, email string) error

RemoveUserFromWorkspace ...

func (*Conch) RemoveValidationFromPlan

func (c *Conch) RemoveValidationFromPlan(validationPlanUUID fmt.Stringer, validationUUID fmt.Stringer) error

RemoveValidationFromPlan removes a validation from a validation plan

func (*Conch) ResetUserPassword added in v1.4.0

func (c *Conch) ResetUserPassword(email string) error

ResetUserPassword resets the password for the provided user, causing an email to be sent

func (*Conch) RevokeOwnTokens

func (c *Conch) RevokeOwnTokens() error

RevokeOwnTokens revokes all auth tokens for the current user. Login() is required after to generate new tokens. Clears the Session, JWToken, and Expires attributes

func (*Conch) RevokeUserTokens

func (c *Conch) RevokeUserTokens(user string) error

RevokeUserTokens revokes all auth tokens for a the given user. This action is typically limited server-side to admins.

func (*Conch) RunDeviceValidation

func (c *Conch) RunDeviceValidation(deviceSerial string, validationUUID fmt.Stringer, body io.Reader) ([]ValidationResult, error)

RunDeviceValidation runs a validation against given a device and returns the results

func (*Conch) RunDeviceValidationPlan

func (c *Conch) RunDeviceValidationPlan(deviceSerial string, validationPlanUUID fmt.Stringer, body io.Reader) ([]ValidationResult, error)

RunDeviceValidationPlan runs a validation plan against a given device and returns the results

func (*Conch) SaveDBHardwareProduct added in v1.3.0

func (c *Conch) SaveDBHardwareProduct(h *DBHardwareProduct) error

SaveDBHardwareProduct creates or saves a new-style hardware product, based on the presence of an ID

func (*Conch) SaveGlobalDatacenter

func (c *Conch) SaveGlobalDatacenter(d *GlobalDatacenter) error

SaveGlobalDatacenter creates or updates a datacenter in the global domain, based on the presence of an ID

func (*Conch) SaveGlobalRack

func (c *Conch) SaveGlobalRack(r *GlobalRack) error

SaveGlobalRack creates or updates a rack in the global domain, based on the presence of an ID

func (*Conch) SaveGlobalRackLayoutSlot

func (c *Conch) SaveGlobalRackLayoutSlot(r *GlobalRackLayoutSlot) error

SaveGlobalRackLayoutSlot creates or updates a rack layout in the global domain, based on the presence of an ID

func (*Conch) SaveGlobalRackRole

func (c *Conch) SaveGlobalRackRole(r *GlobalRackRole) error

SaveGlobalRackRole creates or updates a rack role in the global domain, based on the presence of an ID

func (*Conch) SaveGlobalRoom

func (c *Conch) SaveGlobalRoom(r *GlobalRoom) error

SaveGlobalRoom creates or updates a room in the global domain, based on the presence of an ID

func (*Conch) SaveHardwareVendor added in v1.5.0

func (c *Conch) SaveHardwareVendor(v *HardwareVendor) error

SaveHardwareVendor ...

func (*Conch) SetDeviceAssetTag

func (c *Conch) SetDeviceAssetTag(serial string, tag string) error

SetDeviceAssetTag sets the asset tag for the provided serial

func (*Conch) SetDeviceSetting added in v1.4.0

func (c *Conch) SetDeviceSetting(deviceID string, key string, value string) error

SetDeviceSetting sets a single setting for a device via /device/:deviceID/settings/:key Settings that begin with "tag." cannot be processed by this routine and will always return ErrDataNotFound

func (*Conch) SetDeviceTag added in v1.4.0

func (c *Conch) SetDeviceTag(deviceID string, key string, value string) error

SetDeviceTag sets a single tag for a device via /device/:deviceID/settings/:key The key must either begin with 'tag.' or it will be prepended

func (*Conch) SetDeviceTritonUUID

func (c *Conch) SetDeviceTritonUUID(serial string, id uuid.UUID) error

SetDeviceTritonUUID sets the triton UUID via /device/:serial/triton_uuid

func (*Conch) SetUserSetting

func (c *Conch) SetUserSetting(name string, value interface{}) error

SetUserSetting sets the value of a user setting via /user/me/settings/:name

func (*Conch) SetUserSettings

func (c *Conch) SetUserSettings(settings map[string]interface{}) error

SetUserSettings sets the value of *all* user settings via /user/me/settings

func (*Conch) VerifyLogin

func (c *Conch) VerifyLogin(refreshTime int, forceJWT bool) error

VerifyLogin determines if the user's session data is still valid. If available, it uses the refresh API, falling back to plain cookie auth.

One can pass in an integer value, representing when to force a token refresh, based on the number of seconds left until expiry. Pass in 0 to prevent refreshing

If the second parameter is true, a JWT refresh is forced, regardless of any other parameters.

NOTE: If the Conch struct contains cookie session data, it will be automatically upgraded to JWT and the Session data will no longer function

func (*Conch) WorkspaceValidationStates

func (c *Conch) WorkspaceValidationStates(workspaceUUID fmt.Stringer) ([]ValidationState, error)

WorkspaceValidationStates returns the stored validation states for all devices in a workspace

type DBHardwareProduct added in v1.3.0

type DBHardwareProduct struct {
	ID                uuid.UUID `json:"id,omitempty"`
	Name              string    `json:"name"`
	Alias             string    `json:"alias"`
	Prefix            string    `json:"prefix"`
	Vendor            uuid.UUID `json:"vendor"`
	Specification     string    `json:"specification,omitempty"`
	SKU               string    `json:"sku,omitempty"`
	GenerationName    string    `json:"generation_name,omitempty"`
	LegacyProductName string    `json:"legacy_product_name,omitempty"`
}

DBHardwareProduct represents the specification for a specific piece of hardware

type Datacenter

type Datacenter struct {
	ID         uuid.UUID `json:"id"`
	Name       string    `json:"name"`
	VendorName string    `json:"vendor_name"`
}

Datacenter represents a conch datacenter, aka an AZ

type Device

type Device struct {
	AssetTag        string             `json:"asset_tag"`
	BootPhase       string             `json:"boot_phase"`
	Created         pgtime.PgTime      `json:"created"`
	Deactivated     pgtime.PgTime      `json:"deactivated"`
	Graduated       pgtime.PgTime      `json:"graduated"`
	HardwareProduct uuid.UUID          `json:"hardware_product"`
	Health          string             `json:"health"`
	ID              string             `json:"id"`
	LastSeen        pgtime.PgTime      `json:"last_seen"`
	Location        DeviceLocation     `json:"location"`
	Nics            []Nic              `json:"nics"`
	State           string             `json:"state"`
	SystemUUID      uuid.UUID          `json:"system_uuid"`
	TritonUUID      uuid.UUID          `json:"triton_uuid"`
	TritonSetup     pgtime.PgTime      `json:"triton_setup"`
	Updated         pgtime.PgTime      `json:"updated"`
	UptimeSince     pgtime.PgTime      `json:"uptime_since"`
	Validated       pgtime.PgTime      `json:"validated"`
	Validations     []ValidationReport `json:"validations"`
	LatestReport    interface{}        `json:"latest_report"`
}

Device represents what the API docs call a "DetailedDevice"

Instead of having multiple structs representing partial datasets, like the API chooses to do, this library will always hand back Devices. In the case that the API does not provide all the data, those fields will be null or zero values.

type DeviceLocation

type DeviceLocation struct {
	Datacenter            Datacenter            `json:"datacenter"`
	Rack                  Rack                  `json:"rack"`
	TargetHardwareProduct HardwareProductTarget `json:"target_hardware_product"`
}

DeviceLocation represents the location of a device, including its datacenter and rack

type GlobalDatacenter

type GlobalDatacenter struct {
	ID         uuid.UUID `json:"id"`
	Vendor     string    `json:"vendor"`
	VendorName string    `json:"vendor_name"`
	Region     string    `json:"region"`
	Location   string    `json:"location"`
	Created    time.Time `json:"created"`
	Updated    time.Time `json:"updated"`
}

GlobalDatacenter represents a datacenter in the global domain

type GlobalRack

type GlobalRack struct {
	ID               uuid.UUID `json:"id"`
	Created          time.Time `json:"created"`
	Updated          time.Time `json:"updated"`
	DatacenterRoomID uuid.UUID `json:"datacenter_room_id"`
	Name             string    `json:"name"`
	RoleID           uuid.UUID `json:"role"`
	SerialNumber     string    `json:"serial_number"`
	AssetTag         string    `json:"asset_tag"`
}

GlobalRack represents a datacenter rack in the global domain

type GlobalRackLayoutSlot

type GlobalRackLayoutSlot struct {
	ID        uuid.UUID `json:"id"`
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
	RackID    uuid.UUID `json:"rack_id"`
	ProductID uuid.UUID `json:"product_id"`
	RUStart   int       `json:"ru_start"`
}

GlobalRackLayoutSlot represents an individual rack layout entry

type GlobalRackRole

type GlobalRackRole struct {
	ID       uuid.UUID `json:"id"`
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
	Name     string    `json:"name"`
	RackSize int       `json:"rack_size"`
}

GlobalRackRole represents a rack role in the global domain

type GlobalRoom

type GlobalRoom struct {
	ID           uuid.UUID `json:"id"`
	Created      time.Time `json:"created"`
	Updated      time.Time `json:"updated"`
	DatacenterID uuid.UUID `json:"datacenter"`
	AZ           string    `json:"az"`
	Alias        string    `json:"alias"`
	VendorName   string    `json:"vendor_name"`
}

GlobalRoom represents a datacenter room in the global domain

type HardwareProduct

type HardwareProduct struct {
	ID                uuid.UUID       `json:"id"`
	Name              string          `json:"name"`
	Alias             string          `json:"alias"`
	Prefix            string          `json:"prefix"`
	Profile           HardwareProfile `json:"profile"`
	Vendor            string          `json:"vendor"`
	Specification     interface{}     `json:"specification"`
	SKU               string          `json:"sku"`
	GenerationName    string          `json:"generation_name"`
	LegacyProductName string          `json:"legacy_product_name"`
}

HardwareProduct is a type of Device. For instance, "Hallasan C"

type HardwareProductTarget

type HardwareProductTarget struct {
	ID    uuid.UUID `json:"id"`
	Name  string    `json:"name"`
	Alias string    `json:"alias"`
}

HardwareProductTarget represents the HardwareProduct that a device should have based on its location

type HardwareProfile

type HardwareProfile struct {
	ID           uuid.UUID            `json:"id"`
	NumNics      int                  `json:"nics_num"`
	BiosFirmware string               `json:"bios_firmware"`
	NumCPU       int                  `json:"cpu_num"`
	CPUType      string               `json:"cpu_type"`
	NumDimms     int                  `json:"dimms_num"`
	TotalPSU     int                  `json:"psu_total"`
	Purpose      string               `json:"purpose"`
	TotalRAM     int                  `json:"ram_total"`
	SASNum       int                  `json:"sas_num"`
	SizeSAS      int                  `json:"sas_size"`
	SlotsSAS     string               `json:"saas_slots"`
	NumSATA      int                  `json:"sata_num"`
	SizeSATA     int                  `json:"sata_size"`
	SlotsSATA    string               `json:"sata_slots"`
	NumSSD       int                  `json:"ssd_num"`
	SizeSSD      int                  `json:"ssd_size"`
	SlotsSSD     string               `json:"ssd_slots"`
	NumUSB       int                  `json:"usb_num"`
	Zpool        HardwareProfileZpool `json:"zpool"`
}

HardwareProfile is a detailed accounting of either the actual hardware or intended hardware configuration of a Device, depending on the API endpoint in question

type HardwareProfileZpool

type HardwareProfileZpool struct {
	ID       uuid.UUID `json:"id"`
	Cache    int       `json:"cache"`
	Log      int       `json:"log"`
	DisksPer int       `json:"disks_per"`
	Spare    int       `json:"spare"`
	VdevN    int       `json:"vdev_n"`
	VdevT    string    `json:"vdev_t"`
}

HardwareProfileZpool represents the layout of the target device's ZFS zpools

type HardwareVendor added in v1.5.0

type HardwareVendor struct {
	ID      uuid.UUID     `json:"id"`
	Name    string        `json:"name"`
	Created pgtime.PgTime `json:"created"`
	Updated pgtime.PgTime `json:"updated"`
}

HardwareVendor ...

type Nic

type Nic struct {
	MAC         string `json:"mac"`
	IfaceName   string `json:"iface_name"`
	IfaceVendor string `json:"iface_vendor"`
	IfaceType   string `json:"iface_type"`
	PeerMac     string `json:"peer_mac"`
	PeerPort    string `json:"peer_port"`
	PeerSwitch  string `json:"peer_switch"`
}

Nic is a network interface card, including its peer switch info

type Rack

type Rack struct {
	ID           uuid.UUID  `json:"id"`
	Name         string     `json:"name"`
	Role         string     `json:"role"`
	Unit         int        `json:"unit"` // BUG(sungo): This exists because device locations provide rack info, but also slot info. This is a sloppy combination of data streams
	Size         int        `json:"size"`
	Datacenter   string     `json:"datacenter"`
	Slots        []RackSlot `json:"slots,omitempty"`
	SerialNumber string     `json:"serial_number"`
	AssetTag     string     `json:"asset_tag"`
}

Rack represents a physical rack

type RackSlot

type RackSlot struct {
	ID            uuid.UUID `json:"id"`
	Size          int       `json:"size"`
	Name          string    `json:"name"`
	Alias         string    `json:"alias"`
	Vendor        string    `json:"vendor"`
	Occupant      Device    `json:"occupant"`
	RackUnitStart int       `json:"rack_unit_start"`
}

RackSlot represents a physical slot in a physical Rack

type Relay

type Relay struct {
	Alias   string    `json:"alias"`
	Created time.Time `json:"created"`
	Devices []Device  `json:"devices"`
	ID      string    `json:"id"`
	IPAddr  string    `json:"ipaddr"`
	SSHPort int       `json:"ssh_port"`
	Updated time.Time `json:"updated"`
	Version string    `json:"version"`
}

Relay represents a Conch Relay unit, a physical piece of hardware that mediates Livesys interactions in the field

type Room

type Room struct {
	ID         string `json:"id"`
	AZ         string `json:"az"`
	Alias      string `json:"alias"`
	VendorName string `json:"vendor_name"`
}

Room represents a physical area in a datacenter/AZ

type User

type User struct {
	ID      string    `json:"id,omitempty"`
	Email   string    `json:"email"`
	Name    string    `json:"name"`
	Role    string    `json:"role"`
	RoleVia uuid.UUID `json:"role_via,omitempty"`
}

User represents a person able to access the Conch API or UI

type UserDetailed added in v1.7.0

type UserDetailed struct {
	ID                  uuid.UUID          `json:"id"`
	Name                string             `json:"name"`
	Email               string             `json:"email"`
	Created             pgtime.PgTime      `json:"created"`
	LastLogin           pgtime.PgTime      `json:"last_login"`
	RefuseSessionAuth   bool               `json:"refuse_session_auth"`
	ForcePasswordChange bool               `json:"force_password_change"`
	Workspaces          []WorkspaceAndRole `json:"workspaces,omitempty"`
	IsAdmin             bool               `json:"is_admin"`
}

UserDetailed ...

type Validation

type Validation struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Version     int       `json:"version"`
	Description string    `json:"description"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Validation represents device validations loaded into Conch

type ValidationPlan

type ValidationPlan struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Created     time.Time `json:"created"`
}

ValidationPlan represents an organized association of Validations

type ValidationReport

type ValidationReport struct {
	ComponentID   uuid.UUID   `json:"component_id"`
	ComponentName string      `json:"component_name"`
	ComponentType string      `json:"component_type"`
	CriteriaID    uuid.UUID   `json:"criteria_id"`
	Log           string      `json:"log"`
	Metric        interface{} `json:"metric"`
	Status        int         `json:"status"` // Can use the ValidationReportStatus consts to understand status
}

ValidationReport represents the result from the validation engine, comparing field data to expectations.

type ValidationResult

type ValidationResult struct {
	ID              uuid.UUID `json:"id"`
	Category        string    `json:"category"`
	ComponentID     string    `json:"component_id"`
	DeviceID        string    `json:"device_id"`
	HardwareProduct uuid.UUID `json:"hardware_product_id"`
	Hint            string    `json:"hint"`
	Message         string    `json:"message"`
	Status          string    `json:"status"`
	ValidationID    uuid.UUID `json:"validation_id"`
}

ValidationResult is a result of running a validation on a device

type ValidationState

type ValidationState struct {
	ID               uuid.UUID          `json:"id"`
	Created          time.Time          `json:"created"`
	Completed        time.Time          `json:"completed"`
	DeviceID         string             `json:"device_id"`
	Results          []ValidationResult `json:"results"`
	Status           string             `json:"status"`
	ValidationPlanID uuid.UUID          `json:"validation_plan_id"`
}

ValidationState is the result of running a validation plan on a device

type Workspace

type Workspace struct {
	ID          uuid.UUID `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	Role        string    `json:"role"`
	ParentID    uuid.UUID `json:"parent_id,omitempty"`
}

Workspace represents a Conch data partition which allows users to create custom lists of hardware

type WorkspaceAndRole added in v1.7.0

type WorkspaceAndRole struct {
	Workspace
	RoleVia uuid.UUID `json:"role_via"`
}

WorkspaceAndRole ...

type WorkspaceUser added in v1.7.0

type WorkspaceUser struct {
	User
	RoleVia uuid.UUID `json:"role_via,omitempty"`
}

WorkspaceUser ...

Notes

Bugs

  • This exists because device locations provide rack info, but also slot info. This is a sloppy combination of data streams

Jump to

Keyboard shortcuts

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