|
| 1 | +namespace example.weather |
| 2 | + |
| 3 | +use aws.protocols#awsJson1_0 |
| 4 | +use aws.api#service |
| 5 | + |
| 6 | +@service(sdkId: "Weather") |
| 7 | +@awsJson1_0 |
| 8 | +service Weather { |
| 9 | + version: "2006-03-01", |
| 10 | + resources: [City], |
| 11 | + operations: [GetCurrentTime] |
| 12 | +} |
| 13 | + |
| 14 | +resource City { |
| 15 | + identifiers: { cityId: CityId }, |
| 16 | + read: GetCity, |
| 17 | + list: ListCities, |
| 18 | + resources: [Forecast] |
| 19 | +} |
| 20 | + |
| 21 | +resource Forecast { |
| 22 | + identifiers: { cityId: CityId }, |
| 23 | + read: GetForecast |
| 24 | +} |
| 25 | + |
| 26 | +// Pattern is a trait. |
| 27 | +@pattern("^[A-Za-z0-9 ]+$") |
| 28 | +string CityId |
| 29 | + |
| 30 | +@readonly |
| 31 | +operation GetCurrentTime { |
| 32 | + output: GetCurrentTimeOutput |
| 33 | +} |
| 34 | + |
| 35 | +structure GetCurrentTimeOutput { |
| 36 | + time: smithy.api#Timestamp |
| 37 | +} |
| 38 | + |
| 39 | +@readonly |
| 40 | +operation GetForecast { |
| 41 | + input: GetForecastInput, |
| 42 | + output: GetForecastOutput, |
| 43 | + errors: [NoSuchResource] |
| 44 | +} |
| 45 | + |
| 46 | +structure GetForecastInput { |
| 47 | + @required cityId: CityId |
| 48 | +} |
| 49 | + |
| 50 | +structure GetForecastOutput { |
| 51 | + @required chanceOfRain: smithy.api#Float, |
| 52 | + @required low: smithy.api#Integer, |
| 53 | + @required high: smithy.api#Integer |
| 54 | +} |
| 55 | + |
| 56 | +@readonly |
| 57 | +operation GetCity { |
| 58 | + input: GetCityInput, |
| 59 | + output: GetCityOutput, |
| 60 | + errors: [NoSuchResource] |
| 61 | +} |
| 62 | + |
| 63 | +structure GetCityInput { |
| 64 | + @required cityId: CityId |
| 65 | +} |
| 66 | + |
| 67 | +structure GetCityOutput { |
| 68 | + @required name: smithy.api#String, |
| 69 | + @required coordinates: CityCoordinates |
| 70 | +} |
| 71 | + |
| 72 | +@readonly |
| 73 | +@paginated(inputToken: "nextToken", outputToken: "nextToken", |
| 74 | + pageSize: "pageSize", items: "items") |
| 75 | +operation ListCities { |
| 76 | + input: ListCitiesInput, |
| 77 | + output: ListCitiesOutput |
| 78 | +} |
| 79 | + |
| 80 | +structure ListCitiesInput { |
| 81 | + nextToken: smithy.api#String, |
| 82 | + pageSize: smithy.api#Integer |
| 83 | +} |
| 84 | + |
| 85 | +// Traits can be applied outside of the definition. |
| 86 | +apply ListCitiesInput @documentation("hello!") |
| 87 | + |
| 88 | +structure ListCitiesOutput { |
| 89 | + nextToken: smithy.api#String, |
| 90 | + @required items: CitySummaries |
| 91 | +} |
| 92 | + |
| 93 | +structure CityCoordinates { |
| 94 | + @required latitude: smithy.api#Float, |
| 95 | + @required longitude: smithy.api#Float |
| 96 | +} |
| 97 | + |
| 98 | +@error("client") |
| 99 | +structure NoSuchResource { |
| 100 | + @required resourceType: smithy.api#String |
| 101 | +} |
| 102 | + |
| 103 | +list CitySummaries { |
| 104 | + member: CitySummary |
| 105 | +} |
| 106 | + |
| 107 | +@references([{resource: City}]) |
| 108 | +structure CitySummary { |
| 109 | + @required cityId: CityId, |
| 110 | + @required name: smithy.api#String |
| 111 | +} |
0 commit comments