smithy.api.Reference.scala Maven / Gradle / Ivy
package smithy.api
import smithy4s.Hints
import smithy4s.Schema
import smithy4s.ShapeId
import smithy4s.ShapeTag
import smithy4s.schema.Schema.struct
/** @param resource
* The shape ID of the referenced resource.
* @param ids
* Defines a mapping of each resource identifier name to a structure member
* name that provides its value. Each key in the map MUST refer to one of the
* identifier names in the identifiers property of the resource, and each
* value in the map MUST refer to a valid structure member name that targets
* a string shape.
* @param service
* Providing a service makes the reference specific to a particular binding
* of the resource to a service. When omitted, the reference is late-bound to
* a service, meaning the reference is assumed to be a reference to the
* resource bound to the service currently in use by the client or server.
* @param rel
* Defines the semantics of the relationship. The rel property SHOULD
* contain a link relation as defined in RFC 5988#section-4.
*/
final case class Reference(resource: NonEmptyString, ids: Option[Map[NonEmptyString, NonEmptyString]] = None, service: Option[NonEmptyString] = None, rel: Option[NonEmptyString] = None)
object Reference extends ShapeTag.Companion[Reference] {
val id: ShapeId = ShapeId("smithy.api", "Reference")
val hints: Hints = Hints(
smithy.api.Private(),
).lazily
// constructor using the original order from the spec
private def make(resource: NonEmptyString, ids: Option[Map[NonEmptyString, NonEmptyString]], service: Option[NonEmptyString], rel: Option[NonEmptyString]): Reference = Reference(resource, ids, service, rel)
implicit val schema: Schema[Reference] = struct(
NonEmptyString.schema.required[Reference]("resource", _.resource).addHints(smithy.api.Documentation("The shape ID of the referenced resource.")),
NonEmptyStringMap.underlyingSchema.optional[Reference]("ids", _.ids).addHints(smithy.api.Documentation("Defines a mapping of each resource identifier name to a structure member\nname that provides its value. Each key in the map MUST refer to one of the\nidentifier names in the identifiers property of the resource, and each\nvalue in the map MUST refer to a valid structure member name that targets\na string shape.")),
NonEmptyString.schema.optional[Reference]("service", _.service).addHints(smithy.api.Documentation("Providing a service makes the reference specific to a particular binding\nof the resource to a service. When omitted, the reference is late-bound to\na service, meaning the reference is assumed to be a reference to the\nresource bound to the service currently in use by the client or server.")),
NonEmptyString.schema.optional[Reference]("rel", _.rel).addHints(smithy.api.Documentation("Defines the semantics of the relationship. The rel property SHOULD\ncontain a link relation as defined in RFC 5988#section-4.")),
)(make).withId(id).addHints(hints)
}