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

smithy.api.AuthDefinition.scala Maven / Gradle / Ivy

There is a newer version: 0.19.0-41-91762fb
Show newest version
package smithy.api

import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.recursive
import smithy4s.schema.Schema.struct

/** Marks a trait as an auth scheme defining trait.
  * 
  * The targeted trait must only be applied to service shapes or operation
  * shapes, must be a structure, and must have the `trait` trait.
  * @param traits
  *   The list of traits that auth implementations must understand in order
  *   to successfully use the scheme.
  */
final case class AuthDefinition(traits: Option[List[TraitShapeId]] = None)

object AuthDefinition extends ShapeTag.Companion[AuthDefinition] {
  val id: ShapeId = ShapeId("smithy.api", "authDefinition")

  val hints: Hints = Hints(
    smithy.api.Documentation("Marks a trait as an auth scheme defining trait.\n\nThe targeted trait must only be applied to service shapes or operation\nshapes, must be a structure, and must have the `trait` trait."),
    smithy.api.Trait(selector = Some("structure[trait|trait]"), structurallyExclusive = None, conflicts = None, breakingChanges = Some(List(smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.PRESENCE.widen, severity = smithy.api.Severity.ERROR.widen, path = None, message = None)))),
  ).lazily

  // constructor using the original order from the spec
  private def make(traits: Option[List[TraitShapeId]]): AuthDefinition = AuthDefinition(traits)

  implicit val schema: Schema[AuthDefinition] = recursive(struct(
    TraitShapeIdList.underlyingSchema.optional[AuthDefinition]("traits", _.traits).addHints(smithy.api.Documentation("The list of traits that auth implementations must understand in order\nto successfully use the scheme.")),
  )(make).withId(id).addHints(hints))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy