Lesson 13
Capstone: the Weather service
Capstone: the Weather service
This is the canonical example from Smithy’s own quickstart. It pulls together
everything you’ve learned: a service, resources with identifiers, lifecycle
operations, @readonly, target elision, and an error.
The starter already wires up the Weather service, the City resource, and the
CityId string. Your job is to fill in the operations and the error so the model
assembles and the structural checks pass.
What you’re building
GetCity— the resource’sread. It’s@readonly; its input uses target elision to pullcityIdfrom the resource (input := for City { @required $cityId }); its output has a@required name: String. It can fail withNoSuchResource.GetCurrentTime— a standalone@readonlyoperation on the service that returns a@required time: Timestamp.NoSuchResource— a client error structure with a@required message.
A worked skeleton of the pieces:
@readonly
operation GetCity {
input := for City {
@required
$cityId
}
output := {
@required
name: String
}
errors: [
NoSuchResource
]
}
@readonly
operation GetCurrentTime {
output := {
@required
time: Timestamp
}
}
@error("client")
structure NoSuchResource {
@required
message: String
}