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

camundala.dmn.DmnConfigWriter.scala Maven / Gradle / Ivy

There is a newer version: 1.30.23
Show newest version
package camundala
package dmn

import pme123.camunda.dmn.tester.shared.*
import sttp.client3.*
import sttp.client3.circe.*

import java.net.URLEncoder
import java.nio.charset.StandardCharsets

trait DmnConfigWriter extends DmnTesterHelpers:

  def updateConfig(dmnConfig: DmnConfig, configPath: os.Path): Unit =
    val encodedPath =
      URLEncoder.encode(configPath.relativeTo(projectBasePath).toString, StandardCharsets.UTF_8)
    client.send(
      basicRequest
        .contentType("application/json")
        .body(dmnConfig)
        .put(uri"$apiUrl/dmnConfig?path=$encodedPath")
        .response(asString)
    ).body match
      case Right(_) =>
        println(s"Successfully updated ${dmnConfig.decisionId}")
      case Left(v) => println(s"Problem updating $configPath: \n $v")
    end match
  end updateConfig

end DmnConfigWriter




© 2015 - 2024 Weber Informatics LLC | Privacy Policy