Hosts Controller

@RestController
@RequestMapping(value = "BASE_EQUINOX_ENDPOINT + SESSIONS_KEY + "/{" + IDENTIFIER_KEY + "}/" + HOSTS_KEY" )
open class HostsController : DefaultBrownieController

The BrownieSessionController class is useful to manage all the BrownieHost operations

Author

N7ghtm4r3 - Tecknobit

See also

EquinoxController
DefaultEquinoxController

Constructors

Link copied to clipboard
@Autowired
constructor(sessionsService: BrownieSessionsService, hostsService: HostsService)
Constructor used to init the controller

Properties

Link copied to clipboard
protected val configuration: EquinoxBackendConfiguration
Link copied to clipboard
currentBrownieSession the current Brownie's session used in the request
Link copied to clipboard
protected val hostsService: HostsService
hostsService the support service used to manage the hosts data
Link copied to clipboard
protected open var jsonHelper: JsonHelper
Link copied to clipboard
protected open var me: T
Link copied to clipboard
protected open var messageSource: MessageSource
Link copied to clipboard
open var resourcesProvider: ResourcesProvider
Link copied to clipboard
val RESPONSE_SUCCESSFUL_MESSAGE: String = "operation_executed_successfully"
Link copied to clipboard
protected open var serverProtector: ServerProtector
Link copied to clipboard
sessionsService the support service used to manage the sessions data
Link copied to clipboard
val SOMETHING_WENT_WRONG_MESSAGE: String = "something_went_wrong"
SOMETHING_WENT_WRONG_MESSAGE the key of the message sent to the clients when a remote SSH connection failed
Link copied to clipboard
protected open var usersRepository: R
Link copied to clipboard
val WRONG_EMAIL_MESSAGE: String = "wrong_email"
Link copied to clipboard
val WRONG_HOST_ADDRESS_MESSAGE: String = "wrong_host_address"
WRONG_HOST_ADDRESS_MESSAGE the key of the message sent to the clients when a host address value is not valid
Link copied to clipboard
val WRONG_LANGUAGE_MESSAGE: String = "wrong_language"
Link copied to clipboard
val WRONG_NAME_MESSAGE: String = "wrong_name"
Link copied to clipboard
val WRONG_PASSWORD_MESSAGE: String = "wrong_password"
Link copied to clipboard
val WRONG_PROCEDURE_MESSAGE: String = "wrong_procedure"
Link copied to clipboard
val WRONG_SSH_CREDENTIALS_MESSAGE: String = "ssh_credentials_are_not_valid"
WRONG_SSH_CREDENTIALS_MESSAGE the key of the message sent to the clients when the SSH credentials are not valid
Link copied to clipboard
val WRONG_SURNAME_MESSAGE: String = "wrong_surname"

Functions

Link copied to clipboard
@PatchMapping(path = "/{" + HOST_IDENTIFIER_KEY + "}" )
open fun editHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String, @RequestBody payload: Map<String, Any>): String
Endpoint used to edit an existing host
Link copied to clipboard
protected open fun failedResponse(errorKey: String): String
Link copied to clipboard
Link copied to clipboard
protected open fun getBrownieHostIfAllowed(sessionId: String, hostId: String): BrownieHost
Method to retrieve a BrownieHost checking the identifier of the session and its identifier
Link copied to clipboard
@GetMapping(path = "/{" + HOST_IDENTIFIER_KEY + "}" )
open fun <T> getHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): T
Endpoint used to get an existing host
Link copied to clipboard
@GetMapping(path = ""/{" + HOST_IDENTIFIER_KEY + "}" + OVERVIEW_ENDPOINT" )
open fun <T> getHostOverview(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): T
Endpoint used to retrieve an overview of a host
Link copied to clipboard
@GetMapping
open fun <T> getHosts(@PathVariable(value = "id") sessionId: String, @RequestParam(name = "keywords", defaultValue = "", required = false) keywords: Set<String>, @RequestParam(name = "statuses", defaultValue = "ONLINE, OFFLINE, REBOOTING", required = false) statuses: List<String>, @RequestParam(value = "language", required = false, defaultValue = "en") language: String, @RequestParam(name = "page", defaultValue = "0", required = false) page: Int, @RequestParam(name = "pageSize", defaultValue = "10", required = false) pageSize: Int): T
Endpoint used to retrieve the hosts of a session
Link copied to clipboard
@GetMapping(path = ""/" + STATUS_KEY" )
open fun <T> getHostsStatus(@PathVariable(value = "id") sessionId: String, @RequestParam(name = "hosts", defaultValue = "") hosts: List<String>, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): T
Endpoint used to retrieve the current status of the specified hosts
Link copied to clipboard
protected open fun getInternationalizedMessage(messageKey: String): String
Link copied to clipboard
open fun initEquinoxEnvironment(context: Class<out Any>, args: Array<String>)
Link copied to clipboard
protected open fun isMe(id: String, token: String): Boolean
Link copied to clipboard
protected open fun loadJsonHelper(payload: JSONObject)
Link copied to clipboard
Link copied to clipboard
protected open fun plainResponse(status: ResponseStatus, message: String): String
Link copied to clipboard
@PatchMapping(path = ""/{" + HOST_IDENTIFIER_KEY + "}" + REBOOT_ENDPOINT" )
open fun rebootHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): String
Endpoint used to reboot a host
Link copied to clipboard
@PostMapping
open fun registerHost(@PathVariable(value = "id") sessionId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String, @RequestBody payload: Map<String, Any>): String
Endpoint used to register a new host
Link copied to clipboard
protected open fun sessionExists(sessionId: String): Boolean
Method to check whether a session exists by its id
Link copied to clipboard
protected open fun setSessionLocale(locale: String)
Link copied to clipboard
private open fun SSHCredentialsAreValid(sshUser: String, sshPassword: String): Boolean
Method to validate the payload for the SSH credentials
Link copied to clipboard
@PatchMapping(path = ""/{" + HOST_IDENTIFIER_KEY + "}" + START_ENDPOINT" )
open fun startHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): String
Endpoint used to start a remote host
Link copied to clipboard
@PatchMapping(path = ""/{" + HOST_IDENTIFIER_KEY + "}" + STOP_ENDPOINT" )
open fun stopHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): String
Endpoint used to stop a host
Link copied to clipboard
protected open fun successResponse(): String
protected open fun <V> successResponse(value: V): HashMap<String, V>
Link copied to clipboard
@DeleteMapping(path = "/{" + HOST_IDENTIFIER_KEY + "}" )
open fun unregisterHost(@PathVariable(value = "id") sessionId: String, @PathVariable(value = "host_id") hostId: String, @RequestParam(value = "language", required = false, defaultValue = "en") language: String): String
Endpoint used to unregister a host from the session
Link copied to clipboard
private open fun validateHostPayload(hostName: String, hostAddress: String): String
Method to validate the payload for the registerHost and editHost requests
Link copied to clipboard
protected open fun wrongProcedureResponse(): String