-
Notifications
You must be signed in to change notification settings - Fork 180
/
pokemon.smithy
204 lines (175 loc) · 4.09 KB
/
pokemon.smithy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
$version: "1.0"
namespace com.aws.example
use aws.protocols#restJson1
/// The Pokémon Service allows you to retrieve information about Pokémon species.
@title("Pokémon Service")
@restJson1
service PokemonService {
version: "2021-12-01",
resources: [PokemonSpecies],
operations: [GetServerStatistics, EmptyOperation, CapturePokemonOperation],
}
/// A Pokémon species forms the basis for at least one Pokémon.
@title("Pokémon Species")
resource PokemonSpecies {
identifiers: {
name: String
},
read: GetPokemonSpecies,
}
/// Capture Pokémons via event streams
@http(uri: "/capture-pokemon-event/{region}", method: "POST")
operation CapturePokemonOperation {
input: CapturePokemonOperationEventsInput,
output: CapturePokemonOperationEventsOutput,
errors: [UnsupportedRegionError, ThrottlingError]
}
@input
structure CapturePokemonOperationEventsInput {
@httpPayload
events: AttemptCapturingPokemonEvent,
@httpLabel
@required
region: String,
}
@output
structure CapturePokemonOperationEventsOutput {
@httpPayload
events: CapturePokemonEvents,
}
@streaming
union AttemptCapturingPokemonEvent {
event: CapturingEvent,
masterball_unsuccessful: MasterBallUnsuccessful,
}
structure CapturingEvent {
@eventPayload
payload: CapturingPayload,
}
structure CapturingPayload {
name: String,
pokeball: String,
}
@streaming
union CapturePokemonEvents {
event: CaptureEvent,
invalid_pokeball: InvalidPokeballError,
throttlingError: ThrottlingError,
}
structure CaptureEvent {
@eventHeader
name: String,
@eventHeader
captured: Boolean,
@eventHeader
shiny: Boolean,
@eventPayload
pokedex_update: Blob,
}
@error("server")
structure UnsupportedRegionError {
@required
region: String,
}
@error("client")
structure InvalidPokeballError {
@required
pokeball: String,
}
@error("server")
structure MasterBallUnsuccessful {
@required
message: String,
}
@error("client")
structure ThrottlingError {}
/// Retrieve information about a Pokémon species.
@readonly
@http(uri: "/pokemon-species/{name}", method: "GET")
operation GetPokemonSpecies {
input: GetPokemonSpeciesInput,
output: GetPokemonSpeciesOutput,
errors: [ResourceNotFoundException],
}
@input
structure GetPokemonSpeciesInput {
@required
@httpLabel
name: String
}
@output
structure GetPokemonSpeciesOutput {
/// The name for this resource.
@required
name: String,
/// A list of flavor text entries for this Pokémon species.
@required
flavorTextEntries: FlavorTextEntries
}
/// Retrieve HTTP server statistiscs, such as calls count.
@readonly
@http(uri: "/stats", method: "GET")
operation GetServerStatistics {
input: GetServerStatisticsInput,
output: GetServerStatisticsOutput,
}
@input
structure GetServerStatisticsInput { }
@output
structure GetServerStatisticsOutput {
/// The number of calls executed by the server.
@required
calls_count: Long,
}
list FlavorTextEntries {
member: FlavorText
}
structure FlavorText {
/// The localized flavor text for an API resource in a specific language.
@required
flavorText: String,
/// The language this name is in.
@required
language: Language,
}
/// Supported languages for FlavorText entries.
@enum([
{
name: "ENGLISH",
value: "en",
documentation: "American English.",
},
{
name: "SPANISH",
value: "es",
documentation: "Español.",
},
{
name: "ITALIAN",
value: "it",
documentation: "Italiano.",
},
{
name: "JAPANESE",
value: "jp",
documentation: "日本語。",
},
])
string Language
/// Empty operation, used to stress test the framework.
@readonly
@http(uri: "/empty-operation", method: "GET")
operation EmptyOperation {
input: EmptyOperationInput,
output: EmptyOperationOutput,
}
@input
structure EmptyOperationInput { }
@output
structure EmptyOperationOutput { }
@error("client")
@httpError(404)
structure ResourceNotFoundException {
@required
message: String,
}