Skip to content

Commit

Permalink
feat: CQDG-850 add manifest download url to config endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
adipaul1981 committed Aug 29, 2024
1 parent f9bbb10 commit 31b9b7d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ HTTP Server information :
- `HTTP_HOST` : Address HTTP server should listen to. Default 0.0.0.0 (all interfaces)
- `HTTP_PORT`: Port HTTP server should listen to. Default 9090

Report Api information :
- `REPORT_API_MANIFEST_URL` : Report Api manifest download URL.

Log configuration :
- `LOG_LEVEL` : Log level. Default WARN.

Expand Down
12 changes: 10 additions & 2 deletions src/main/scala/bio/ferlab/ferload/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ package bio.ferlab.ferload

import bio.ferlab.ferload.FerloadClientConfig.DEVICE

case class Config(auth: AuthConfig, http: HttpConfig, s3Config: S3Config, drsConfig: DrsConfig, ferloadClientConfig: FerloadClientConfig)
case class Config(
auth: AuthConfig,
http: HttpConfig,
s3Config: S3Config,
drsConfig: DrsConfig,
ferloadClientConfig: FerloadClientConfig,
reportApiManifestUrl: Option[String]
)

case class S3Config(
accessKey: Option[String],
Expand Down Expand Up @@ -136,7 +143,8 @@ object Config {
HttpConfig.load(),
S3Config.load(),
DrsConfig.load(),
FerloadClientConfig.load()
FerloadClientConfig.load(),
sys.env.get("REPORT_API_MANIFEST_URL"),
)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ object ConfigEndpoint:
def configServerEndpoint(config: Config): ServerEndpoint[Any, IO] = configEndpoint.serverLogicSuccess(_ => {
if (config.ferloadClientConfig.method == FerloadClientConfig.TOKEN) {
val tokenConfig = TokenConfig(config.auth.realm, config.ferloadClientConfig.clientId, config.ferloadClientConfig.tokenLink.get, config.ferloadClientConfig.tokenHelper)
IO.pure(FerloadConfig(config.ferloadClientConfig.method, None, Some(tokenConfig), None))
IO.pure(FerloadConfig(config.ferloadClientConfig.method, None, Some(tokenConfig), None, config.reportApiManifestUrl))
} else if (config.ferloadClientConfig.method == FerloadClientConfig.PASSWORD) {
val kc = KeycloakConfig(config.auth.authUrl, config.auth.realm, config.ferloadClientConfig.clientId, config.auth.clientId)
IO.pure(FerloadConfig(config.ferloadClientConfig.method, Some(kc), None, None))
IO.pure(FerloadConfig(config.ferloadClientConfig.method, Some(kc), None, None, config.reportApiManifestUrl))
} else if (config.ferloadClientConfig.method == FerloadClientConfig.DEVICE) {
val kc = KeycloakConfig(config.auth.authUrl, config.auth.realm, config.auth.clientId, config.auth.audience.get)
val clientConfig = ClientConfig(`manifest-file-pointer` = "File ID", `manifest-filename` = "File Name", `manifest-size` = "File Size")
IO.pure(FerloadConfig(config.ferloadClientConfig.method, Some(kc), None, Some(clientConfig)))
IO.pure(FerloadConfig(config.ferloadClientConfig.method, Some(kc), None, Some(clientConfig), config.reportApiManifestUrl))
}
else {
IO.raiseError(new IllegalStateException(s"Invalid configuration type ${config.ferloadClientConfig.method}"))
Expand Down
10 changes: 8 additions & 2 deletions src/main/scala/bio/ferlab/ferload/model/FerloadConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import sttp.tapir.Schema.annotations.encodedName

import scala.annotation.targetName

case class FerloadConfig(method: String, keycloak: Option[KeycloakConfig], tokenConfig: Option[TokenConfig], clientConfig: Option[ClientConfig])
case class FerloadConfig(
method: String,
keycloak: Option[KeycloakConfig],
tokenConfig: Option[TokenConfig],
clientConfig: Option[ClientConfig],
reportApiManifestUrl: Option[String]
)

case class KeycloakConfig(url: String, realm: String, `client-id`: String, audience: String)

Expand All @@ -18,4 +24,4 @@ case class ClientConfig(
`download-files-pool`: Int = 10,
`download-agreement`: String = "yes",
`size-estimation-timeout`: Int = 60
)
)

0 comments on commit 31b9b7d

Please sign in to comment.