All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.touk.nussknacker.engine.deployment.DeploymentId.scala Maven / Gradle / Ivy

The newest version!
package pl.touk.nussknacker.engine.deployment

import io.circe.generic.extras.semiauto.{deriveUnwrappedDecoder, deriveUnwrappedEncoder}
import io.circe.{Decoder, Encoder}
import pl.touk.nussknacker.engine.api.deployment.ProcessActionId
import pl.touk.nussknacker.engine.newdeployment

import java.util.UUID
import scala.util.Try

//id generated by Nussknacker - in contrary to ExternalDeploymentId which is generated by e.g. Flink
// TODO: This class will be replaced by DeploymentId from newdeployment package, see docs in newdeployment.DeploymentService
final case class DeploymentId(value: String) extends AnyVal {
  override def toString: String = value

  def toActionIdOpt: Option[ProcessActionId] = Try(UUID.fromString(value)).toOption.map(ProcessActionId(_))

  def toNewDeploymentIdOpt: Option[newdeployment.DeploymentId] =
    Try(UUID.fromString(value)).toOption.map(newdeployment.DeploymentId(_))

}

object DeploymentId {
  implicit val encoder: Encoder[DeploymentId] = deriveUnwrappedEncoder
  implicit val decoder: Decoder[DeploymentId] = deriveUnwrappedDecoder

  def fromActionId(actionId: ProcessActionId): DeploymentId = DeploymentId(actionId.toString)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy