github.com/s7techlab/cckit@v0.10.5/examples/fabcar/fabcar.proto (about) 1 syntax = "proto3"; 2 3 package examples.fabcar; 4 5 option go_package = "github.com/s7techlab/cckit/examples/fabcar"; 6 7 import "google/api/annotations.proto"; 8 import "google/protobuf/empty.proto"; 9 import "google/protobuf/timestamp.proto"; 10 11 import "mwitkow/go-proto-validators/validator.proto"; 12 13 service FabCarService { 14 rpc CreateMaker (CreateMakerRequest) returns (Maker) { 15 option (google.api.http) = { 16 post: "/fabcar/makers" 17 body: "*" 18 }; 19 } 20 21 rpc DeleteMaker (MakerName) returns (Maker) { 22 option (google.api.http) = { 23 delete: "/fabcar/makers/{name}" 24 }; 25 } 26 27 rpc GetMaker (MakerName) returns (Maker) { 28 option (google.api.http) = { 29 get: "/fabcar/makers/{name}" 30 }; 31 } 32 33 rpc ListMakers (google.protobuf.Empty) returns (Makers) { 34 option (google.api.http) = { 35 get: "/fabcar/makers" 36 }; 37 } 38 39 rpc CreateCar (CreateCarRequest) returns (CarView) { 40 option (google.api.http) = { 41 post: "/fabcar/cars" 42 body: "*" 43 }; 44 } 45 46 rpc UpdateCar (UpdateCarRequest) returns (CarView) { 47 option (google.api.http) = { 48 put: "/fabcar/cars/{id}" 49 body: "*" 50 }; 51 } 52 53 rpc DeleteCar (CarId) returns (CarView) { 54 option (google.api.http) = { 55 delete: "/fabcar/cars/{id}" 56 }; 57 } 58 59 rpc GetCar (CarId) returns (Car) { 60 option (google.api.http) = { 61 get: "/fabcar/cars/{id}" 62 }; 63 } 64 65 rpc GetCarView (CarId) returns (CarView) { 66 option (google.api.http) = { 67 get: "/fabcar/cars/{id}/view" 68 }; 69 } 70 71 rpc ListCars (google.protobuf.Empty) returns (Cars) { 72 option (google.api.http) = { 73 get: "/fabcar/cars" 74 }; 75 } 76 77 rpc UpdateCarOwners (UpdateCarOwnersRequest) returns (CarOwners) { 78 option (google.api.http) = { 79 put: "/fabcar/cars/{car_id}/owners" 80 }; 81 } 82 83 rpc DeleteCarOwner (CarOwnerId) returns (CarOwner) { 84 option (google.api.http) = { 85 delete: "/fabcar/cars/{car_id}/owners/{first_name}/{second_name}" 86 }; 87 } 88 89 rpc GetCarOwner (CarOwnerId) returns (CarOwner) { 90 option (google.api.http) = { 91 get: "/fabcar/cars/{car_id}/owners/{first_name}/{second_name}" 92 }; 93 } 94 95 rpc ListCarOwners (CarId) returns (CarOwners) { 96 option (google.api.http) = { 97 get: "/fabcar/cars/{id}/owners" 98 }; 99 } 100 101 rpc UpdateCarDetails (UpdateCarDetailsRequest) returns (CarDetails) { 102 option (google.api.http) = { 103 put: "/fabcar/cars/{car_id}/details" 104 }; 105 } 106 107 rpc DeleteCarDetail (CarDetailId) returns (CarDetail) { 108 option (google.api.http) = { 109 delete: "/fabcar/cars/{car_id}/details/{type}" 110 }; 111 } 112 113 rpc GetCarDetail (CarDetailId) returns (CarDetail) { 114 option (google.api.http) = { 115 get: "/fabcar/cars/{car_id}/details/{type}" 116 }; 117 } 118 119 rpc ListCarDetails (CarId) returns (CarDetails) { 120 option (google.api.http) = { 121 get: "/fabcar/cars/{id}/details" 122 }; 123 } 124 } 125 126 // Dictionaries 127 enum DetailType { 128 WHEELS = 0; 129 BATTERY = 1; 130 } 131 132 // Entities 133 message CreateMakerRequest { 134 string name = 1 [(validator.field) = {string_not_empty: true}]; 135 string country = 2 [(validator.field) = {string_not_empty: true}]; 136 uint64 foundation_year = 3 [(validator.field) = {int_gt: 1885}]; // in 1886 was founded the oldest automaker - Mercedes-Benz 137 } 138 139 message MakerName { 140 string name = 1 [(validator.field) = {string_not_empty: true}]; 141 } 142 143 message Maker { 144 string name = 1; 145 string country = 2; 146 uint64 foundation_year = 3; 147 } 148 149 message Makers { 150 repeated Maker items = 1; 151 } 152 153 message CreateCarRequest { 154 string make = 1 [(validator.field) = {string_not_empty: true}]; 155 string model = 2 [(validator.field) = {string_not_empty: true}]; 156 string colour = 3 [(validator.field) = {string_not_empty: true}]; 157 uint64 number = 4 [(validator.field) = {int_gt: 0}]; 158 repeated SetCarOwner owners = 5; 159 repeated SetCarDetail details = 6 [(validator.field) = {repeated_count_min: 1}]; 160 } 161 162 message UpdateCarRequest { 163 repeated string id = 1 [(validator.field) = {repeated_count_min: 1}]; 164 string color = 2 [(validator.field) = {string_not_empty: true}]; 165 repeated SetCarOwner owners = 3; 166 repeated SetCarDetail details = 4; 167 } 168 169 message SetCarOwner { 170 string first_name = 1 [(validator.field) = {string_not_empty: true}]; 171 string second_name = 2 [(validator.field) = {string_not_empty: true}]; 172 string vehicle_passport = 3 [(validator.field) = {string_not_empty: true}]; 173 } 174 175 message SetCarDetail { 176 DetailType type = 1; 177 string make = 2 [(validator.field) = {string_not_empty: true}]; 178 } 179 180 message CarView { 181 Car car = 1; 182 CarOwners owners = 2; 183 CarDetails details = 3; 184 } 185 186 message Car { 187 repeated string id = 1 [(validator.field) = {repeated_count_min: 1}]; 188 string make = 2 [(validator.field) = {string_not_empty: true}]; 189 string model = 3 [(validator.field) = {string_not_empty: true}]; 190 string colour = 4 [(validator.field) = {string_not_empty: true}]; 191 uint64 number = 5 [(validator.field) = {int_gt: 0}]; 192 google.protobuf.Timestamp updated_at = 6; 193 } 194 195 message CarOwner { 196 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 197 string first_name = 2 [(validator.field) = {string_not_empty: true}]; 198 string second_name = 3 [(validator.field) = {string_not_empty: true}]; 199 string vehicle_passport = 4 [(validator.field) = {string_not_empty: true}]; 200 google.protobuf.Timestamp updated_at = 5; 201 } 202 203 message CarDetail { 204 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 205 DetailType type = 2; 206 string make = 3 [(validator.field) = {string_not_empty: true}]; 207 google.protobuf.Timestamp updated_at = 4; 208 } 209 210 message CarId { 211 repeated string id = 1 [(validator.field) = {repeated_count_min: 1}]; 212 } 213 214 message Cars { 215 repeated Car items = 1; 216 } 217 218 message UpdateCarOwnersRequest { 219 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 220 repeated SetCarOwner owners = 2 [(validator.field) = {repeated_count_min: 1}]; 221 } 222 223 message CarOwnerId { 224 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 225 string first_name = 2 [(validator.field) = {string_not_empty: true}]; 226 string second_name = 3 [(validator.field) = {string_not_empty: true}]; 227 } 228 229 message CarOwners { 230 repeated CarOwner items = 1; 231 } 232 233 message UpdateCarDetailsRequest { 234 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 235 repeated SetCarDetail details = 2 [(validator.field) = {repeated_count_min: 1}]; 236 } 237 238 message CarDetailId { 239 repeated string car_id = 1 [(validator.field) = {repeated_count_min: 1}]; 240 DetailType type = 2; 241 } 242 243 message CarDetails { 244 repeated CarDetail items = 1; 245 } 246 247 // Events 248 message MakerCreated { 249 string name = 1; 250 string country = 2; 251 uint64 foundation_year = 3; 252 } 253 254 message MakerDeleted { 255 string name = 1; 256 string country = 2; 257 uint64 foundation_year = 3; 258 } 259 260 message CarCreated { 261 repeated string id = 1; 262 string make = 2; 263 string model = 3; 264 string colour = 4; 265 uint64 number = 5; 266 } 267 268 message CarDeleted { 269 repeated string id = 1; 270 string make = 2; 271 string model = 3; 272 string colour = 4; 273 uint64 number = 5; 274 CarOwners owners = 6; 275 CarDetails details = 7; 276 } 277 278 message CarUpdated { 279 repeated string id = 1; 280 string colour = 2; 281 } 282 283 message CarOwnersUpdated { 284 CarOwners owners = 1; 285 } 286 287 message CarOwnerDeleted { 288 CarOwner owner = 1; 289 } 290 291 message CarDetailsUpdated { 292 CarDetails details = 1; 293 } 294 295 message CarDetailDeleted { 296 CarDetail detail = 1; 297 }