Skip to content

Commit

Permalink
Add new routes for admin-api
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Sep 27, 2023
1 parent bcf112a commit dfd9b0b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
46 changes: 44 additions & 2 deletions daikoku/app/controllers/AdminApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,42 @@ class TranslationsAdminApiController(daa: DaikokuApiAction,
.leftMap(_.flatMap(_._2).map(_.message).mkString(", "))
}

class UsagePlansAdminApiController(daa: DaikokuApiAction,
env: Env,
cc: ControllerComponents)
extends AdminApiController[UsagePlan, UsagePlanId](daa, env, cc) {
override def entityClass = classOf[UsagePlan]
override def entityName: String = "usage-plan"
override def pathRoot: String = s"/admin-api/${entityName}s"
override def entityStore(tenant: Tenant,
ds: DataStore): Repo[UsagePlan, UsagePlanId] =
ds.usagePlanRepo.forTenant(tenant)
override def toJson(entity: UsagePlan): JsValue = entity.asJson
override def fromJson(entity: JsValue): Either[String, UsagePlan] =
UsagePlanFormat
.reads(entity)
.asEither
.leftMap(_.flatMap(_._2).map(_.message).mkString(", "))
}

class SubscriptionDemandsAdminApiController(daa: DaikokuApiAction,
env: Env,
cc: ControllerComponents)
extends AdminApiController[SubscriptionDemand, SubscriptionDemandId](daa, env, cc) {
override def entityClass = classOf[SubscriptionDemand]
override def entityName: String = "subscription-demand"
override def pathRoot: String = s"/admin-api/${entityName}s"
override def entityStore(tenant: Tenant,
ds: DataStore): Repo[SubscriptionDemand, SubscriptionDemandId] =
ds.subscriptionDemandRepo.forTenant(tenant)
override def toJson(entity: SubscriptionDemand): JsValue = entity.asJson
override def fromJson(entity: JsValue): Either[String, SubscriptionDemand] =
SubscriptionDemandFormat
.reads(entity)
.asEither
.leftMap(_.flatMap(_._2).map(_.message).mkString(", "))
}

class AdminApiSwaggerController(
env: Env,
cc: ControllerComponents,
Expand All @@ -518,7 +554,9 @@ class AdminApiSwaggerController(
ctrl11: MessagesAdminApiController,
ctrl12: IssuesAdminApiController,
ctrl13: PostsAdminApiController,
ctrl14: TranslationsAdminApiController
ctrl14: TranslationsAdminApiController,
ctrl15: UsagePlansAdminApiController,
ctrl16: SubscriptionDemandsAdminApiController
) extends AbstractController(cc) {

def schema[A, B <: ValueType](
Expand All @@ -541,7 +579,9 @@ class AdminApiSwaggerController(
schema(ctrl11) ++
schema(ctrl12) ++
schema(ctrl13) ++
schema(ctrl14)
schema(ctrl14) ++
schema(ctrl15) ++
schema(ctrl16) ++

def paths: JsValue =
path(ctrl1) ++
Expand All @@ -558,6 +598,8 @@ class AdminApiSwaggerController(
path(ctrl12) ++
path(ctrl13) ++
path(ctrl14) ++
path(ctrl15) ++
path(ctrl16) ++
ctrl1.pathForIntegrationApi()

def swagger() = Action {
Expand Down
14 changes: 14 additions & 0 deletions daikoku/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,20 @@ PUT /admin-api/translations/:id fr.maif.otoroshi.daikoku
GET /admin-api/translations/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findById(id)
POST /admin-api/translations fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.createEntity()
GET /admin-api/translations fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findAll()

DELETE /admin-api/usage-plans/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.deleteEntity(id)
PATCH /admin-api/usage-plans/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.patchEntity(id)
PUT /admin-api/usage-plans/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.updateEntity(id)
GET /admin-api/usage-plans/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findById(id)
POST /admin-api/usage-plans fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.createEntity()
GET /admin-api/usage-plans fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findAll()

DELETE /admin-api/subscription-demands/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.deleteEntity(id)
PATCH /admin-api/subscription-demands/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.patchEntity(id)
PUT /admin-api/subscription-demands/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.updateEntity(id)
GET /admin-api/subscription-demands/:id fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findById(id)
POST /admin-api/subscription-demands fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.createEntity()
GET /admin-api/subscription-demands fr.maif.otoroshi.daikoku.ctrls.TranslationsAdminApiController.findAll()
###
# summary: get apikey from integration token
# tags:
Expand Down

0 comments on commit dfd9b0b

Please sign in to comment.