Skip to content

Commit

Permalink
merge master, fix dependencies and conclude server implicit implement…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
TebaleloS committed Jun 21, 2024
1 parent eb77ba5 commit f6d2ece
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 125 deletions.
28 changes: 21 additions & 7 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ object Dependencies {
val balta = "0.1.0"

val jacksonModuleScala = "2.14.2"
val circeVersion = "0.14.5"

val specs2 = "4.10.0"
val typesafeConfig = "1.4.2"
Expand Down Expand Up @@ -76,7 +75,8 @@ object Dependencies {
val http4sPrometheus = "0.23.6"
val playJson = "3.0.1"
val sttpPlayJson = "3.9.3"
val sttpCirceJson = "4.0.0-M16"
val circeJson = "0.14.7"
val sttpCirceJson = "3.9.7"

val awssdk = "2.23.15"

Expand Down Expand Up @@ -117,8 +117,10 @@ object Dependencies {
lazy val json4sJackson = "org.json4s" %% "json4s-jackson" % json4sVersion
lazy val json4sNative = "org.json4s" %% "json4s-native" % json4sVersion % Provided

lazy val circeCore = "io.circe" %% "circe-core" % Versions.circeVersion
lazy val circeParser = "io.circe" %% "circe-parser" % Versions.circeVersion
// Circe dependencies
lazy val circeCore = "io.circe" %% "circe-core" % Versions.circeJson
lazy val circeParser = "io.circe" %% "circe-parser" % Versions.circeJson
lazy val circeGeneric = "io.circe" %% "circe-generic" % Versions.circeJson

Seq(
jacksonModuleScala,
Expand All @@ -128,6 +130,7 @@ object Dependencies {
json4sNative,
circeCore,
circeParser,
circeGeneric,
)
}

Expand All @@ -141,7 +144,6 @@ object Dependencies {
val logbackOrg = "ch.qos.logback"
val awsSdkOrg = "software.amazon.awssdk"
val sttpClient3Org = "com.softwaremill.sttp.client3"
val sttpClient4Org = "com.softwaremill.sttp.client4"

// zio
lazy val zioCore = zioOrg %% "zio" % Versions.zio
Expand All @@ -165,11 +167,21 @@ object Dependencies {
lazy val tapirPrometheus = tapirOrg %% "tapir-prometheus-metrics" % Versions.tapir
lazy val tapirStubServer = tapirOrg %% "tapir-sttp-stub-server" % Versions.tapir % Test

lazy val tapirCirce = tapirOrg %% "tapir-json-circe" % Versions.tapir
lazy val tapirOpenApiDocs = tapirOrg %% "tapir-openapi-docs" % Versions.tapir
lazy val tapirOpenApiCirceYaml = tapirOrg %% "tapir-openapi-circe-yaml" % Versions.tapir
lazy val tapirHttp4sServer = tapirOrg %% "tapir-http4s-server" % Versions.tapir
lazy val tapirCore = tapirOrg %% "tapir-core" % Versions.tapir
lazy val tapirSwaggerUi = tapirOrg %% "tapir-swagger-ui-http4s" % Versions.tapir

// json
lazy val playJson = playOrg %% "play-json" % Versions.playJson
lazy val sttpPlayJson = sttpClient3Org %% "play-json" % Versions.sttpPlayJson % Test
lazy val sttpCirceJson = sttpClient4Org %% "circe" % Versions.sttpCirceJson % Test

// STTP core and Circe integration
lazy val sttpCirce = sttpClient3Org %% "circe" % Versions.sttpCirceJson % Test
lazy val sttpCore = sttpClient3Org %% "core" % Versions.sttpCirceJson
lazy val clientBackend = sttpClient3Org %% "async-http-client-backend-zio" % Versions.sttpCirceJson

// Fa-db
lazy val faDbDoobie = faDbOrg %% "doobie" % Versions.fadb
Expand Down Expand Up @@ -201,11 +213,13 @@ object Dependencies {
tapirHttp4sZio,
tapirSwagger,
tapirPlayJson,
tapirCirce,
tapirPrometheus,
tapirStubServer,
playJson,
sttpPlayJson,
sttpCirceJson,
sttpCirce,
sttpCore,
awsSecretsManagerSdk,
zioTest,
zioTestSbt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package za.co.absa.atum.server.api.controller

import za.co.absa.atum.server.api.exception.ServiceError
import za.co.absa.atum.server.model.ErrorResponse.{ErrorResponse, GeneralErrorResponse, InternalServerErrorResponse}
import za.co.absa.atum.server.model.{ErrorResponse, GeneralErrorResponse, InternalServerErrorResponse}
import za.co.absa.atum.server.model.SuccessResponse.{MultiSuccessResponse, SingleSuccessResponse}
import za.co.absa.fadb.exceptions.StatusException
import zio._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package za.co.absa.atum.server.api.controller

import za.co.absa.atum.model.dto.CheckpointDTO
import za.co.absa.atum.server.model.ErrorResponse.ErrorResponse
import za.co.absa.atum.server.model.ErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.SingleSuccessResponse
import zio.IO
import zio.macros.accessible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package za.co.absa.atum.server.api.controller

import za.co.absa.atum.model.dto.CheckpointDTO
import za.co.absa.atum.server.api.service.CheckpointService
import za.co.absa.atum.server.model.ErrorResponse.ErrorResponse
import za.co.absa.atum.server.model.ErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.SingleSuccessResponse
import zio._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package za.co.absa.atum.server.api.controller

import za.co.absa.atum.model.dto.{CheckpointDTO, CheckpointQueryDTO}
import za.co.absa.atum.server.model.ErrorResponse.ErrorResponse
import za.co.absa.atum.server.model.ErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.MultiSuccessResponse
import zio.IO
import zio.macros.accessible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package za.co.absa.atum.server.api.controller

import za.co.absa.atum.model.dto.{CheckpointDTO, CheckpointQueryDTO}
import za.co.absa.atum.server.api.service.FlowService
import za.co.absa.atum.server.model.ErrorResponse.ErrorResponse
import za.co.absa.atum.server.model.ErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.MultiSuccessResponse
import zio._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import za.co.absa.atum.model.dto.{
CheckpointQueryDTO,
PartitioningSubmitDTO
}
import za.co.absa.atum.server.model.ErrorResponse.ErrorResponse
import za.co.absa.atum.server.model.ErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.{MultiSuccessResponse, SingleSuccessResponse}
import zio.IO
import zio.macros.accessible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package za.co.absa.atum.server.api.controller
import za.co.absa.atum.model.dto._
import za.co.absa.atum.server.api.exception.ServiceError
import za.co.absa.atum.server.api.service.PartitioningService
import za.co.absa.atum.server.model.ErrorResponse.{ErrorResponse, InternalServerErrorResponse}
import za.co.absa.atum.server.model.{ErrorResponse, InternalServerErrorResponse}
import za.co.absa.atum.server.model.SuccessResponse.{MultiSuccessResponse, SingleSuccessResponse}
import zio._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import za.co.absa.fadb.status.handling.implementations.StandardStatusHandling
import zio._
import zio.interop.catz._
import io.circe.syntax._
import io.circe.generic.auto._

import doobie.postgres.implicits._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import za.co.absa.atum.server.api.database.runs.Runs
import zio._
import zio.interop.catz._
import io.circe.syntax._
import io.circe.generic.auto._

class CreatePartitioningIfNotExists(implicit schema: DBSchema, dbEngine: DoobieEngine[Task])
extends DoobieSingleResultFunctionWithStatus[PartitioningSubmitDTO, Unit, Task]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import za.co.absa.fadb.doobie.DoobieEngine
import zio.interop.catz.asyncInstance
import zio.{Task, URLayer, ZIO, ZLayer}
import io.circe.syntax._
import io.circe.generic.auto._

import za.co.absa.atum.server.api.database.DoobieImplicits.getMapWithOptionStringValues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import za.co.absa.fadb.doobie.DoobieFunction.DoobieMultipleResultFunction
import zio._
import zio.interop.catz._
import io.circe.syntax._
import io.circe.generic.auto._

import za.co.absa.atum.server.api.database.DoobieImplicits.Sequence.get
import doobie.postgres.circe.jsonb.implicits.jsonbGet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import za.co.absa.atum.server.api.database.runs.Runs
import zio._
import zio.interop.catz._
import io.circe.syntax._
import io.circe.generic.auto._

import za.co.absa.atum.server.api.database.DoobieImplicits.Sequence.get

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,58 @@ import za.co.absa.atum.server.model.SuccessResponse.{MultiSuccessResponse, Singl
import za.co.absa.atum.server.model.CirceJsonImplicits._
import sttp.tapir.{PublicEndpoint, endpoint}


trait Endpoints extends BaseEndpoints {

protected val createCheckpointEndpointV1
: PublicEndpoint[CheckpointDTO, ErrorResponse, CheckpointDTO, Any] = {
protected val createCheckpointEndpointV1: PublicEndpoint[CheckpointDTO, ErrorResponse, CheckpointDTO, Any] = {
apiV1.post
.in(pathToAPIv1CompatibleFormat(CreateCheckpoint))
.in(jsonBody[CheckpointDTO])
.out(statusCode(StatusCode.Created))
.out(jsonBody[CheckpointDTO])
}

protected val createCheckpointEndpointV2
: PublicEndpoint[CheckpointDTO, ErrorResponse, SingleSuccessResponse[CheckpointDTO], Any] = {
protected val createCheckpointEndpointV2: PublicEndpoint[CheckpointDTO, ErrorResponse, SingleSuccessResponse[CheckpointDTO], Any] = {
apiV2.post
.in(CreateCheckpoint)
.in(jsonBody[CheckpointDTO])
.out(statusCode(StatusCode.Created))
.out(jsonBody[SingleSuccessResponse[CheckpointDTO]])
}

protected val createPartitioningEndpointV1
: PublicEndpoint[PartitioningSubmitDTO, ErrorResponse, AtumContextDTO, Any] = {
protected val createPartitioningEndpointV1: PublicEndpoint[PartitioningSubmitDTO, ErrorResponse, AtumContextDTO, Any] = {
apiV1.post
.in(pathToAPIv1CompatibleFormat(CreatePartitioning))
.in(jsonBody[PartitioningSubmitDTO])
.out(statusCode(StatusCode.Ok))
.out(jsonBody[AtumContextDTO])
}

protected val createPartitioningEndpointV2
: PublicEndpoint[PartitioningSubmitDTO, ErrorResponse, SingleSuccessResponse[AtumContextDTO], Any] = {
protected val createPartitioningEndpointV2: PublicEndpoint[PartitioningSubmitDTO, ErrorResponse, SingleSuccessResponse[AtumContextDTO], Any] = {
apiV2.post
.in(CreatePartitioning)
.in(jsonBody[PartitioningSubmitDTO])
.out(statusCode(StatusCode.Ok))
.out(jsonBody[SingleSuccessResponse[AtumContextDTO]])
}

protected val createOrUpdateAdditionalDataEndpointV2
: PublicEndpoint[AdditionalDataSubmitDTO, ErrorResponse, SingleSuccessResponse[AdditionalDataSubmitDTO], Any] = {
protected val createOrUpdateAdditionalDataEndpointV2: PublicEndpoint[AdditionalDataSubmitDTO, ErrorResponse, SingleSuccessResponse[AdditionalDataSubmitDTO], Any] = {
apiV2.post
.in(CreateOrUpdateAdditionalData)
.in(jsonBody[AdditionalDataSubmitDTO])
.out(statusCode(StatusCode.Ok))
.out(jsonBody[SingleSuccessResponse[AdditionalDataSubmitDTO]])
}

protected val getPartitioningCheckpointsEndpointV2
: PublicEndpoint[CheckpointQueryDTO, ErrorResponse, MultiSuccessResponse[CheckpointDTO], Any] = {
protected val getPartitioningCheckpointsEndpointV2: PublicEndpoint[CheckpointQueryDTO, ErrorResponse, MultiSuccessResponse[CheckpointDTO], Any] = {
apiV2.get
.in(GetPartitioningCheckpoints)
.in(jsonBody[CheckpointQueryDTO])
.out(statusCode(StatusCode.Ok))
.out(jsonBody[MultiSuccessResponse[CheckpointDTO]])
}

protected val getFlowCheckpointsEndpointV2
: PublicEndpoint[CheckpointQueryDTO, ErrorResponse, MultiSuccessResponse[CheckpointDTO], Any] = {
protected val getFlowCheckpointsEndpointV2: PublicEndpoint[CheckpointQueryDTO, ErrorResponse, MultiSuccessResponse[CheckpointDTO], Any] = {
apiV2.post
.in(GetFlowCheckpoints)
.in(jsonBody[CheckpointQueryDTO])
Expand All @@ -100,5 +94,4 @@ trait Endpoints extends BaseEndpoints {

protected val healthEndpoint: PublicEndpoint[Unit, Unit, Unit, Any] =
endpoint.get.in(Health)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

package za.co.absa.atum.server.model

import io.circe._, io.circe.generic.semiauto._
import za.co.absa.atum.model.dto.MeasureResultDTO.{ResultValueType, TypedValue}
import io.circe._
import io.circe.generic.semiauto._
import za.co.absa.atum.model.dto.MeasureResultDTO.ResultValueType
import za.co.absa.atum.model.dto._

object CirceJsonImplicits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,6 @@

package za.co.absa.atum.server.model

//import play.api.libs.json.{Json, Reads, Writes}
//
//sealed trait ErrorResponse {
// def message: String
//}
//
//object ErrorResponse {
// implicit val reads: Reads[ErrorResponse] = Json.reads[ErrorResponse]
// implicit val writes: Writes[ErrorResponse] = Json.writes[ErrorResponse]
//}
//
//final case class BadRequestResponse(message: String) extends ErrorResponse
//
//object BadRequestResponse {
// implicit val reads: Reads[BadRequestResponse] = Json.reads[BadRequestResponse]
// implicit val writes: Writes[BadRequestResponse] = Json.writes[BadRequestResponse]
//}
//
//final case class GeneralErrorResponse(message: String) extends ErrorResponse
//
//object GeneralErrorResponse {
// implicit val reads: Reads[GeneralErrorResponse] = Json.reads[GeneralErrorResponse]
// implicit val writes: Writes[GeneralErrorResponse] = Json.writes[GeneralErrorResponse]
//}
//
//final case class InternalServerErrorResponse(message: String) extends ErrorResponse
//
//object InternalServerErrorResponse {
// implicit val reads: Reads[InternalServerErrorResponse] = Json.reads[InternalServerErrorResponse]
// implicit val writes: Writes[InternalServerErrorResponse] = Json.writes[InternalServerErrorResponse]
//}

import io.circe._
import io.circe.generic.semiauto._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,11 @@

package za.co.absa.atum.server.model

//import play.api.libs.json.{Json, Writes}
//import za.co.absa.atum.model.dto.PartitioningDTO
//
//private[server] case class PartitioningForDB private (
// version: Int = 1,
// keys: Seq[String],
// keysToValues: Map[String, String]
//)
//
//object PartitioningForDB {
//
// def fromSeqPartitionDTO(partitioning: PartitioningDTO): PartitioningForDB = {
// val allKeys = partitioning.map(_.key)
// val mapOfKeysAndValues = partitioning.map(p => p.key -> p.value).toMap[String, String]
//
// PartitioningForDB(keys = allKeys, keysToValues = mapOfKeysAndValues)
// }
//
// implicit val writes: Writes[PartitioningForDB] = Json.writes
//
//}

import io.circe._, io.circe.generic.semiauto._

import io.circe.generic.semiauto._
import io.circe.{Decoder, Encoder}
import za.co.absa.atum.model.dto.PartitioningDTO
import scala.collection.immutable.Seq

private[server] case class PartitioningForDB private (
version: Int = 1,
Expand All @@ -50,12 +31,12 @@ private[server] case class PartitioningForDB private (
object PartitioningForDB {

def fromSeqPartitionDTO(partitioning: PartitioningDTO): PartitioningForDB = {
val allKeys = partitioning.map(_.key)
val mapOfKeysAndValues = partitioning.map(p => p.key -> p.value).toMap[String, String]
val allKeys: Seq[String] = partitioning.map(_.key)
val mapOfKeysAndValues: Map[String, String] = partitioning.map(p => p.key -> p.value).toMap

PartitioningForDB(keys = allKeys, keysToValues = mapOfKeysAndValues)
}

implicit val encodePartitioningForDB: Encoder[PartitioningForDB] = deriveEncoder

implicit val encoder: Encoder[PartitioningForDB] = deriveEncoder
implicit val decoder: Decoder[PartitioningForDB] = deriveDecoder
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.mockito.Mockito.{mock, when}
import za.co.absa.atum.server.api.TestData
import za.co.absa.atum.server.api.exception.ServiceError
import za.co.absa.atum.server.api.service.CheckpointService
import za.co.absa.atum.server.model.ErrorResponse.{GeneralErrorResponse, InternalServerErrorResponse}
import za.co.absa.atum.server.model.{GeneralErrorResponse, InternalServerErrorResponse}
import za.co.absa.fadb.exceptions.ErrorInDataException
import za.co.absa.fadb.status.FunctionStatus
import zio.test.Assertion.failsWithA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.mockito.Mockito.{mock, when}
import za.co.absa.atum.server.api.TestData
import za.co.absa.atum.server.api.exception.ServiceError
import za.co.absa.atum.server.api.service.FlowService
import za.co.absa.atum.server.model.ErrorResponse.InternalServerErrorResponse
import za.co.absa.atum.server.model.InternalServerErrorResponse
import zio._
import zio.test.Assertion.failsWithA
import zio.test._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import za.co.absa.atum.model.dto.CheckpointDTO
import za.co.absa.atum.server.api.TestData
import za.co.absa.atum.server.api.exception.ServiceError
import za.co.absa.atum.server.api.service.PartitioningService
import za.co.absa.atum.server.model.ErrorResponse.InternalServerErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.{MultiSuccessResponse, SingleSuccessResponse}
import za.co.absa.atum.server.model.InternalServerErrorResponse
import za.co.absa.atum.server.model.SuccessResponse.SingleSuccessResponse
import zio._
import zio.test.Assertion.{equalTo, failsWithA}
import zio.test._
Expand Down
Loading

0 comments on commit f6d2ece

Please sign in to comment.