Skip to content

Commit

Permalink
new endpoints for docker machines
Browse files Browse the repository at this point in the history
  • Loading branch information
NiHaiden committed Oct 10, 2023
1 parent e841c63 commit 4d43508
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import java.lang.Exception
class MachineAlreadyExistsException: Exception {
constructor() : super()
constructor(message: String): super(message)
}
}
20 changes: 16 additions & 4 deletions src/main/kotlin/tech/niklas/ariesbackend/web/MachineController.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package tech.niklas.ariesbackend.web

import org.springframework.data.crossstore.ChangeSetPersister.NotFoundException
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import org.springframework.web.server.ResponseStatusException
import tech.niklas.ariesbackend.db.DockerMachineRepository
import tech.niklas.ariesbackend.exception.MachineAlreadyExistsException
import tech.niklas.ariesbackend.model.DockerMachine
import kotlin.jvm.optionals.getOrElse
import kotlin.jvm.optionals.getOrNull

@RestController
@RequestMapping("/machine")
Expand All @@ -21,5 +21,17 @@ class MachineController(private val dockerMachineRepository: DockerMachineReposi
return dockerMachineRepository.save(dockerMachine)
}

@GetMapping("/get")
fun getAll(): List<DockerMachine> {
return dockerMachineRepository.findAll()
}

@GetMapping("/get/{id}")
fun getSpecificMachine(@PathVariable id: String): DockerMachine {
return dockerMachineRepository.findById(id).getOrElse {
throw MachineAlreadyExistsException("not found lol")
}
}


}

0 comments on commit 4d43508

Please sign in to comment.