This repository has been archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
shoppingcart.proto
63 lines (53 loc) · 1.55 KB
/
shoppingcart.proto
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
// This is the public API offered by the shopping cart entity.
// #example-shopping-cart-proto
syntax = "proto3";
package com.example.shoppingcart;
import "google/protobuf/empty.proto";
import "cloudstate/entity_key.proto";
import "cloudstate/eventing.proto";
import "google/api/annotations.proto";
import "google/api/http.proto";
import "google/api/httpbody.proto";
message AddLineItem {
string user_id = 1 [(.cloudstate.entity_key) = true];
string product_id = 2;
string name = 3;
int32 quantity = 4;
}
message RemoveLineItem {
string user_id = 1 [(.cloudstate.entity_key) = true];
string product_id = 2;
}
message GetShoppingCart {
string user_id = 1 [(.cloudstate.entity_key) = true];
}
message LineItem {
string product_id = 1;
string name = 2;
int32 quantity = 3;
}
message Cart {
repeated LineItem items = 1;
}
service ShoppingCart {
rpc AddItem(AddLineItem) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/cart/{user_id}/items/add",
body: "*",
};
option (.cloudstate.eventing).in = "items";
}
rpc RemoveItem(RemoveLineItem) returns (google.protobuf.Empty) {
option (google.api.http).post = "/cart/{user_id}/items/{product_id}/remove";
}
rpc GetCart(GetShoppingCart) returns (Cart) {
option (google.api.http) = {
get: "/carts/{user_id}",
additional_bindings: {
get: "/carts/{user_id}/items",
response_body: "items"
}
};
}
}
// #example-shopping-cart-proto