|
| 1 | +// Copyright 2020 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +syntax = "proto3"; |
| 16 | + |
| 17 | +package oteldemo; |
| 18 | + |
| 19 | +option go_package = "genproto/oteldemo"; |
| 20 | + |
| 21 | +// -----------------Cart service----------------- |
| 22 | + |
| 23 | +service CartService { |
| 24 | + rpc AddItem(AddItemRequest) returns (Empty) {} |
| 25 | + rpc GetCart(GetCartRequest) returns (Cart) {} |
| 26 | + rpc EmptyCart(EmptyCartRequest) returns (Empty) {} |
| 27 | +} |
| 28 | + |
| 29 | +message CartItem { |
| 30 | + string product_id = 1; |
| 31 | + int32 quantity = 2; |
| 32 | +} |
| 33 | + |
| 34 | +message AddItemRequest { |
| 35 | + string user_id = 1; |
| 36 | + CartItem item = 2; |
| 37 | +} |
| 38 | + |
| 39 | +message EmptyCartRequest { |
| 40 | + string user_id = 1; |
| 41 | +} |
| 42 | + |
| 43 | +message GetCartRequest { |
| 44 | + string user_id = 1; |
| 45 | +} |
| 46 | + |
| 47 | +message Cart { |
| 48 | + string user_id = 1; |
| 49 | + repeated CartItem items = 2; |
| 50 | +} |
| 51 | + |
| 52 | +message Empty {} |
| 53 | + |
| 54 | +// ---------------Recommendation service---------- |
| 55 | + |
| 56 | +service RecommendationService { |
| 57 | + rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse){} |
| 58 | +} |
| 59 | + |
| 60 | +message ListRecommendationsRequest { |
| 61 | + string user_id = 1; |
| 62 | + repeated string product_ids = 2; |
| 63 | +} |
| 64 | + |
| 65 | +message ListRecommendationsResponse { |
| 66 | + repeated string product_ids = 1; |
| 67 | +} |
| 68 | + |
| 69 | +// ---------------Product Catalog---------------- |
| 70 | + |
| 71 | +service ProductCatalogService { |
| 72 | + rpc ListProducts(Empty) returns (ListProductsResponse) {} |
| 73 | + rpc GetProduct(GetProductRequest) returns (Product) {} |
| 74 | + rpc SearchProducts(SearchProductsRequest) returns (SearchProductsResponse) {} |
| 75 | +} |
| 76 | + |
| 77 | +message Product { |
| 78 | + string id = 1; |
| 79 | + string name = 2; |
| 80 | + string description = 3; |
| 81 | + string picture = 4; |
| 82 | + Money price_usd = 5; |
| 83 | + |
| 84 | + // Categories such as "clothing" or "kitchen" that can be used to look up |
| 85 | + // other related products. |
| 86 | + repeated string categories = 6; |
| 87 | +} |
| 88 | + |
| 89 | +message ListProductsResponse { |
| 90 | + repeated Product products = 1; |
| 91 | +} |
| 92 | + |
| 93 | +message GetProductRequest { |
| 94 | + string id = 1; |
| 95 | +} |
| 96 | + |
| 97 | +message SearchProductsRequest { |
| 98 | + string query = 1; |
| 99 | +} |
| 100 | + |
| 101 | +message SearchProductsResponse { |
| 102 | + repeated Product results = 1; |
| 103 | +} |
| 104 | + |
| 105 | +// ---------------Shipping Service---------- |
| 106 | + |
| 107 | +service ShippingService { |
| 108 | + rpc GetQuote(GetQuoteRequest) returns (GetQuoteResponse) {} |
| 109 | + rpc ShipOrder(ShipOrderRequest) returns (ShipOrderResponse) {} |
| 110 | +} |
| 111 | + |
| 112 | +message GetQuoteRequest { |
| 113 | + Address address = 1; |
| 114 | + repeated CartItem items = 2; |
| 115 | +} |
| 116 | + |
| 117 | +message GetQuoteResponse { |
| 118 | + Money cost_usd = 1; |
| 119 | +} |
| 120 | + |
| 121 | +message ShipOrderRequest { |
| 122 | + Address address = 1; |
| 123 | + repeated CartItem items = 2; |
| 124 | +} |
| 125 | + |
| 126 | +message ShipOrderResponse { |
| 127 | + string tracking_id = 1; |
| 128 | +} |
| 129 | + |
| 130 | +message Address { |
| 131 | + string street_address = 1; |
| 132 | + string city = 2; |
| 133 | + string state = 3; |
| 134 | + string country = 4; |
| 135 | + string zip_code = 5; |
| 136 | +} |
| 137 | + |
| 138 | +// -----------------Currency service----------------- |
| 139 | + |
| 140 | +service CurrencyService { |
| 141 | + rpc GetSupportedCurrencies(Empty) returns (GetSupportedCurrenciesResponse) {} |
| 142 | + rpc Convert(CurrencyConversionRequest) returns (Money) {} |
| 143 | +} |
| 144 | + |
| 145 | +// Represents an amount of money with its currency type. |
| 146 | +message Money { |
| 147 | + // The 3-letter currency code defined in ISO 4217. |
| 148 | + string currency_code = 1; |
| 149 | + |
| 150 | + // The whole units of the amount. |
| 151 | + // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. |
| 152 | + int64 units = 2; |
| 153 | + |
| 154 | + // Number of nano (10^-9) units of the amount. |
| 155 | + // The value must be between -999,999,999 and +999,999,999 inclusive. |
| 156 | + // If `units` is positive, `nanos` must be positive or zero. |
| 157 | + // If `units` is zero, `nanos` can be positive, zero, or negative. |
| 158 | + // If `units` is negative, `nanos` must be negative or zero. |
| 159 | + // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. |
| 160 | + int32 nanos = 3; |
| 161 | +} |
| 162 | + |
| 163 | +message GetSupportedCurrenciesResponse { |
| 164 | + // The 3-letter currency code defined in ISO 4217. |
| 165 | + repeated string currency_codes = 1; |
| 166 | +} |
| 167 | + |
| 168 | +message CurrencyConversionRequest { |
| 169 | + Money from = 1; |
| 170 | + |
| 171 | + // The 3-letter currency code defined in ISO 4217. |
| 172 | + string to_code = 2; |
| 173 | +} |
| 174 | + |
| 175 | +// -------------Payment service----------------- |
| 176 | + |
| 177 | +service PaymentService { |
| 178 | + rpc Charge(ChargeRequest) returns (ChargeResponse) {} |
| 179 | +} |
| 180 | + |
| 181 | +message CreditCardInfo { |
| 182 | + string credit_card_number = 1; |
| 183 | + int32 credit_card_cvv = 2; |
| 184 | + int32 credit_card_expiration_year = 3; |
| 185 | + int32 credit_card_expiration_month = 4; |
| 186 | +} |
| 187 | + |
| 188 | +message ChargeRequest { |
| 189 | + Money amount = 1; |
| 190 | + CreditCardInfo credit_card = 2; |
| 191 | +} |
| 192 | + |
| 193 | +message ChargeResponse { |
| 194 | + string transaction_id = 1; |
| 195 | +} |
| 196 | + |
| 197 | +// -------------Email service----------------- |
| 198 | + |
| 199 | +service EmailService { |
| 200 | + rpc SendOrderConfirmation(SendOrderConfirmationRequest) returns (Empty) {} |
| 201 | +} |
| 202 | + |
| 203 | +message OrderItem { |
| 204 | + CartItem item = 1; |
| 205 | + Money cost = 2; |
| 206 | +} |
| 207 | + |
| 208 | +message OrderResult { |
| 209 | + string order_id = 1; |
| 210 | + string shipping_tracking_id = 2; |
| 211 | + Money shipping_cost = 3; |
| 212 | + Address shipping_address = 4; |
| 213 | + repeated OrderItem items = 5; |
| 214 | +} |
| 215 | + |
| 216 | +message SendOrderConfirmationRequest { |
| 217 | + string email = 1; |
| 218 | + OrderResult order = 2; |
| 219 | +} |
| 220 | + |
| 221 | + |
| 222 | +// -------------Checkout service----------------- |
| 223 | + |
| 224 | +service CheckoutService { |
| 225 | + rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse) {} |
| 226 | +} |
| 227 | + |
| 228 | +message PlaceOrderRequest { |
| 229 | + string user_id = 1; |
| 230 | + string user_currency = 2; |
| 231 | + |
| 232 | + Address address = 3; |
| 233 | + string email = 5; |
| 234 | + CreditCardInfo credit_card = 6; |
| 235 | +} |
| 236 | + |
| 237 | +message PlaceOrderResponse { |
| 238 | + OrderResult order = 1; |
| 239 | +} |
| 240 | + |
| 241 | +// ------------Ad service------------------ |
| 242 | + |
| 243 | +service AdService { |
| 244 | + rpc GetAds(AdRequest) returns (AdResponse) {} |
| 245 | +} |
| 246 | + |
| 247 | +message AdRequest { |
| 248 | + // List of important key words from the current page describing the context. |
| 249 | + repeated string context_keys = 1; |
| 250 | +} |
| 251 | + |
| 252 | +message AdResponse { |
| 253 | + repeated Ad ads = 1; |
| 254 | +} |
| 255 | + |
| 256 | +message Ad { |
| 257 | + // url to redirect to when an ad is clicked. |
| 258 | + string redirect_url = 1; |
| 259 | + |
| 260 | + // short advertisement text to display. |
| 261 | + string text = 2; |
| 262 | +} |
| 263 | + |
| 264 | +// ------------Feature flag service------------------ |
| 265 | + |
| 266 | +service FeatureFlagService { |
| 267 | + rpc GetFlag(GetFlagRequest) returns (GetFlagResponse) {} |
| 268 | + rpc CreateFlag(CreateFlagRequest) returns (CreateFlagResponse) {} |
| 269 | + rpc UpdateFlag(UpdateFlagRequest) returns (UpdateFlagResponse) {} |
| 270 | + rpc ListFlags(ListFlagsRequest) returns (ListFlagsResponse) {} |
| 271 | + rpc DeleteFlag(DeleteFlagRequest) returns (DeleteFlagResponse) {} |
| 272 | +} |
| 273 | + |
| 274 | +message Flag { |
| 275 | + string name = 1; |
| 276 | + string description = 2; |
| 277 | + bool enabled = 3; |
| 278 | +} |
| 279 | + |
| 280 | +message GetFlagRequest { |
| 281 | + string name = 1; |
| 282 | +} |
| 283 | + |
| 284 | +message GetFlagResponse { |
| 285 | + Flag flag = 1; |
| 286 | +} |
| 287 | + |
| 288 | +message CreateFlagRequest { |
| 289 | + string name = 1; |
| 290 | + string description = 2; |
| 291 | + bool enabled = 3; |
| 292 | +} |
| 293 | + |
| 294 | +message CreateFlagResponse { |
| 295 | + Flag flag = 1; |
| 296 | +} |
| 297 | + |
| 298 | +message UpdateFlagRequest { |
| 299 | + string name = 1; |
| 300 | + bool enabled = 2; |
| 301 | +} |
| 302 | + |
| 303 | +message UpdateFlagResponse {} |
| 304 | + |
| 305 | +message ListFlagsRequest {} |
| 306 | + |
| 307 | +message ListFlagsResponse { |
| 308 | + repeated Flag flag = 1; |
| 309 | +} |
| 310 | + |
| 311 | +message DeleteFlagRequest { |
| 312 | + string name = 1; |
| 313 | +} |
| 314 | + |
| 315 | +message DeleteFlagResponse {} |
0 commit comments