Files
services/contact/proto/contact.proto
2022-02-24 22:00:29 +00:00

157 lines
3.0 KiB
Protocol Buffer

syntax = "proto3";
package contact;
option go_package = "./proto;contact";
service Contact {
rpc Create(CreateRequest) returns (CreateResponse) {}
rpc Read(ReadRequest) returns (ReadResponse) {}
rpc Update(UpdateRequest) returns (UpdateResponse) {}
rpc Delete(DeleteRequest) returns (DeleteResponse) {}
rpc List(ListRequest) returns (ListResponse) {}
// TODO: wait for the search API
// rpc Search(Request) returns (Response) {}
}
message Phone {
// the label of the phone number
string label = 1;
// phone number
string number = 2;
}
message Email {
// the label of the email
string label = 1;
// the email address
string address = 2;
}
message Link {
// the label of the link
string label = 1;
// the url of the contact
string url = 2;
}
message Address {
// the label of the address
string label = 1;
// the address location
string location = 2;
}
message SocialMedia {
// the label of the social
string label = 1;
// the username of social media
string username = 2;
}
message ContactInfo {
// contact id
string id = 1;
// the contact name
string name = 2;
// the phone numbers
repeated Phone phones = 3;
// the emails
repeated Email emails = 4;
// the contact links
repeated Link links = 5;
// the birthday
string birthday = 6;
// the address
repeated Address addresses = 7;
// the social media username
repeated SocialMedia social_medias = 8;
// note of the contact
string note = 9;
// create date string in RFC3339
string created_at = 10;
// update date string in RFC3339
string updated_at = 11;
}
// Create a contact
message CreateRequest {
// required, the name of the contact
string name = 1;
// optional, phone numbers
repeated Phone phones = 2;
// optional, emails
repeated Email emails = 3;
// optional, links
repeated Link links = 4;
// optional, birthday
string birthday = 5;
// optional, location
repeated Address addresses = 6;
// optional, social media
repeated SocialMedia social_medias = 7;
// optional, note of the contact
string note = 8;
}
message CreateResponse {
ContactInfo contact = 1;
}
// Read contact details
message ReadRequest {
string id = 1;
}
message ReadResponse {
ContactInfo contact = 1;
}
// Delete a contact
message DeleteRequest {
// the id of the contact
string id = 1;
}
message DeleteResponse {
}
// Update a contact
message UpdateRequest {
// required, the contact id
string id = 1;
// required, the name
string name = 2;
// optional, phone number
repeated Phone phones = 3;
// optional, emails
repeated Email emails = 4;
// optional, links
repeated Link links = 5;
// optional, birthday
string birthday = 6;
// optional, addresses
repeated Address addresses = 7;
// optional, social media
repeated SocialMedia social_medias = 8;
// optional, note
string note = 9;
}
message UpdateResponse {
ContactInfo contact = 1;
}
// List contacts
message ListRequest {
// optional
uint32 offset = 1;
// optional, default is 30
uint32 limit = 2;
}
message ListResponse {
repeated ContactInfo contacts = 1;
}