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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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
import "@typespec/http";
import "@typespec/openapi";
import "@typespec/openapi3";

using TypeSpec.OpenAPI;
using TypeSpec.Http;

namespace Common;

/**
 * Bad Request.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/BadRequest")
@friendlyName("BadRequest")
model BadRequest extends BaseError {
  @statusCode _: 400;

  /**
   * The list of parameters that failed validation.
   */
  invalid_parameters: InvalidParameters;
}

/**
 * Unauthorized.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/Unauthorized")
@friendlyName("Unauthorized")
model Unauthorized extends BaseError {
  @statusCode _: 401;
}

/**
 * Forbidden.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/Forbidden")
@friendlyName("Forbidden")
model Forbidden extends BaseError {
  @statusCode _: 403;
}

/**
 * Not Found.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/NotFound")
@friendlyName("NotFound")
model NotFound extends BaseError {
  @statusCode _: 404;
}

/**
 * Conflict.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/Conflict")
@friendlyName("Conflict")
model Conflict extends BaseError {
  @statusCode _: 409;
}

/**
 * Gone.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/Gone")
@friendlyName("Gone")
model Gone extends BaseError {
  @statusCode _: 410;
}

/**
 * Payload Too Large.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@friendlyName("PayloadTooLarge")
@useRef("../../../../common/definitions/errors.yaml#/components/responses/PayloadTooLarge")
@friendlyName("PayloadTooLarge")
model PayloadTooLarge extends BaseError {
  @statusCode _: 413;
}

/**
 * Unsupported Media Type.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@friendlyName("UnsupportedMediaType")
@useRef("../../../../common/definitions/errors.yaml#/components/responses/UnsupportedMediaType")
@friendlyName("UnsupportedMediaType")
model UnsupportedMediaType extends BaseError {
  @statusCode _: 415;
}

/**
 * Unprocessable Content.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@friendlyName("UnprocessableContent")
@useRef("../../../../common/definitions/errors.yaml#/components/responses/UnprocessableContent")
@friendlyName("UnprocessableContent")
model UnprocessableContent extends BaseError {
  @statusCode _: 422;
}

/**
 * Too Many Requests.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@friendlyName("TooManyRequests")
@useRef("../../../../common/definitions/errors.yaml#/components/responses/TooManyRequests")
@friendlyName("TooManyRequests")
model TooManyRequests extends BaseError {
  @statusCode _: 429;
}

/**
 * Internal Server Error.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/Internal")
@friendlyName("Internal")
model Internal extends BaseError {
  @statusCode _: 500;
}

/**
 * Not Implemented.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@friendlyName("NotImplemented")
@useRef("../../../../common/definitions/errors.yaml#/components/responses/NotImplemented")
@friendlyName("NotImplemented")
model NotImplemented extends BaseError {
  @statusCode _: 501;
}

/**
 * Not Available.
 */
#suppress "@openmeter/api-spec-aip/composition-over-inheritance" "inheritance"
@error
@useRef("../../../../common/definitions/errors.yaml#/components/responses/NotAvailable")
@friendlyName("NotAvailable")
model NotAvailable extends BaseError {
  @statusCode _: 503;
}

alias ErrorResponses = BadRequest | Unauthorized | Forbidden;

/**
 * Standard error response.
 */
@error
@friendlyName("BaseError")
model BaseError {
  @header contentType: "application/problem+json";

  /**
   * Type contains a URI that identifies the problem type.
   */
  @example("about:blank")
  @visibility(Lifecycle.Read)
  type: string = "about:blank";

  /**
   * The HTTP status code generated by the origin server for this occurrence of the
   * problem.
   */
  @example(400)
  @visibility(Lifecycle.Read)
  status: integer;

  /**
   * A a short, human-readable summary of the problem type.
   */
  @example("Bad Request")
  @visibility(Lifecycle.Read)
  title: string;

  /**
   * A human-readable explanation specific to this occurrence of the problem.
   */
  @example("The request body must be a JSON object.")
  detail: string;

  /**
   * A URI reference that identifies the specific occurrence of the problem.
   */
  @visibility(Lifecycle.Read)
  instance: string;

  /**
   * Additional properties specific to the problem type may be present.
   */
  ...Record<unknown>;
}

/**
 * The list of parameters that failed validation.
 */
@friendlyName("InvalidParameters")
@minItems(1)
model InvalidParameters is InvalidParameter[];

/**
 * A parameter that failed validation.
 */
@friendlyName("InvalidParameter")
union InvalidParameter {
  standard: InvalidParameterStandard,
  minimumLength: InvalidParameterMinimumLength,
  maximumLength: InvalidParameterMaximumLength,
  choice: InvalidParameterChoiceItem,
  dependent: InvalidParameterDependentItem,
}

/**
 * The validation rule that a parameter failed.
 */
@friendlyName("InvalidRules")
enum InvalidRules {
  Required: "required",
  IsArray: "is_array",
  IsBase64: "is_base64",
  IsBoolean: "is_boolean",
  IsDateTime: "is_date_time",
  IsInteger: "is_integer",
  IsNull: "is_null",
  IsNumber: "is_number",
  IsObject: "is_object",
  IsString: "is_string",
  IsUuid: "is_uuid",
  IsFqdn: "is_fqdn",
  IsArn: "is_arn",
  UnknownProperty: "unknown_property",
  MissingReference: "missing_reference",
  IsLabel: "is_label",
  MatchesRegex: "matches_regex",
  Invalid: "invalid",
  IsSupportedNetworkAvailabilityZoneList: "is_supported_network_availability_zone_list",
  IsSupportedNetworkCidrBlock: "is_supported_network_cidr_block",
  IsSupportedProviderRegion: "is_supported_provider_region",
  Type: "type",
}

/**
 * A parameter that failed a standard validation rule.
 */
@friendlyName("InvalidParameterStandard")
model InvalidParameterStandard {
  /**
   * The name of the field that failed validation.
   */
  @visibility(Lifecycle.Read)
  field: string;

  /**
   * The validation rule that was violated.
   */
  rule?: InvalidRules;

  /**
   * The part of the request the field came from (e.g. `body`, `query`).
   */
  source?: string;

  /**
   * A human readable explanation of why the field failed validation.
   */
  reason: string;
}

/**
 * A parameter that failed a minimum-length (or minimum-value) validation rule.
 */
@friendlyName("InvalidParameterMinimumLength")
model InvalidParameterMinimumLength {
  /**
   * The name of the field that failed validation.
   */
  field: string;

  /**
   * The minimum validation rule that was violated.
   */
  rule: InvalidParameterMinimumRule;

  /**
   * The minimum allowed value or length.
   */
  minimum: integer;

  /**
   * The part of the request the field came from (e.g. `body`, `query`).
   */
  source?: string;

  /**
   * A human readable explanation of why the field failed validation.
   */
  reason: string;
}

/**
 * Minimum-length (or minimum-value) validation rules.
 */
@friendlyName("InvalidParameterMinimumRule")
enum InvalidParameterMinimumRule {
  MinLength: "min_length",
  MinDigits: "min_digits",
  MinLowercase: "min_lowercase",
  MinUppercase: "min_uppercase",
  MinSymbols: "min_symbols",
  MinItems: "min_items",
  Min: "min",
}

/**
 * A parameter that failed a maximum-length (or maximum-value) validation rule.
 */
@friendlyName("InvalidParameterMaximumLength")
model InvalidParameterMaximumLength {
  /**
   * The name of the field that failed validation.
   */
  @visibility(Lifecycle.Read)
  field: string;

  /**
   * The maximum validation rule that was violated.
   */
  rule: InvalidParameterMaximumRule;

  /**
   * The maximum allowed value or length.
   */
  maximum: integer;

  /**
   * The part of the request the field came from (e.g. `body`, `query`).
   */
  source?: string;

  /**
   * A human readable explanation of why the field failed validation.
   */
  @visibility(Lifecycle.Read)
  reason: string;
}

/**
 * Maximum-length (or maximum-value) validation rules.
 */
@friendlyName("InvalidParameterMaximumRule")
enum InvalidParameterMaximumRule {
  MaxLength: "max_length",
  MaxItems: "max_items",
  Max: "max",
}

/**
 * A parameter whose value was not one of the allowed choices.
 */
@friendlyName("InvalidParameterChoiceItem")
model InvalidParameterChoiceItem {
  /**
   * The name of the field that failed validation.
   */
  @visibility(Lifecycle.Read)
  field: string;

  /**
   * The enum validation rule that was violated.
   */
  rule: InvalidParameterChoiceRule;

  /**
   * A human readable explanation of why the field failed validation.
   */
  @visibility(Lifecycle.Read)
  reason: string;

  /**
   * The allowed choices for the field.
   */
  @visibility(Lifecycle.Read)
  @minItems(1)
  choices: unknown[];

  /**
   * The part of the request the field came from (e.g. `body`, `query`).
   */
  source?: string;
}

/**
 * The enum validation rule.
 */
@friendlyName("InvalidParameterChoiceRule")
enum InvalidParameterChoiceRule {
  Enum: "enum",
}

/**
 * A parameter that failed a dependent-fields validation rule.
 */
@friendlyName("InvalidParameterDependentItem")
model InvalidParameterDependentItem {
  /**
   * The name of the field that failed validation.
   */
  field: string;

  /**
   * The dependent-fields validation rule that was violated.
   */
  rule: InvalidParameterDependentRule;

  /**
   * A human readable explanation of why the field failed validation.
   */
  reason: string;

  /**
   * The fields that this field depends on.
   */
  dependents: unknown[];

  /**
   * The part of the request the field came from (e.g. `body`, `query`).
   */
  source?: string;
}

/**
 * The dependent-fields validation rule.
 */
@friendlyName("InvalidParameterDependentRule")
enum InvalidParameterDependentRule {
  DependentFields: "dependent_fields",
}