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

scala.smithy.rules.EndpointTestExpectation.scala Maven / Gradle / Ivy

There is a newer version: 0.0.32
Show newest version
package smithy.rules

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.bijection
import smithy4s.schema.Schema.string
import smithy4s.schema.Schema.union

/** An endpoint rule-set test expectation describing an expected endpoint or error. */
sealed trait EndpointTestExpectation extends scala.Product with scala.Serializable {
  @inline final def widen: EndpointTestExpectation = this
}
object EndpointTestExpectation extends ShapeTag.Companion[EndpointTestExpectation] {
  val id: ShapeId = ShapeId("smithy.rules", "EndpointTestExpectation")

  val hints: Hints = Hints(
    smithy.api.Documentation("An endpoint rule-set test expectation describing an expected endpoint or error."),
    smithy.api.Unstable(),
    smithy.api.Private(),
  )

  /** A test case expectation resulting in an error. */
  case class ErrorCase(error: String) extends EndpointTestExpectation
  /** A test case expectation resulting in an endpoint. */
  case class EndpointCase(endpoint: EndpointExpectation) extends EndpointTestExpectation

  object ErrorCase {
    val hints: Hints = Hints(
      smithy.api.Documentation("A test case expectation resulting in an error."),
    )
    val schema: Schema[ErrorCase] = bijection(string.addHints(hints), ErrorCase(_), _.error)
    val alt = schema.oneOf[EndpointTestExpectation]("error")
  }
  object EndpointCase {
    val hints: Hints = Hints(
      smithy.api.Documentation("A test case expectation resulting in an endpoint."),
    )
    val schema: Schema[EndpointCase] = bijection(EndpointExpectation.schema.addHints(hints), EndpointCase(_), _.endpoint)
    val alt = schema.oneOf[EndpointTestExpectation]("endpoint")
  }

  implicit val schema: Schema[EndpointTestExpectation] = union(
    ErrorCase.alt,
    EndpointCase.alt,
  ){
    case c: ErrorCase => ErrorCase.alt(c)
    case c: EndpointCase => EndpointCase.alt(c)
  }.withId(id).addHints(hints)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy