package repository // Tokens represents a user record with info and permissions. type Tokens struct { ID int64 `json:"id"` Name string `json:"name"` LastName string `json:"last_name"` Login string `json:"login"` Token string `json:"token"` PermissionView bool `json:"permission_view"` PermissionManage bool `json:"permission_manage_agent"` PermissionAdmin bool `json:"permission_admin"` IsActive bool `json:"is_active"` } // TokenCreate is the request body for creating a new user. type TokenCreate struct { Name string `json:"name" binding:"required"` LastName string `json:"last_name" binding:"required"` Login string `json:"login" binding:"required"` Password string `json:"password" binding:"required"` PermissionView bool `json:"permission_view"` PermissionManage bool `json:"permission_manage_agent"` PermissionAdmin bool `json:"permission_admin"` IsActive bool `json:"is_active"` } // UserRegister is the request body for public user registration (all permissions false). type UserRegister struct { Name string `json:"name" binding:"required"` LastName string `json:"last_name" binding:"required"` Login string `json:"login" binding:"required"` Password string `json:"password" binding:"required"` } // TokenUpdate is the request body for updating an existing user. type TokenUpdate struct { Name string `json:"name"` LastName string `json:"last_name"` } // TokenUpdatePermissions is the request body for updating user permissions. type TokenUpdatePermissions struct { PermissionView *bool `json:"permission_view"` PermissionManage *bool `json:"permission_manage_agent"` PermissionAdmin *bool `json:"permission_admin"` IsActive *bool `json:"is_active"` } // TokenPasswordReset is the request body for resetting a user's password. type TokenPasswordReset struct { NewPassword string `json:"new_password" binding:"required"` } // BatchActionRequest is the request body for batch activate/deactivate users. type BatchActionRequest struct { Logins []string `json:"logins" binding:"required,min=1"` } // LoginRequest is the request body for login. type LoginRequest struct { Login string `json:"login" binding:"required"` Password string `json:"password" binding:"required"` } // LoginResponse is returned after successful login. type LoginResponse struct { Token string `json:"token"` Name string `json:"name"` LastName string `json:"last_name"` Login string `json:"login"` PermissionView bool `json:"permission_view"` PermissionManage bool `json:"permission_manage_agent"` PermissionAdmin bool `json:"permission_admin"` IsActive bool `json:"is_active"` } // RegistrationToken represents a one-time agent registration token. type RegistrationToken struct { ID int64 `json:"id"` Token string `json:"token"` Label string `json:"label"` Used bool `json:"used"` CreatedAt *string `json:"created_at"` UsedAt *string `json:"used_at"` } // RegistrationRequest is the request body for creating a registration token. type RegistrationRequest struct { Label string `json:"label" binding:"required"` } // RegistrationResponse is returned when an agent registers. type RegistrationResponse struct { CACert string `json:"ca_cert"` ClientCert string `json:"client_cert"` } // DeployType represents the type of agent deployment // @Description Type of deployment: docker or binary type DeployType string const ( DeployTypeDocker DeployType = "docker" DeployTypeBinary DeployType = "binary" ) // AuthMethod represents the SSH authentication method // @Description SSH authentication method: key or password type AuthMethod string const ( AuthMethodKey AuthMethod = "key" AuthMethodPassword AuthMethod = "password" ) // AgentDeployConfig represents the configuration for deploying an agent to a server // @Description Configuration for deploying HellreigN agent to a single server type AgentDeployConfig struct { User string `json:"user" binding:"required" example:"admin" description:"SSH username"` IP string `json:"ip" binding:"required" example:"192.168.1.100" description:"Server IP address"` Port int `json:"port" example:"22" description:"SSH port (default: 22)"` AuthMethod AuthMethod `json:"authMethod" binding:"required" example:"key" description:"SSH auth method: key or password"` SSHKey string `json:"sshKey,omitempty" example:"-----BEGIN OPENSSH PRIVATE KEY-----" description:"SSH private key (required if authMethod=key)"` Password string `json:"password,omitempty" example:"secret" description:"SSH password (required if authMethod=password)"` DeployType DeployType `json:"deployType" binding:"required" example:"docker" description:"Deployment type: docker or binary"` AgentLabel string `json:"agentLabel" binding:"required" example:"production-server-1" description:"Unique label for the agent"` } // DeployAgentsRequest represents the request body for deploying agents to multiple servers // @Description Request to deploy HellreigN agents to multiple servers type DeployAgentsRequest struct { Servers []AgentDeployConfig `json:"servers" binding:"required,min=1,dive" description:"List of server configurations"` } // DeployResponse represents the response after deploying agents // @Description Response containing deployment results and registration tokens type DeployResponse struct { Message string `json:"message" example:"Deployment completed"` Results []DeployResult `json:"results" description:"Deployment results for each server"` } // DeployResult represents the result of deploying to a single server // @Description Result of deploying to a single server type DeployResult struct { IP string `json:"ip" example:"192.168.1.100" description:"Server IP address"` AgentLabel string `json:"agent_label" example:"production-server-1" description:"Agent label"` Token string `json:"token" example:"abc123..." description:"Registration token for agent registration"` Success bool `json:"success" example:"true" description:"Whether deployment succeeded"` Error string `json:"error,omitempty" example:"" description:"Error message if deployment failed"` } // Script represents a stored script with path and interpreter binding. type Script struct { ID int64 `json:"id"` Path string `json:"path"` Content string `json:"content"` InterpreterID int64 `json:"interpreter_id"` CreatedAt *string `json:"created_at"` UpdatedAt *string `json:"updated_at"` } // ScriptCreate is the request body for creating a script. type ScriptCreate struct { Path string `json:"path" binding:"required"` Content string `json:"content"` InterpreterID int64 `json:"interpreter_id" binding:"required"` } // ScriptUpdate is the request body for updating a script. type ScriptUpdate struct { Path *string `json:"path"` Content *string `json:"content"` InterpreterID *int64 `json:"interpreter_id"` } // ScriptTreeNode represents a node in the script directory tree. type ScriptTreeNode struct { Name string `json:"name"` Type string `json:"type"` // "folder" or "file" Children []ScriptTreeNode `json:"children,omitempty"` ID *int64 `json:"id,omitempty"` Content *string `json:"content,omitempty"` InterpreterID *int64 `json:"interpreter_id,omitempty"` }