smithy.api.Paginated.scala Maven / Gradle / Ivy
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
/** The paginated trait indicates that an operation intentionally limits the
* number of results returned in a single response and that multiple
* invocations might be necessary to retrieve all results.
* @param inputToken
* The name of the operation input member that represents the continuation
* token.
*
* When this value is provided as operation input, the service returns
* results from where the previous response left off. This input member
* MUST NOT be required and MUST target a string shape.
* @param outputToken
* The name of the operation output member that represents the
* continuation token.
*
* When this value is present in operation output, it indicates that there
* are more results to retrieve. To get the next page of results, the
* client uses the output token as the input token of the next request.
* This output member MUST NOT be required and MUST target a string shape.
* @param items
* The name of a top-level output member of the operation that is the data
* that is being paginated across many responses.
*
* The named output member, if specified, MUST target a list or map.
* @param pageSize
* The name of an operation input member that limits the maximum number of
* results to include in the operation output. This input member MUST NOT
* be required and MUST target an integer shape.
*/
final case class Paginated(inputToken: Option[NonEmptyString] = None, outputToken: Option[NonEmptyString] = None, items: Option[NonEmptyString] = None, pageSize: Option[NonEmptyString] = None)
object Paginated extends ShapeTag.Companion[Paginated] {
val id: ShapeId = ShapeId("smithy.api", "paginated")
val hints: Hints = Hints(
smithy.api.Documentation("The paginated trait indicates that an operation intentionally limits the\nnumber of results returned in a single response and that multiple\ninvocations might be necessary to retrieve all results."),
smithy.api.Trait(selector = Some(":is(service, operation)"), structurallyExclusive = None, conflicts = None, breakingChanges = Some(List(smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.REMOVE.widen, severity = smithy.api.Severity.ERROR.widen, path = None, message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/inputToken"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/outputToken"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.REMOVE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/items"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.ADD.widen, severity = smithy.api.Severity.NOTE.widen, path = Some("/items"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.NOTE.widen, path = Some("/items"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.UPDATE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/pageSize"), message = None), smithy.api.TraitDiffRule(change = smithy.api.TraitChangeType.REMOVE.widen, severity = smithy.api.Severity.ERROR.widen, path = Some("/pageSize"), message = None)))),
).lazily
// constructor using the original order from the spec
private def make(inputToken: Option[NonEmptyString], outputToken: Option[NonEmptyString], items: Option[NonEmptyString], pageSize: Option[NonEmptyString]): Paginated = Paginated(inputToken, outputToken, items, pageSize)
implicit val schema: Schema[Paginated] = recursive(struct(
NonEmptyString.schema.optional[Paginated]("inputToken", _.inputToken).addHints(smithy.api.Documentation("The name of the operation input member that represents the continuation\ntoken.\n\nWhen this value is provided as operation input, the service returns\nresults from where the previous response left off. This input member\nMUST NOT be required and MUST target a string shape.")),
NonEmptyString.schema.optional[Paginated]("outputToken", _.outputToken).addHints(smithy.api.Documentation("The name of the operation output member that represents the\ncontinuation token.\n\nWhen this value is present in operation output, it indicates that there\nare more results to retrieve. To get the next page of results, the\nclient uses the output token as the input token of the next request.\nThis output member MUST NOT be required and MUST target a string shape.")),
NonEmptyString.schema.optional[Paginated]("items", _.items).addHints(smithy.api.Documentation("The name of a top-level output member of the operation that is the data\nthat is being paginated across many responses.\n\nThe named output member, if specified, MUST target a list or map.")),
NonEmptyString.schema.optional[Paginated]("pageSize", _.pageSize).addHints(smithy.api.Documentation("The name of an operation input member that limits the maximum number of\nresults to include in the operation output. This input member MUST NOT\nbe required and MUST target an integer shape.")),
)(make).withId(id).addHints(hints))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy