-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer.proto
86 lines (71 loc) · 2.55 KB
/
customer.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
syntax = "proto3";
package appointy.customer.v2;
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
//import "google/api/http.proto";
import "validate/validate.proto";
option go_package = "/proto";
service CustomerService {
//create customer by passing a user message
rpc CreateCustomerService(CreateUserRequest) returns (User) {
option (google.api.http) = {
post: "/v2/user",
body: "user"
};
}
//get an existing customer by id
rpc GetCustomer(GetCustomerRequest) returns (User) {
option (google.api.http) = {
get: "/v2/user/{id}"
};
}
//search a customer by their email and first_name
rpc SearchCustomer(SearchCustomerRequest) returns (User) {
option (google.api.http) = {
get: "/v2/user"
};
}
//get a stream of all customers in database
rpc GetAllCustomers(.google.protobuf.Empty) returns (stream User) {
option (google.api.http) = {
get: "/v2/users"
};
}
//update an existing customer by providing a user message and user_id
rpc UpdateCustomer(UpdateCustomerRequest) returns (User) {
option (google.api.http) = {
patch: "/v2/user/{user_id}",
body: "user"
};
}
//delete a customer by providing their id
rpc DeleteCustomer(DeleteCustomerRequest) returns (.google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v2/user/{id}"
};
}
}
message User {
string id = 1 [(validate.rules).string = {ignore_empty: true, max_len: 20}];
string first_name = 2 [(validate.rules).string = {ignore_empty: true, min_len: 3, max_len: 20}];
string last_name = 3 [(validate.rules).string = {ignore_empty: true, min_len: 3, max_len: 20}];
string email = 4 [(validate.rules).string = {email: true, ignore_empty: true}];
int64 phone = 5 [(validate.rules).int64 = {gt: 999999999, lt: 10000000000, ignore_empty: true}];
}
message GetCustomerRequest {
string id = 1 [(validate.rules).string = {max_len: 20}];
}
message DeleteCustomerRequest {
string id = 1 [(validate.rules).string = {max_len: 20}];
}
message SearchCustomerRequest {
string email = 1[(validate.rules).string = {email: true}];
string first_name = 2 [(validate.rules).string = {min_len: 3, max_len: 20}];
}
message CreateUserRequest {
User user = 1 [(validate.rules).message.required = true];
}
message UpdateCustomerRequest {
string user_id = 1 [(validate.rules).string = {max_len: 20}];
User user = 2;
}