Documentation
¶
Overview ¶
Package clockworks interacts with the Clockworks API service:
https://clockworks.oit.duke.edu/help/api_v1
Index ¶
- Constants
- func BindCreateVMCompletions(cmd *cobra.Command, c *Client) error
- func BindDeleteVMCobra(cmd *cobra.Command) error
- func BindEditVMCobra(cmd *cobra.Command) error
- func BindNewVMCobra(cmd *cobra.Command, _ *Client) error
- func DoRequest(ctx context.Context, req *http.Request) (*http.Response, error)
- func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func NewVMCreateOpts[T VMCreateOpts](opts ...Option[T]) *T
- func NewVMDeleteOpts[T VMDeleteOpts](opts ...Option[T]) *T
- func NewVMEditOpts[T VMEditOpts](opts ...Option[T]) *T
- func NewVMListOpts[T VMListOpts](opts ...Option[T]) *T
- func ProductionLevelCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func StorageTypeCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func SysadminOptionCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
- func ValidatePatchWindowWithSysadminOption(p int, s SysadminOption) error
- func WithEnv() func(*Client)
- func WithErrWriter(w io.Writer) func(*Client)
- func WithLogger(l *slog.Logger) func(*Client)
- func WithReqWaitTimes(ts map[string]time.Duration) func(*Client)
- func WithToken(t string) func(*Client)
- func WithURL(u string) func(*Client)
- func WithUser(u string) func(*Client)
- func WithViper(v *viper.Viper) func(*Client)
- type AllowedBackups
- type CPU
- type Client
- func (c *Client) CheckResponse(r *http.Response) error
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) GuessPrimaryNetworkWithFQDN(ctx context.Context, fqdn string) (*Network, error)
- func (c *Client) GuessPrimaryNetworkWithVMId(ctx context.Context, id int) (*Network, error)
- func (c *Client) VMCreateOptsWithCmd(cmd *cobra.Command, args []string) (*VMCreateOpts, error)
- func (c *Client) VMDeleteOptsWithCmd(cmd *cobra.Command, _ []string) (*VMDeleteOpts, error)
- func (c *Client) VMEditOptsWithCmd(cmd *cobra.Command, _ []string) (*VMEditOpts, error)
- func (c *Client) Validate() error
- type CloudInitUserData
- type Container
- type ContainerService
- type ContainerServiceOp
- type DiskSet
- type ErrorResponse
- type FundCode
- type Hostname
- type Location
- type LocationID
- type LocationListVMOpt
- type LocationService
- type LocationServiceOp
- func (s *LocationServiceOp) DisplayNameMap(ctx context.Context) (map[string]int, *Response, error)
- func (s *LocationServiceOp) Get(ctx context.Context, id int) (*Location, *Response, error)
- func (s *LocationServiceOp) GetWithName(ctx context.Context, name string) (*Location, *Response, error)
- func (s *LocationServiceOp) List(ctx context.Context) ([]Location, *Response, error)
- func (s *LocationServiceOp) ListDisplayNames(ctx context.Context) ([]string, *Response, error)
- func (s *LocationServiceOp) ListIDs(ctx context.Context) ([]int, *Response, error)
- func (s *LocationServiceOp) ListWithNetwork(ctx context.Context, name string) ([]Location, *Response, error)
- func (s *LocationServiceOp) ShellComplete(ctx context.Context, filter string) []string
- type Network
- type NetworkService
- type NetworkServiceOp
- func (s *NetworkServiceOp) Get(ctx context.Context, name string) (*Network, *Response, error)
- func (s *NetworkServiceOp) List(ctx context.Context) ([]Network, *Response, error)
- func (s *NetworkServiceOp) ListCIDRs(ctx context.Context) ([]string, *Response, error)
- func (s *NetworkServiceOp) ListWithLocation(ctx context.Context, id int) ([]Network, *Response, error)
- func (s *NetworkServiceOp) ShellComplete(ctx context.Context, filter string) []string
- type NetworkType
- type OS
- type OSID
- type OSService
- type OSServiceOp
- func (s *OSServiceOp) Get(ctx context.Context, name string) (*OS, *Response, error)
- func (s *OSServiceOp) List(ctx context.Context) ([]OS, *Response, error)
- func (s *OSServiceOp) ListIDs(ctx context.Context) ([]string, *Response, error)
- func (s *OSServiceOp) ShellComplete(ctx context.Context, filter string) []string
- type Option
- func WithApplication[T VMCreateOpts](f string) Option[T]
- func WithArchiveDeleteTime[T VMDeleteOpts](n time.Time) Option[T]
- func WithArchived[T VMListOpts]() Option[T]
- func WithBackups[T VMCreateOpts]() Option[T]
- func WithCPU[T VMCreateOpts | VMEditOpts](c int) Option[T]
- func WithCloudInitUserData[T VMCreateOpts](c string) Option[T]
- func WithContainer[T VMCreateOpts](f string) Option[T]
- func WithDeleteArchiveAfter(n time.Duration) Option[VMDeleteOpts]
- func WithDeleted[T VMListOpts]() Option[T]
- func WithDetails[T VMListOpts]() Option[T]
- func WithDisasterRecovery[T VMCreateOpts]() Option[T]
- func WithDisks[T VMCreateOpts | VMEditOpts](disks DiskSet) Option[T]
- func WithFundCode[T VMCreateOpts | VMEditOpts](f string) Option[T]
- func WithHostname[T VMCreateOpts](h string) Option[T]
- func WithIPAddress[T VMListOpts](n string) Option[T]
- func WithLocation[T VMCreateOpts | VMListOpts](l Location) Option[T]
- func WithName[T VMListOpts](n string) Option[T]
- func WithNetworkType[T VMCreateOpts](n NetworkType) Option[T]
- func WithOSID[T VMCreateOpts](h string) Option[T]
- func WithOnBehalfOf[T VMCreateOpts](f string) Option[T]
- func WithPatchWindowID[T VMCreateOpts](p int) Option[T]
- func WithPoweroffAllowed[T VMEditOpts]() Option[T]
- func WithProductionLevel[T VMCreateOpts](f ProductionLevel) Option[T]
- func WithRAM[T VMCreateOpts | VMEditOpts](r int) Option[T]
- func WithSecureProjectID[T VMCreateOpts](c int) Option[T]
- func WithSkipFinalize[T VMCreateOpts]() Option[T]
- func WithStartTime[T VMEditOpts | VMCreateOpts | VMDeleteOpts, V time.Time | string](n V) Option[T]
- func WithStorageType[T VMCreateOpts | VMEditOpts](s StorageType) Option[T]
- func WithSubnet[T VMCreateOpts](f string) Option[T]
- func WithSysadminOption[T VMCreateOpts | VMEditOpts](s SysadminOption) Option[T]
- func WithSysadminnedBy[T VMListOpts](n string) Option[T]
- func WithoutLive[T VMListOpts]() Option[T]
- func WithoutValidate[T VMCreateOpts]() Option[T]
- type PatchWindow
- type PatchWindowService
- type PatchWindowServiceOp
- type ProductionLevel
- type RAM
- type Response
- type StorageType
- type SysadminOption
- type VM
- type VMCreateOpts
- type VMDeleteOpts
- type VMDisk
- type VMEditOpts
- type VMListOpts
- type VMRequest
- type VMRequestListOpts
- type VMRequestResponse
- type VMRequestService
- type VMRequestServiceOp
- func (s *VMRequestServiceOp) Get(ctx context.Context, name int) (*VMRequest, *Response, error)
- func (s *VMRequestServiceOp) List(ctx context.Context, opt *VMRequestListOpts) ([]VMRequest, *Response, error)
- func (s *VMRequestServiceOp) ListWithVMId(ctx context.Context, id int, opt *VMRequestListOpts) ([]VMRequest, *Response, error)
- func (s *VMRequestServiceOp) WaitForFinalStatus(ctx context.Context, id int) error
- func (s *VMRequestServiceOp) WaitForFinalStatusTUI(ctx context.Context, id int) error
- type VMService
- type VMServiceOp
- func (s *VMServiceOp) Create(ctx context.Context, opt *VMCreateOpts) (*VMRequestResponse, *Response, error)
- func (s *VMServiceOp) Delete(ctx context.Context, vmid int, opt *VMDeleteOpts) (*VMRequestResponse, *Response, error)
- func (s *VMServiceOp) Edit(ctx context.Context, vmid int, opt *VMEditOpts) (*VMRequestResponse, *Response, error)
- func (s *VMServiceOp) Get(ctx context.Context, name int) (*VM, *Response, error)
- func (s *VMServiceOp) GetIDWithFQDN(ctx context.Context, fqdn string, opt *VMListOpts) (int, *Response, error)
- func (s *VMServiceOp) GetWithFQDN(ctx context.Context, fqdn string) (*VM, *Response, error)
- func (s *VMServiceOp) List(ctx context.Context, opt *VMListOpts) ([]VM, *Response, error)
- func (s *VMServiceOp) ListWithLocation(ctx context.Context, id int, c *LocationListVMOpt) ([]VM, *Response, error)
- func (s *VMServiceOp) ShellComplete(ctx context.Context, filter string) []string
- type Validator
Constants ¶
const AnyPatchWindow int = -1
AnyPatchWindow picks any available out of hours window
Variables ¶
This section is empty.
Functions ¶
func BindCreateVMCompletions ¶ added in v1.8.0
BindCreateVMCompletions adds auto completion to the Create VM command
func BindDeleteVMCobra ¶ added in v1.7.0
BindDeleteVMCobra creates the required arguments for a delete VM request
func BindEditVMCobra ¶ added in v1.6.1
BindEditVMCobra creates the required arguments for a modify VM request
func BindNewVMCobra ¶ added in v1.6.0
BindNewVMCobra creates the required arguments for a new VM to the given cobra.Command
func DoRequest ¶
DoRequest executes a request with the default http client Do we really need this one? - DS
func DoRequestWithClient ¶
func DoRequestWithClient(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
DoRequestWithClient submits an HTTP request using the specified client.
func NewVMCreateOpts ¶ added in v1.5.0
func NewVMCreateOpts[T VMCreateOpts](opts ...Option[T]) *T
NewVMCreateOpts uses functional options to return a new VMCreateOpts item
func NewVMDeleteOpts ¶ added in v1.5.0
func NewVMDeleteOpts[T VMDeleteOpts](opts ...Option[T]) *T
NewVMDeleteOpts creates a new VMDeleteOpts using functional options
func NewVMEditOpts ¶ added in v1.5.0
func NewVMEditOpts[T VMEditOpts](opts ...Option[T]) *T
NewVMEditOpts uses functional options to return a new VMEditOpts item
func NewVMListOpts ¶ added in v1.4.2
func NewVMListOpts[T VMListOpts](opts ...Option[T]) *T
NewVMListOpts generates a new VMListOpts object
func ProductionLevelCompletion ¶ added in v1.6.1
func ProductionLevelCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
ProductionLevelCompletion returns shell completion for the sysadmin options
func StorageTypeCompletion ¶ added in v1.6.0
func StorageTypeCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
StorageTypeCompletion returns shell completion for the storage options
func SysadminOptionCompletion ¶ added in v1.6.0
func SysadminOptionCompletion(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective)
SysadminOptionCompletion returns shell completion for the sysadmin options
func ValidatePatchWindowWithSysadminOption ¶ added in v1.5.0
func ValidatePatchWindowWithSysadminOption(p int, s SysadminOption) error
ValidatePatchWindowWithSysadminOption ensures these work together as expected
func WithEnv ¶ added in v1.5.0
func WithEnv() func(*Client)
WithEnv gets Username, Token and URL from environment variables
func WithErrWriter ¶ added in v1.5.0
WithErrWriter sets the error writer to something custom
func WithLogger ¶ added in v1.9.1
WithLogger sets the Logger on a new Client.
func WithReqWaitTimes ¶ added in v1.5.0
WithReqWaitTimes overrides the default timing when waiting for a request to complete
Types ¶
type AllowedBackups ¶ added in v1.6.0
type AllowedBackups int
AllowedBackups represents a range of backup types that a Location can have
const ( // NoBackups is...no backups! NoBackups AllowedBackups = iota // Backups is on-site VM backups Backups // BackupsAndDR is on-site and offsite BackupsAndDR )
func (*AllowedBackups) UnmarshalJSON ¶ added in v1.6.0
func (a *AllowedBackups) UnmarshalJSON(data []byte) error
UnmarshalJSON turns the int in to an actual AllowedBackups type
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // baseURLString string Username string Token string // User agent for client UserAgent string Location LocationService PatchWindow PatchWindowService Container ContainerService OS OSService Network NetworkService VMRequest VMRequestService VM VMService Logger *slog.Logger // contains filtered or unexported fields }
Client is the holder for all the services and methods for interacting with the API
func NewFromEnvironment ¶
NewFromEnvironment is just a shortcut for New(WithEnv()) Keeping it around for backwards compatibility (for now...) Deprecated: Use New(WithEnv()) instead going forward
func (*Client) CheckResponse ¶ added in v1.9.0
CheckResponse examines an http.Response and returns an error if it's not cool 😎
func (*Client) GuessPrimaryNetworkWithFQDN ¶ added in v1.4.14
GuessPrimaryNetworkWithFQDN attempts to find the primary network based off of the FQDN
func (*Client) GuessPrimaryNetworkWithVMId ¶ added in v1.4.15
GuessPrimaryNetworkWithVMId returns a network that is guessed using the VM ID
func (*Client) VMCreateOptsWithCmd ¶ added in v1.6.0
VMCreateOptsWithCmd creates a new VMCreatOpts with the cobra.Command info given
func (*Client) VMDeleteOptsWithCmd ¶ added in v1.7.0
VMDeleteOptsWithCmd returns a delete option with the given options
func (*Client) VMEditOptsWithCmd ¶ added in v1.6.1
VMEditOptsWithCmd returns an edit option with the given options
type CloudInitUserData ¶ added in v1.5.0
type CloudInitUserData string
CloudInitUserData is a non empty string
func (CloudInitUserData) Validate ¶ added in v1.5.0
func (r CloudInitUserData) Validate() error
Validate ensures this is set to a non empty string
type Container ¶
type Container struct {
Name string `json:"name,omitempty"`
}
Container is the clockworks 'container'
func NewContainer ¶ added in v1.5.0
NewContainer returns a new Container instance with the provided name
func (Container) ValidateWithSysadminOption ¶ added in v1.5.0
func (c Container) ValidateWithSysadminOption(s SysadminOption) error
ValidateWithSysadminOption returns an error if it's invalid
type ContainerService ¶
type ContainerService interface { List(context.Context) ([]Container, *Response, error) ListNames(context.Context) ([]string, *Response, error) Get(context.Context, string) (*Container, *Response, error) }
ContainerService holds on the methods for interacting with containers
type ContainerServiceOp ¶
type ContainerServiceOp struct {
// contains filtered or unexported fields
}
ContainerServiceOp is the operator for the ContainerService interface
type DiskSet ¶ added in v1.5.0
type DiskSet []VMDisk
DiskSet describes a slice of VMDisks
func NewDiskSet ¶ added in v1.5.0
NewDiskSet creates a new DiskSet with the given sizes in GB
func NewDiskSetPTR ¶ added in v1.5.0
NewDiskSetPTR returns a pointer to a new disk set
type ErrorResponse ¶
type ErrorResponse struct { // HTTP response that caused this error Response *http.Response // Error message Message string `json:"message"` Errors []string `json:"errors"` }
ErrorResponse holds the http response, and any additional metadata when an error is returned
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
Error turns the response in to an Error
type Hostname ¶ added in v1.5.0
type Hostname string
Hostname represents a valid hostname for a Clockworks interaction
type Location ¶
type Location struct { ID int `json:"id"` ParentLocation int `json:"parent_location,omitempty"` MemGBCapacity int `json:"mem_gb_capacity,omitempty"` MemGBUsed int `json:"mem_gb_used,omitempty"` CPUUsed int `json:"cpu_used,omitempty"` MinAllowedBackups AllowedBackups `json:"min_allowed_backups,omitempty"` MaxAllowedBackups AllowedBackups `json:"max_allowed_backups,omitempty"` IsCluster bool `json:"is_cluster,omitempty"` Type string `json:"type,omitempty"` VCenterFQDN string `json:"vcenter_fqdn,omitempty"` DisplayName string `json:"display_name,omitempty"` ClusterName string `json:"cluster_name,omitempty"` ChildLocations []interface{} `json:"child_locations,omitempty"` Datastores []string `json:"datastores,omitempty"` Tags []string `json:"tags,omitempty"` }
Location represents a Location item in Clockworks
func (*Location) CanBackup ¶ added in v1.6.0
CanBackup returns a boolean representing if normal backups can be performed on VMSs in this location
func (*Location) CanDR ¶ added in v1.6.0
CanDR returns a boolean representing if disaster recovery can be performed on VMS in this location
func (*Location) InferredBackup ¶ added in v1.6.0
InferredBackup returns true if the location has a >= min_allowed_backups of 1
func (*Location) InferredDR ¶ added in v1.6.0
InferredDR returns true if the location has a >= min_allowed_backups of 2
type LocationID ¶ added in v1.5.0
type LocationID int
LocationID is the ID of the location for a VM
func (LocationID) Validate ¶ added in v1.5.0
func (l LocationID) Validate() error
Validate ensures this is set to something > 0
type LocationListVMOpt ¶
type LocationListVMOpt struct { ShowDeleted bool `url:"show_deleted"` ShowArchived bool `url:"show_archived"` ShowLive bool `url:"show_live"` }
LocationListVMOpt are the options that can be passed to the LocationList service
type LocationService ¶
type LocationService interface { List(context.Context) ([]Location, *Response, error) ListIDs(context.Context) ([]int, *Response, error) ListWithNetwork(context.Context, string) ([]Location, *Response, error) ListDisplayNames(context.Context) ([]string, *Response, error) Get(context.Context, int) (*Location, *Response, error) GetWithName(context.Context, string) (*Location, *Response, error) DisplayNameMap(context.Context) (map[string]int, *Response, error) ShellComplete(context.Context, string) []string }
LocationService holds on the methods for interacting with the Location endpoint in Clockworks
type LocationServiceOp ¶
type LocationServiceOp struct {
// contains filtered or unexported fields
}
LocationServiceOp is the operator for the LocationServic
func (*LocationServiceOp) DisplayNameMap ¶
DisplayNameMap returns a map of the locations, using the DisplayName as the key and the ID as the value
func (*LocationServiceOp) GetWithName ¶ added in v1.6.0
func (s *LocationServiceOp) GetWithName(ctx context.Context, name string) (*Location, *Response, error)
GetWithName returns a single location using it's Name
func (*LocationServiceOp) ListDisplayNames ¶
ListDisplayNames returns a list of the display names for a location
func (*LocationServiceOp) ListWithNetwork ¶
func (s *LocationServiceOp) ListWithNetwork(ctx context.Context, name string) ([]Location, *Response, error)
ListWithNetwork returns the Locations for a given network
func (*LocationServiceOp) ShellComplete ¶ added in v1.6.1
func (s *LocationServiceOp) ShellComplete(ctx context.Context, filter string) []string
ShellComplete provides shell complete functionality for Locations
type Network ¶
type Network struct { ID int `json:"id"` Subnet string `json:"subnet,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` VRF string `json:"vrf,omitempty"` }
Network is the object that represents a Clockworks Network
type NetworkService ¶
type NetworkService interface { List(context.Context) ([]Network, *Response, error) ListCIDRs(context.Context) ([]string, *Response, error) ListWithLocation(context.Context, int) ([]Network, *Response, error) Get(context.Context, string) (*Network, *Response, error) ShellComplete(context.Context, string) []string }
NetworkService holds on the methods for interacting with the Network endpoint
type NetworkServiceOp ¶
type NetworkServiceOp struct {
// contains filtered or unexported fields
}
NetworkServiceOp is the operator for the NetworkService
func (*NetworkServiceOp) ListWithLocation ¶
func (s *NetworkServiceOp) ListWithLocation(ctx context.Context, id int) ([]Network, *Response, error)
ListWithLocation returns a list of networks given a location ID
func (*NetworkServiceOp) ShellComplete ¶ added in v1.6.1
func (s *NetworkServiceOp) ShellComplete(ctx context.Context, filter string) []string
ShellComplete provides shell completion for VM stuff
type NetworkType ¶ added in v1.5.0
type NetworkType int
NetworkType is the base type for a Network configuration option in Clockworks
const ( // NullNetwork is the empty NetworkType NullNetwork NetworkType = iota // PublicNetwork will use any available public network PublicNetwork // PrivateNetwork will use any available private network PrivateNetwork // CustomNetwork will use a given network CustomNetwork )
func NetworkTypeWithString ¶ added in v1.5.1
func NetworkTypeWithString(s string) NetworkType
NetworkTypeWithString returns a NetworkType using the given string
func (*NetworkType) MarshalJSON ¶ added in v1.5.0
func (n *NetworkType) MarshalJSON() ([]byte, error)
MarshalJSON ensures that json conversions use the string value here, not the int value
func (NetworkType) String ¶ added in v1.5.0
func (n NetworkType) String() string
func (NetworkType) ValidateWithSubnet ¶ added in v1.5.0
func (n NetworkType) ValidateWithSubnet(s string) error
ValidateWithSubnet ensures that a subnet is valid for a given NetworkType
type OS ¶
type OS struct { APIOnly bool `json:"api_only,omitempty"` Family string `json:"family,omitempty"` FullName string `json:"full_name,omitempty"` ID int `json:"id,omitempty"` InitScript string `json:"init_script,omitempty"` Movement string `json:"movement,omitempty"` OSId string `json:"os_id,omitempty"` SCCMCollectionID string `json:"sccm_collection_id,omitempty"` SSIManaged bool `json:"ssi_managed,omitempty"` SSIOnly bool `json:"ssi_only,omitempty"` Template string `json:"template,omitempty"` }
OS Represents an Operating Systems from Clockworks
type OSService ¶
type OSService interface { List(context.Context) ([]OS, *Response, error) ListIDs(context.Context) ([]string, *Response, error) Get(context.Context, string) (*OS, *Response, error) ShellComplete(context.Context, string) []string }
OSService holds all of the OS related methods
type OSServiceOp ¶
type OSServiceOp struct {
// contains filtered or unexported fields
}
OSServiceOp is the operator for the OSService
func (*OSServiceOp) ShellComplete ¶ added in v1.6.1
func (s *OSServiceOp) ShellComplete(ctx context.Context, filter string) []string
ShellComplete provides shell complete functionality for Locations
type Option ¶ added in v1.5.0
type Option[T VMCreateOpts | VMEditOpts | VMListOpts | VMDeleteOpts] func(*T)
Option is a generic that we can pass in to things like VM create/edit/etc
func WithApplication ¶ added in v1.6.0
func WithApplication[T VMCreateOpts](f string) Option[T]
WithApplication sets the application for a new request
func WithArchiveDeleteTime ¶ added in v1.5.0
func WithArchiveDeleteTime[T VMDeleteOpts](n time.Time) Option[T]
WithArchiveDeleteTime sets the archive_delete_time for a delete request
func WithArchived ¶ added in v1.5.0
func WithArchived[T VMListOpts]() Option[T]
WithArchived sets the show_archived to true for a filter option
func WithBackups ¶ added in v1.6.0
func WithBackups[T VMCreateOpts]() Option[T]
WithBackups sets the backups value to 'true'
func WithCPU ¶ added in v1.5.0
func WithCPU[T VMCreateOpts | VMEditOpts](c int) Option[T]
WithCPU sets the CPU in a request
func WithCloudInitUserData ¶ added in v1.5.0
func WithCloudInitUserData[T VMCreateOpts](c string) Option[T]
WithCloudInitUserData sets the cloud_init_user_data in a new request
func WithContainer ¶ added in v1.6.0
func WithContainer[T VMCreateOpts](f string) Option[T]
WithContainer sets the VMware container for the given VM
func WithDeleteArchiveAfter ¶ added in v1.7.0
func WithDeleteArchiveAfter(n time.Duration) Option[VMDeleteOpts]
WithDeleteArchiveAfter waits the given duration after a VM is deleted, before starting the archive deletion
func WithDeleted ¶ added in v1.5.0
func WithDeleted[T VMListOpts]() Option[T]
WithDeleted sets the show_deleted to true for a filter option
func WithDetails ¶ added in v1.5.0
func WithDetails[T VMListOpts]() Option[T]
WithDetails sets hide_details to false in a VM listing
func WithDisasterRecovery ¶ added in v1.6.0
func WithDisasterRecovery[T VMCreateOpts]() Option[T]
WithDisasterRecovery sets the disaster_recovery value to 'true'
func WithDisks ¶ added in v1.5.0
func WithDisks[T VMCreateOpts | VMEditOpts](disks DiskSet) Option[T]
WithDisks sets the initial disk sizes for a new VM request
func WithFundCode ¶ added in v1.5.0
func WithFundCode[T VMCreateOpts | VMEditOpts](f string) Option[T]
WithFundCode sets the fund_code for a new request
func WithHostname ¶ added in v1.5.0
func WithHostname[T VMCreateOpts](h string) Option[T]
WithHostname sets a hostname in the VMCreateOpts
func WithIPAddress ¶ added in v1.5.0
func WithIPAddress[T VMListOpts](n string) Option[T]
WithIPAddress sets the ipaddress for a filter option
func WithLocation ¶ added in v1.6.0
func WithLocation[T VMCreateOpts | VMListOpts](l Location) Option[T]
WithLocation specifies the location of a new VM. This will also set the backup and disasaster_recovery flags based off of the locations capabilities
func WithName ¶ added in v1.5.0
func WithName[T VMListOpts](n string) Option[T]
WithName sets the name for a filter option
func WithNetworkType ¶ added in v1.5.0
func WithNetworkType[T VMCreateOpts](n NetworkType) Option[T]
WithNetworkType specifies the network_type for a new request
func WithOSID ¶ added in v1.5.0
func WithOSID[T VMCreateOpts](h string) Option[T]
WithOSID sets a os_id in the VMCreateOpts
func WithOnBehalfOf ¶ added in v1.6.0
func WithOnBehalfOf[T VMCreateOpts](f string) Option[T]
WithOnBehalfOf sets the on_behalf_of for a new request
func WithPatchWindowID ¶ added in v1.5.0
func WithPatchWindowID[T VMCreateOpts](p int) Option[T]
WithPatchWindowID sets the patch_window_id in a new request
func WithPoweroffAllowed ¶ added in v1.5.0
func WithPoweroffAllowed[T VMEditOpts]() Option[T]
WithPoweroffAllowed will set poweroff_allowed to true in a VM request
func WithProductionLevel ¶ added in v1.6.0
func WithProductionLevel[T VMCreateOpts](f ProductionLevel) Option[T]
WithProductionLevel sets the application for a new request
func WithRAM ¶ added in v1.5.0
func WithRAM[T VMCreateOpts | VMEditOpts](r int) Option[T]
WithRAM sets the ram in a request
func WithSecureProjectID ¶ added in v1.6.0
func WithSecureProjectID[T VMCreateOpts](c int) Option[T]
WithSecureProjectID sets the secure_project_id in a request
func WithSkipFinalize ¶ added in v1.5.0
func WithSkipFinalize[T VMCreateOpts]() Option[T]
WithSkipFinalize sets the skip_finalize value to 'true'
func WithStartTime ¶ added in v1.7.0
func WithStartTime[T VMEditOpts | VMCreateOpts | VMDeleteOpts, V time.Time | string](n V) Option[T]
WithStartTime sets the start_time for a request
func WithStorageType ¶ added in v1.5.0
func WithStorageType[T VMCreateOpts | VMEditOpts](s StorageType) Option[T]
WithStorageType sets the storage_type in a new request
func WithSubnet ¶ added in v1.6.0
func WithSubnet[T VMCreateOpts](f string) Option[T]
WithSubnet sets the subnet for the given VM
func WithSysadminOption ¶ added in v1.5.0
func WithSysadminOption[T VMCreateOpts | VMEditOpts](s SysadminOption) Option[T]
WithSysadminOption sets the sysadmin_option_id in a new request
func WithSysadminnedBy ¶ added in v1.5.0
func WithSysadminnedBy[T VMListOpts](n string) Option[T]
WithSysadminnedBy sets the sysadminned_by for a filter option
func WithoutLive ¶ added in v1.5.0
func WithoutLive[T VMListOpts]() Option[T]
WithoutLive sets the show_live to false for a filter option
func WithoutValidate ¶ added in v1.6.0
func WithoutValidate[T VMCreateOpts]() Option[T]
WithoutValidate skips any attempt to validate the request before it is sent on to Clockworks. Useful for less wordy testing, or if the validation logic breaks before we can ship a fix
type PatchWindow ¶
PatchWindow represents a Patchmonkey Window from Clockworks
type PatchWindowService ¶
type PatchWindowService interface { List(context.Context) ([]PatchWindow, *Response, error) ListIDs(context.Context) ([]int, *Response, error) ShellComplete(context.Context, string) []string }
PatchWindowService contains all the PatchWindow methods
type PatchWindowServiceOp ¶
type PatchWindowServiceOp struct {
// contains filtered or unexported fields
}
PatchWindowServiceOp is the operator for the PatchWindowService
func (*PatchWindowServiceOp) List ¶
func (s *PatchWindowServiceOp) List(ctx context.Context) ([]PatchWindow, *Response, error)
List returns all PatchWindows
func (*PatchWindowServiceOp) ListIDs ¶ added in v1.10.0
ListIDs returns a list of all PatchWindow IDs
func (*PatchWindowServiceOp) ShellComplete ¶ added in v1.6.1
func (s *PatchWindowServiceOp) ShellComplete(ctx context.Context, filter string) []string
ShellComplete provides shell completion for VM stuff
type ProductionLevel ¶ added in v1.5.0
type ProductionLevel int
ProductionLevel represents the production level status of a VM
const ( // NullProductionLevel is the unset value for this type NullProductionLevel ProductionLevel = iota // Production is...prime time production my folks! Production // Testing is for testing changes before pushing to production Testing // Development is for breaking changes Development )
func (*ProductionLevel) MarshalJSON ¶ added in v1.6.2
func (p *ProductionLevel) MarshalJSON() ([]byte, error)
MarshalJSON ensures that json conversions use the string value here, not the int value
func (*ProductionLevel) Set ¶ added in v1.6.1
func (p *ProductionLevel) Set(v string) error
Set helps fulfill the pflag.Value interface
func (ProductionLevel) String ¶ added in v1.5.0
func (p ProductionLevel) String() string
func (ProductionLevel) Type ¶ added in v1.6.1
func (p ProductionLevel) Type() string
Type satisfies part of the pflags.Value interface
type StorageType ¶ added in v1.5.0
type StorageType int
StorageType represents one of the storage classes in Clockworks
const ( // NullStorageType is the unset Storage Type NullStorageType StorageType = iota // PlatinumStorage is the all flash array PlatinumStorage // SilverStorage is the 'fast' array SilverStorage // BronzeStorage is 'slow', but actually still pretty fast BronzeStorage )
func StorageTypeWithString ¶ added in v1.5.1
func StorageTypeWithString(s string) StorageType
StorageTypeWithString returns a storage type using the given string.
func (*StorageType) MarshalJSON ¶ added in v1.5.0
func (s *StorageType) MarshalJSON() ([]byte, error)
MarshalJSON ensures that json conversions use the string value here, not the int value
func (*StorageType) Set ¶ added in v1.6.0
func (s *StorageType) Set(v string) error
Set helps fulfill the pflag.Value interface
func (StorageType) String ¶ added in v1.5.0
func (s StorageType) String() string
func (*StorageType) Type ¶ added in v1.6.0
func (s *StorageType) Type() string
Type is used in the help for pflag.Value
func (StorageType) Validate ¶ added in v1.5.0
func (s StorageType) Validate() error
Validate returns an error if empty
type SysadminOption ¶ added in v1.5.0
type SysadminOption int
SysadminOption is the type of support for a given VM
[1 == self-admin, 2 == 8/5, 3 == 24/7, 4 == 8/5 web, 5 == 24/7 web]
const ( // NullSupport is the unset value NullSupport SysadminOption = iota // SelfAdminSupport is user supported, no ssi SelfAdminSupport // WorkHoursGeneralSupport is general 8-5 support WorkHoursGeneralSupport // FullGeneralSupport is 24/7 general support FullGeneralSupport // WorkHoursWebSupport is web supported 8-5 WorkHoursWebSupport // FullWebSupport is 24/7 web support FullWebSupport )
func (*SysadminOption) Set ¶ added in v1.6.0
func (s *SysadminOption) Set(v string) error
Set helps fulfill the pflag.Value interface
func (SysadminOption) String ¶ added in v1.6.0
func (s SysadminOption) String() string
String returns the string representing a given SupportOption
func (*SysadminOption) Type ¶ added in v1.6.0
func (s *SysadminOption) Type() string
Type is used in the help for pflag.Value
func (SysadminOption) Validate ¶ added in v1.5.0
func (s SysadminOption) Validate() error
Validate ensures this is set
type VM ¶
type VM struct { ID int `json:"id"` Name string `json:"name,omitempty"` GuestFqdn string `json:"guest_fqdn,omitempty"` MemGB float64 `json:"mem_gb,omitempty"` // MemGB looks like an int in test, but is in fact a float MemMB int `json:"mem_mb,omitempty"` LocationID int `json:"location_id,omitempty"` CPU int `json:"cpu,omitempty"` PatchWindowID int `json:"patch_window_id,omitempty"` SysadminOptionID int `json:"sysadmin_option_id,omitempty"` SelfAdmin bool `json:"self_admin,omitempty"` Folder string `json:"folder,omitempty"` FundCodes []FundCode `json:"fund_codes,omitempty"` UUID string `json:"uuid,omitempty"` SerialNumber string `json:"serial_number,omitempty"` Type string `json:"type,omitempty"` MoRef string `json:"mo_ref,omitempty"` MobURL string `json:"mob_url,omitempty"` WebURL string `json:"web_url,omitempty"` APIURL string `json:"api_url,omitempty"` ServiceLevel string `json:"service_level,omitempty"` StorageType string `json:"storage_type,omitempty"` ProductionLevel string `json:"production_level,omitempty"` ToolsStatus string `json:"tools_status,omitempty"` OSId string `json:"os_id,omitempty"` OsOptionID string `json:"os_option_id,omitempty"` CloudInitUserData string `json:"cloud_init_user_data,omitempty"` Disks []VMDisk `json:"disks,omitempty"` SysadminNetids []string `json:"sysadmin_netids,omitempty"` AppAdminNetids []string `json:"app_admin_netids,omitempty"` MacAddresses []string `json:"mac_addresses,omitempty"` IPAddresses []string `json:"ip_addresses,omitempty"` }
VM represents a VM inside of Clockworks
type VMCreateOpts ¶
type VMCreateOpts struct { CPU CPU `json:"cpu,omitempty"` LocationID LocationID `json:"location_id,omitempty"` PatchWindowID int `json:"patch_window_id,omitempty"` RAM RAM `json:"ram,omitempty"` SecureProjectID int `json:"secure_project_id,omitempty"` SysadminOptionID SysadminOption `json:"sysadmin_option_id,omitempty"` Backups bool `json:"backups,omitempty"` DisasterRecovery bool `json:"disaster_recovery,omitempty"` SkipFinalize bool `json:"skip_finalize,omitempty"` OSID OSID `json:"os_id,omitempty"` Hostname Hostname `json:"hostname,omitempty"` FundCode FundCode `json:"fund_code,omitempty"` NetworkType NetworkType `json:"network_type,omitempty"` Subnet string `json:"subnet,omitempty"` ContainerName string `json:"container_name,omitempty"` CloudInitUserData CloudInitUserData `json:"cloud_init_user_data,omitempty"` ProductionLevel ProductionLevel `json:"production_level,omitempty"` StorageType StorageType `json:"storage_type,omitempty"` ApplicationName string `json:"application_name,omitempty"` Disks DiskSet `json:"disks,omitempty"` OnBehalfOf string `json:"on_behalf_of,omitempty"` StartTime *time.Time `json:"start_time,omitempty"` // contains filtered or unexported fields }
VMCreateOpts specifies options for creating a new VM
func (VMCreateOpts) Validate ¶ added in v1.5.0
func (opt VMCreateOpts) Validate() error
Validate Loops through various validators and makes sure a VMCreate request is ok Wondering if we should move this to the VMCreateOpts object instead of having a public method for this - DS
type VMDeleteOpts ¶
type VMDeleteOpts struct { ArchiveDeleteTime *time.Time `json:"archive_delete_time,omitempty"` StartTime *time.Time `json:"start_time,omitempty"` }
VMDeleteOpts defines options for deleting a VM
type VMDisk ¶
VMDisk contains the information needed for interacting with disks on a VM inside of Clockworks
func NewDiskWithID ¶ added in v1.8.0
NewDiskWithID creates a new VMDisk object with the given size and id
type VMEditOpts ¶
type VMEditOpts struct { FundCode FundCode `json:"fund_code,omitempty"` RAM RAM `json:"ram,omitempty"` CPU CPU `json:"cpu,omitempty"` Disks *DiskSet `json:"disks,omitempty"` StorageType StorageType `json:"storage_type,omitempty"` SysadminOptionID SysadminOption `json:"sysadmin_option_id,omitempty"` PoweroffAllowed bool `json:"poweroff_allowed"` StartTime *time.Time `json:"start_time,omitempty"` }
VMEditOpts defines options for editing a VM
func (*VMEditOpts) Validate ¶
func (v *VMEditOpts) Validate() error
Validate makes sure we aren't just passing an empty one in here with no changes
type VMListOpts ¶
type VMListOpts struct { Name string `url:"name,omitempty"` SysadminnedBy string `url:"sysadminned_by,omitempty"` HideDetails bool `url:"hide_details"` ShowDeleted bool `url:"show_deleted"` ShowArchived bool `url:"show_archived"` ShowLive bool `url:"show_live"` LocationID LocationID `url:"location_id,omitempty"` IPAddress string `url:"ip_address,omitempty"` }
VMListOpts are the options for listing VMs
type VMRequest ¶
type VMRequest struct { APIUserNetid string `json:"api_user_netid,omitempty"` ApproverID int `json:"approver_id,omitempty"` ApproverNetid string `json:"approver_netid,omitempty"` Comments string `json:"comments,omitempty"` CreatedAt string `json:"created_at,omitempty"` DateRequested string `json:"date_requested,omitempty"` DateStarted string `json:"date_started,omitempty"` Hostname string `json:"hostname,omitempty"` ID int `json:"id,omitempty"` OldVMRequestInfoID int `json:"old_vm_request_info_id,omitempty"` ScheduledStart string `json:"scheduled_start,omitempty"` SensitiveData bool `json:"sensitive_data,omitempty"` SkipFinalize bool `json:"skip_finalize,omitempty"` SnRequestID string `json:"sn_request_id,omitempty"` Status string `json:"status,omitempty"` StepID int `json:"step_id,omitempty"` Type string `json:"type,omitempty"` UpdatedAt string `json:"updated_at,omitempty"` UserID int `json:"user_id,omitempty"` UserNetid string `json:"user_netid,omitempty"` VMID int `json:"vm_id,omitempty"` VMRequestInfoID int `json:"vm_request_info_id,omitempty"` }
VMRequest holds all the information needed for a VMRequest
type VMRequestListOpts ¶
type VMRequestListOpts struct {
Status string `url:"status,omitempty"`
}
VMRequestListOpts is the config for a VMRequestList
type VMRequestResponse ¶
type VMRequestResponse struct { SNRequestID string `json:"sn_request_id,omitempty"` VMRequestAPIURL string `json:"vm_request_api_url,omitempty"` VMRequestID int `json:"vm_request_id,omitempty"` VMRequestWebURL string `json:"vm_request_web_url,omitempty"` Errors []string `json:"errors,omitempty"` }
VMRequestResponse is the response to a VMRequest
type VMRequestService ¶
type VMRequestService interface { List(context.Context, *VMRequestListOpts) ([]VMRequest, *Response, error) ListWithVMId(context.Context, int, *VMRequestListOpts) ([]VMRequest, *Response, error) Get(context.Context, int) (*VMRequest, *Response, error) WaitForFinalStatusTUI(context.Context, int) error WaitForFinalStatus(context.Context, int) error }
VMRequestService contains all of the methods for a VMRequest
type VMRequestServiceOp ¶
type VMRequestServiceOp struct {
// contains filtered or unexported fields
}
VMRequestServiceOp is the operator for the VMRequestService
func (*VMRequestServiceOp) List ¶
func (s *VMRequestServiceOp) List(ctx context.Context, opt *VMRequestListOpts) ([]VMRequest, *Response, error)
List returns all VMRequests
func (*VMRequestServiceOp) ListWithVMId ¶
func (s *VMRequestServiceOp) ListWithVMId(ctx context.Context, id int, opt *VMRequestListOpts) ([]VMRequest, *Response, error)
ListWithVMId returns a list of VMRequests with a given VM ID
func (*VMRequestServiceOp) WaitForFinalStatus ¶
func (s *VMRequestServiceOp) WaitForFinalStatus(ctx context.Context, id int) error
WaitForFinalStatus just waits for a completed status
func (*VMRequestServiceOp) WaitForFinalStatusTUI ¶
func (s *VMRequestServiceOp) WaitForFinalStatusTUI(ctx context.Context, id int) error
WaitForFinalStatusTUI - Blocks until a VMRequest is in a final status. Usually completed or errored in a TUI
type VMService ¶
type VMService interface { // Read only Operations List(context.Context, *VMListOpts) ([]VM, *Response, error) ListWithLocation(context.Context, int, *LocationListVMOpt) ([]VM, *Response, error) Get(context.Context, int) (*VM, *Response, error) GetWithFQDN(context.Context, string) (*VM, *Response, error) GetIDWithFQDN(context.Context, string, *VMListOpts) (int, *Response, error) // Shell Helpers ShellComplete(context.Context, string) []string // Edit Operations Edit(context.Context, int, *VMEditOpts) (*VMRequestResponse, *Response, error) Delete(context.Context, int, *VMDeleteOpts) (*VMRequestResponse, *Response, error) Create(context.Context, *VMCreateOpts) (*VMRequestResponse, *Response, error) }
VMService contains all the methods needed for interacting with the VM endpoint
type VMServiceOp ¶
type VMServiceOp struct {
// contains filtered or unexported fields
}
VMServiceOp is the operator for the VMService
func (*VMServiceOp) Create ¶
func (s *VMServiceOp) Create(ctx context.Context, opt *VMCreateOpts) (*VMRequestResponse, *Response, error)
Create will create a VM with the given VMCreateOpts
func (*VMServiceOp) Delete ¶
func (s *VMServiceOp) Delete(ctx context.Context, vmid int, opt *VMDeleteOpts) (*VMRequestResponse, *Response, error)
Delete deletes a VM
func (*VMServiceOp) Edit ¶
func (s *VMServiceOp) Edit(ctx context.Context, vmid int, opt *VMEditOpts) (*VMRequestResponse, *Response, error)
Edit allows modification to a VM given the ID and VMEditOpts
func (*VMServiceOp) GetIDWithFQDN ¶
func (s *VMServiceOp) GetIDWithFQDN(ctx context.Context, fqdn string, opt *VMListOpts) (int, *Response, error)
GetIDWithFQDN Given the FQDN of a host, return the clockworks ID.
func (*VMServiceOp) GetWithFQDN ¶
GetWithFQDN returns a VM after being given the FQDN
func (*VMServiceOp) List ¶
func (s *VMServiceOp) List(ctx context.Context, opt *VMListOpts) ([]VM, *Response, error)
List will return all VMs matching the passed options
func (*VMServiceOp) ListWithLocation ¶
func (s *VMServiceOp) ListWithLocation(ctx context.Context, id int, c *LocationListVMOpt) ([]VM, *Response, error)
ListWithLocation returns a list of VMs given the location id and list options
func (*VMServiceOp) ShellComplete ¶ added in v1.6.1
func (s *VMServiceOp) ShellComplete(ctx context.Context, filter string) []string
ShellComplete provides shell completion for VM stuff