/
RoleRepo.scala
53 lines (45 loc) · 1.24 KB
/
RoleRepo.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright © 2021 - 2022 Data and Service Center for the Humanities and/or DaSCH Service Platform contributors.
* SPDX-License-Identifier: Apache-2.0
*/
package dsp.role.api
import dsp.role.domain.Role
import dsp.valueobjects.Id._
import zio._
import zio.macros.accessible
/**
* The trait (interface) for the role repository.
* The role repository is responsible for storing and retrieving roles.
* Needs to be used by the role repository implementations.
*/
@accessible
trait RoleRepo {
/**
* Writes a role into the repository, while both creating or updating a role.
*
* @param r the role to write
* @return Unit
*/
def storeRole(r: Role): UIO[RoleId]
/**
* Gets all roles from teh repository.
*
* @return a list of [[Role]]
*/
def getRoles(): UIO[List[Role]]
/**
* Retrieves the role frim the repository.
*
* @param id the role's ID
* @return the [[Role]] if found
*/
def getRoleById(id: RoleId): IO[Option[Nothing], Role]
// should the role name be unique like username???
/**
* Deletes the [[Role]] from the repository by its [[RoleId]]
*
* @param id the role ID
* @return the [[RoleId]] deleted role, if found
*/
def deleteRole(id: RoleId): IO[Option[Nothing], RoleId]
}