com.cognite.sdk.scala.v1.fdm.datamodels.DataModelCreateViewReference.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognite-sdk-scala_2.13 Show documentation
Show all versions of cognite-sdk-scala_2.13 Show documentation
Scala SDK for Cognite Data Fusion.
The newest version!
package com.cognite.sdk.scala.v1.fdm.datamodels
import cats.implicits.toFunctorOps
import com.cognite.sdk.scala.v1.fdm.views.{ViewCreateDefinition, ViewReference}
import io.circe.syntax.EncoderOps
import io.circe.{Decoder, Encoder}
/** Type for a data model to reference a view
*/
trait DataModelCreateViewReference
object DataModelCreateViewReference {
implicit val dataModelViewReferenceEncoder: Encoder[DataModelCreateViewReference] =
Encoder.instance {
case v: ViewCreateDefinition => v.asJson
case v: ViewReference => v.asJson
case e =>
throw new IllegalArgumentException(
s"'${e.getClass.getSimpleName}' is not a valid DataModelViewCreateReference type"
)
}
implicit val dataModelViewReferenceDecoder: Decoder[DataModelCreateViewReference] =
List[Decoder[DataModelCreateViewReference]](
Decoder[ViewCreateDefinition].widen,
Decoder[ViewReference].widen
).reduceLeftOption(_ or _).getOrElse(Decoder[ViewReference].widen)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy