forked from Normation/rudder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroupsInternalAPI.scala
47 lines (39 loc) · 1.51 KB
/
GroupsInternalAPI.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
package com.normation.rudder.rest.internal
import com.normation.errors.IOResult
import com.normation.rudder.api.ApiVersion
import com.normation.rudder.apidata.JsonResponseObjects.*
import com.normation.rudder.facts.nodes.QueryContext
import com.normation.rudder.repository.RoNodeGroupRepository
import com.normation.rudder.rest.ApiModuleProvider
import com.normation.rudder.rest.ApiPath
import com.normation.rudder.rest.AuthzToken
import com.normation.rudder.rest.GroupInternalApi as API
import com.normation.rudder.rest.implicits.*
import com.normation.rudder.rest.lift.*
import net.liftweb.http.Req
class GroupsInternalApi(
groupsInternalApiService: GroupsInternalApiService
) extends LiftApiModuleProvider[API] {
def schemas: ApiModuleProvider[API] = API
def getLiftEndpoints(): List[LiftApiModule] = {
API.endpoints.map(e => {
e match {
case API.GetGroupCategoryTree => GetGroupCategoryTree
}
})
}
object GetGroupCategoryTree extends LiftApiModule0 {
val schema: API.GetGroupCategoryTree.type = API.GetGroupCategoryTree
def process0(version: ApiVersion, path: ApiPath, req: Req, params: DefaultParams, authzToken: AuthzToken): LiftResponse = {
implicit val qc: QueryContext = authzToken.qc
groupsInternalApiService.getGroupCategoryTree().toLiftResponseOne(params, schema, _ => None)
}
}
}
class GroupsInternalApiService(
readGroup: RoNodeGroupRepository
) {
def getGroupCategoryTree()(implicit qc: QueryContext): IOResult[JRGroupCategoryInfo] = {
???
}
}