Documentation
¶
Overview ¶
Package types provides type definitions for the application
Index ¶
- func ValidateVolume(v *VolumeConfig, instanceRegion string) error
- type CreateUserRequest
- type CreateUserResponse
- type DeleteInstanceRequest
- type DeleteInstancesRequest
- type ErrorResponse
- type InstanceListResponse
- type InstanceRequest
- type ListResponse
- type PaginationResponse
- type PublicIPs
- type PublicIPsResponse
- type Response
- type Slug
- type SlugResponse
- type SuccessResponse
- type TaskListResponse
- type TaskResponse
- type UserResponse
- type VolumeConfig
- type VolumeDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateVolume ¶
func ValidateVolume(v *VolumeConfig, instanceRegion string) error
ValidateVolume checks if the volume configuration is valid
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct {
Username string `json:"username" gorm:"not null;unique"`
Email string `json:"email" gorm:""`
Role models.UserRole `json:"role" gorm:"index"`
PublicSSHKey string `json:"public_ssh_key" gorm:""`
}
CreateUserRequest represents a request to create a new user
func (CreateUserRequest) Validate ¶
func (u CreateUserRequest) Validate() error
Validate validates the create user request
type CreateUserResponse ¶
type CreateUserResponse struct {
UserID uint `json:"id"`
}
CreateUserResponse represents the response from the create user endpoint
type DeleteInstanceRequest ¶
type DeleteInstanceRequest struct {
InstanceID uint `json:"instance_id" validate:"required"` // Instance ID to delete
}
DeleteInstanceRequest represents the request body for deleting a single instance
type DeleteInstancesRequest ¶ added in v0.0.2
type DeleteInstancesRequest struct {
OwnerID uint `json:"owner_id" validate:"required"` // Owner ID
ProjectName string `json:"project_name" validate:"required"` // Project name
InstanceIDs []uint `json:"instance_ids" validate:"required,min=1"` // Instances to delete
}
DeleteInstancesRequest represents the request body for deleting instances swagger:model Example: {"owner_id":1,"project_name":"my-web-project","instance_ids":[123,456]}
type ErrorResponse ¶ added in v0.0.9
type ErrorResponse struct {
// Error message describing what went wrong
Error string `json:"error"`
// Optional additional details about the error, may include field-specific validation errors
Details interface{} `json:"details,omitempty"`
}
ErrorResponse represents an error response swagger:model Example: {"error":"Invalid input parameter","details":{"field":"region","message":"Region is required"}}
type InstanceListResponse ¶ added in v0.0.9
type InstanceListResponse struct {
// Array of instance objects
Rows []interface{} `json:"rows"`
// Pagination information for the result set
Pagination PaginationResponse `json:"pagination"`
}
InstanceListResponse represents a response containing a list of instances swagger:model Example: {"rows":[{"id":1,"provider_id":"do","status":"ready","public_ip":"203.0.113.42"},{"id":2,"provider_id":"aws","status":"provisioning"}],"pagination":{"total":2,"page":1,"limit":10,"offset":0}}
type InstanceRequest ¶
type InstanceRequest struct {
// DB Model Data - User Defined
OwnerID uint `json:"owner_id"` // Owner ID of the instance
Provider models.ProviderID `json:"provider"` // Cloud provider (e.g., "do")
Region string `json:"region"` // Region where instances will be created
Size string `json:"size"` // Instance size/type (used for cloud provider with predefined sizes)
Memory int `json:"memory"` // Memory in MB (used for Ximera to allow custom memory)
CPU int `json:"cpu"` // CPU cores (used for Ximera to allow custom CPU)
Image string `json:"image"` // OS image to use
Tags []string `json:"tags"` // Tags to apply to instances
// DB Model Data - Internally set during creation
InstanceID uint `json:"instance_id"` // Instance ID
PublicIP string `json:"public_ip"` // Public IP address
VolumeIDs []string `json:"volume_ids,omitempty"` // List of attached volume IDs
VolumeDetails []VolumeDetails `json:"volume_details,omitempty"` // Detailed information about attached volumes
// User Defined Configs
ProjectName string `json:"project_name"`
Name string `json:"name,omitempty"` // Optional name for the instance(s). If multiple instances, will be suffixed with index
SSHKeyName string `json:"ssh_key_name"` // Name of the SSH key to use
NumberOfInstances int `json:"number_of_instances"` // Number of instances to create
Provision bool `json:"provision"` // Whether to run Ansible provisioning
PayloadPath string `json:"payload_path,omitempty"` // Local path to the payload script on the API server
ExecutePayload bool `json:"execute_payload,omitempty"` // Whether to execute the payload after copying
Volumes []VolumeConfig `json:"volumes"` // Optional volumes to attach
// Internal Configs - Used during processing
InstanceIndex int `json:"instance_index,omitempty"` // Index of this instance when creating multiple instances
// Talis Server Configs - Optional
SSHKeyType string `json:"ssh_key_type,omitempty"` // Type of the private SSH key for Ansible (e.g., "rsa", "ed25519"). Defaults to "rsa".
SSHKeyPath string `json:"ssh_key_path,omitempty"` // Custom path to the private SSH key file for Ansible. Overrides defaults.
// Internal Configs - Set by the Talis Server
Action string `json:"action"`
ProviderInstanceID int `json:"provider_instance_id"` // Provider-specific instance ID
LastTaskID uint `json:"last_task_id"` // ID of the last task
}
InstanceRequest represents an RPC request for a single instance NOTE: These should be cleaned up and replaced with specific RPC request types swagger:model Example: {"owner_id":1,"provider":"do","region":"nyc1","size":"s-1vcpu-1gb","image":"ubuntu-20-04-x64","tags":["webserver","production"],"project_name":"my-web-project","ssh_key_name":"my-ssh-key","number_of_instances":2,"provision":true,"payload_path":"/path/to/your/script.sh","execute_payload":true,"volumes":[{"name":"my-volume-1","size_gb":10,"mount_point":"/mnt/data"}]}
func (*InstanceRequest) GetCPU ¶ added in v0.0.16
func (i *InstanceRequest) GetCPU() int
GetCPU returns the CPU value for validation
func (*InstanceRequest) GetImage ¶ added in v0.0.16
func (i *InstanceRequest) GetImage() string
GetImage returns the Image value for validation
func (*InstanceRequest) GetMemory ¶ added in v0.0.16
func (i *InstanceRequest) GetMemory() int
GetMemory returns the memory value for validation
func (*InstanceRequest) GetSSHKeyName ¶ added in v0.0.16
func (i *InstanceRequest) GetSSHKeyName() string
GetSSHKeyName returns the SSHKeyName value for validation
func (*InstanceRequest) Validate ¶
func (i *InstanceRequest) Validate() error
Validate validates the instance configuration
type ListResponse ¶
type ListResponse[T any] struct { // Array of resource items Rows []T `json:"rows"` // Pagination information for the result set Pagination PaginationResponse `json:"pagination"` }
ListResponse defines a generic response structure for listing resources swagger:model Example: {"rows":[{"id":1,"name":"example"},{"id":2,"name":"example2"}],"pagination":{"total":2,"page":1,"limit":10,"offset":0}}
type PaginationResponse ¶
type PaginationResponse struct {
// Total number of items available across all pages
Total int `json:"total"`
// Current page number (1-based)
Page int `json:"page"`
// Maximum number of items per page
Limit int `json:"limit"`
// Number of items skipped from the beginning of the result set
Offset int `json:"offset"`
}
PaginationResponse represents pagination information for list endpoints swagger:model Example: {"total":42,"page":1,"limit":10,"offset":0}
type PublicIPs ¶
type PublicIPs struct {
// The public IPv4 address of the instance
PublicIP string `json:"public_ip"`
}
PublicIPs represents the public IP address of a single instance swagger:model Example: {"public_ip":"203.0.113.42"}
type PublicIPsResponse ¶
type PublicIPsResponse struct {
// List of public IP addresses for instances
PublicIPs []PublicIPs `json:"public_ips"`
// Pagination information for the result set
Pagination PaginationResponse `json:"pagination"`
}
PublicIPsResponse represents the response from the public IPs endpoint swagger:model Example: {"public_ips":[{"public_ip":"203.0.113.42"},{"public_ip":"198.51.100.7"}],"pagination":{"total":2,"page":1,"limit":10,"offset":0}}
type Response ¶
type Response struct {
// Unique identifier for the infrastructure job
ID uint `json:"id"`
// Current status of the infrastructure job (e.g., "pending", "running", "completed", "failed")
Status string `json:"status"`
}
Response represents the response from the infrastructure API swagger:model Example: {"id":123,"status":"running"}
type Slug ¶
type Slug string
Slug is a type for the slug field in the response It is mainly used for the client to understand the type of the response
type SlugResponse ¶
type SlugResponse struct {
Slug Slug `json:"slug"`
Error string `json:"error"`
Data interface{} `json:"data"`
}
SlugResponse is the response type for the API TODO: I think this needs to be revised, I think a generic APIResponse type would be better. The Client methods would need to be updated to ingest the APIResponse type and then decode the data into the appropriate type.
func ErrInvalidInput ¶
func ErrInvalidInput(msg string) SlugResponse
ErrInvalidInput returns a SlugResponse with the InvalidInputSlug and the error message
func ErrNotFound ¶
func ErrNotFound(msg string) SlugResponse
ErrNotFound returns a SlugResponse with the NotFoundSlug and the error message
func ErrServer ¶
func ErrServer(msg string) SlugResponse
ErrServer returns a SlugResponse with the ServerErrorSlug and the error message
func Success ¶
func Success(data interface{}) SlugResponse
Success returns a SlugResponse with the SuccessSlug and the data
type SuccessResponse ¶ added in v0.0.9
type SuccessResponse struct {
// Optional data returned by the operation, may include created resource IDs or other operation results
Data interface{} `json:"data,omitempty"`
}
SuccessResponse represents a success response swagger:model Example: {"data":{"id":123,"status":"created"}}
type TaskListResponse ¶ added in v0.0.9
type TaskListResponse struct {
// Array of task objects
Rows []interface{} `json:"rows"`
// Pagination information for the result set
Pagination PaginationResponse `json:"pagination"`
}
TaskListResponse represents a response containing a list of tasks swagger:model Example: {"rows":[{"id":1,"name":"create_instance","status":"completed"},{"id":2,"name":"provision_instance","status":"pending"}],"pagination":{"total":2,"page":1,"limit":10,"offset":0}}
type TaskResponse ¶
type TaskResponse struct {
// Name of the task that was created or acted upon
TaskName string `json:"task_name"`
}
TaskResponse represents the response when a task is created or acted upon swagger:model Example: {"task_name":"create_instance"}
type UserResponse ¶
type UserResponse struct {
// This can be a single user or null when returning multiple users
User models.User `json:"user,omitempty"`
// This can be an array of users or null when returning a single user
Users []models.User `json:"users,omitempty"`
// Pagination info included only when returning multiple users
Pagination *PaginationResponse `json:"pagination,omitempty"`
}
UserResponse is a flexible response type for both single and multiple user scenarios
type VolumeConfig ¶
type VolumeConfig struct {
Name string `json:"name"` // Name of the volume
SizeGB int `json:"size_gb"` // Size in gigabytes
Region string `json:"region"` // Region where to create the volume
FileSystem string `json:"filesystem"` // File system type (optional)
MountPoint string `json:"mount_point"` // Where to mount the volume
}
VolumeConfig represents the configuration for a volume
type VolumeDetails ¶
type VolumeDetails struct {
ID string `json:"id"` // Volume ID
Name string `json:"name"` // Volume name
Region string `json:"region"` // Region where volume was created
SizeGB int `json:"size_gb"` // Size in gigabytes
MountPoint string `json:"mount_point"` // Where the volume is mounted
}
VolumeDetails represents detailed information about a created volume