From 548496701724ea1f728ab450e277ddc85f482eaf Mon Sep 17 00:00:00 2001 From: Brian Schlining Date: Fri, 16 Aug 2024 16:37:08 -0700 Subject: [PATCH] Wire in the media endpoints --- .../oni/endpoints/MediaEndpointsSuite.scala | 2 +- .../main/scala/org/mbari/oni/Endpoints.scala | 17 +++-------------- .../mbari/oni/endpoints/MediaEndpoints.scala | 4 ++-- .../oni/endpoints/UserAccountEndpoints.scala | 2 +- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/it/src/main/scala/org/mbari/oni/endpoints/MediaEndpointsSuite.scala b/it/src/main/scala/org/mbari/oni/endpoints/MediaEndpointsSuite.scala index 1868c53..baa7b7b 100644 --- a/it/src/main/scala/org/mbari/oni/endpoints/MediaEndpointsSuite.scala +++ b/it/src/main/scala/org/mbari/oni/endpoints/MediaEndpointsSuite.scala @@ -32,7 +32,7 @@ trait MediaEndpointsSuite extends EndpointsSuite with DataInitializer with UserA given jwtService: JwtService = JwtService("mbari", "foo", "bar") lazy val fastPhylogenyService = FastPhylogenyService(entityManagerFactory) - lazy val endpoints: MediaEndpoints = MediaEndpoints(entityManagerFactory, fastPhylogenyService, conceptService) + lazy val endpoints: MediaEndpoints = MediaEndpoints(entityManagerFactory, fastPhylogenyService) private val password = Strings.random(10) def createMedia(): Seq[Media] = { diff --git a/oni/src/main/scala/org/mbari/oni/Endpoints.scala b/oni/src/main/scala/org/mbari/oni/Endpoints.scala index 012c078..d82d831 100644 --- a/oni/src/main/scala/org/mbari/oni/Endpoints.scala +++ b/oni/src/main/scala/org/mbari/oni/Endpoints.scala @@ -8,26 +8,13 @@ package org.mbari.oni import jakarta.persistence.EntityManagerFactory -import org.mbari.oni.endpoints.{ - AuthorizationEndpoints, - ConceptEndpoints, - ConceptNameEndpoints, - HealthEndpoints, - HistoryEndpoints, - LinkEndpoints, - PhylogenyEndpoints, - PrefNodeEndpoints, - ReferenceEndpoints, - UserAccountEndpoints -} +import org.mbari.oni.endpoints.{AuthorizationEndpoints, ConceptEndpoints, ConceptNameEndpoints, HealthEndpoints, HistoryEndpoints, LinkEndpoints, LinkRealizationEndpoints, LinkTemplateEndpoints, MediaEndpoints, PhylogenyEndpoints, PrefNodeEndpoints, ReferenceEndpoints, UserAccountEndpoints} import org.mbari.oni.etc.jwt.JwtService import org.mbari.oni.jdbc.FastPhylogenyService import sttp.tapir.server.ServerEndpoint import sttp.tapir.server.metrics.prometheus.PrometheusMetrics import sttp.shared.Identity import sttp.tapir.swagger.bundle.SwaggerInterpreter -import org.mbari.oni.endpoints.LinkRealizationEndpoints -import org.mbari.oni.endpoints.LinkTemplateEndpoints import java.util.concurrent.Executors import scala.concurrent.{ExecutionContext, Future} @@ -56,6 +43,7 @@ object Endpoints: val linkEndpoints: LinkEndpoints = LinkEndpoints(entityMangerFactory) val linkRealizationEndpoints: LinkRealizationEndpoints = LinkRealizationEndpoints(entityMangerFactory) val linkTemplateEndpoints: LinkTemplateEndpoints = LinkTemplateEndpoints(entityMangerFactory) + val mediaEndpoints: MediaEndpoints = MediaEndpoints(entityMangerFactory, phylogenyEndpoints.service) val prefNodeEndpoints: PrefNodeEndpoints = PrefNodeEndpoints(entityMangerFactory) val referenceEndpoints: ReferenceEndpoints = ReferenceEndpoints(entityMangerFactory) val userAccountEndpoints: UserAccountEndpoints = UserAccountEndpoints(entityMangerFactory) @@ -69,6 +57,7 @@ object Endpoints: linkEndpoints, linkRealizationEndpoints, linkTemplateEndpoints, + mediaEndpoints, phylogenyEndpoints, prefNodeEndpoints, referenceEndpoints, diff --git a/oni/src/main/scala/org/mbari/oni/endpoints/MediaEndpoints.scala b/oni/src/main/scala/org/mbari/oni/endpoints/MediaEndpoints.scala index 03c4fd4..ae326e4 100644 --- a/oni/src/main/scala/org/mbari/oni/endpoints/MediaEndpoints.scala +++ b/oni/src/main/scala/org/mbari/oni/endpoints/MediaEndpoints.scala @@ -26,10 +26,10 @@ import scala.concurrent.Future import org.mbari.oni.etc.jwt.JwtService class MediaEndpoints(entityManagerFactory: EntityManagerFactory, - fastPhylogenyService: FastPhylogenyService, - conceptService: ConceptService)(using jwtService: JwtService, executionContext: ExecutionContext) extends Endpoints: + fastPhylogenyService: FastPhylogenyService)(using jwtService: JwtService, executionContext: ExecutionContext) extends Endpoints: private val service = MediaService(entityManagerFactory, fastPhylogenyService) + private val conceptService = ConceptService(entityManagerFactory) private val base = "media" private val tag = "Media" diff --git a/oni/src/main/scala/org/mbari/oni/endpoints/UserAccountEndpoints.scala b/oni/src/main/scala/org/mbari/oni/endpoints/UserAccountEndpoints.scala index 7cfd69f..3b44e0f 100644 --- a/oni/src/main/scala/org/mbari/oni/endpoints/UserAccountEndpoints.scala +++ b/oni/src/main/scala/org/mbari/oni/endpoints/UserAccountEndpoints.scala @@ -94,7 +94,7 @@ class UserAccountEndpoints(entityManagerFactory: EntityManagerFactory)(using jwt secureEndpoint .post .in(base) - .in(oneOfBody(jsonBody[UserAccountCreate], formBody[UserAccountCreate])) + .in(oneOfBody(jsonBody[UserAccountCreate].description("The user account to create. Accepts camelCase or snake_case."), formBody[UserAccountCreate].description("The user account to create. Accepts camelCase or snake_case."))) .out(jsonBody[UserAccount]) .name("createUserAccount") .description("Create a new user account")