addressbook.thrift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. include "container.thrift"
  2. const i16 DEFAULT_LIST_SIZE = 10
  3. typedef i32 timestamp
  4. enum PhoneType {
  5. MOBILE = 0,
  6. HOME,
  7. WORK,
  8. }
  9. struct PhoneNumber {
  10. 1: optional PhoneType type = PhoneType.MOBILE,
  11. 2: optional string number,
  12. 3: optional container.MixItem mix_item,
  13. }
  14. struct Person {
  15. 1: optional string name,
  16. 2: optional list<PhoneNumber> phones,
  17. 4: optional timestamp created_at,
  18. }
  19. typedef map<string, Person> PersonMap
  20. struct AddressBook {
  21. 1: optional PersonMap people,
  22. }
  23. exception PersonNotExistsError {
  24. 1: optional string message = "Person Not Exists!",
  25. }
  26. service AddressBookService {
  27. void ping();
  28. string hello(1: required string name);
  29. bool add(1: Person person);
  30. bool remove(1: string name) throws (1: PersonNotExistsError not_exists);
  31. Person get(1: string name) throws (1: PersonNotExistsError not_exists);
  32. AddressBook book();
  33. list<PhoneNumber> get_phonenumbers(1: string name, 2: i32 count);
  34. map<PhoneType, string> get_phones(1: string name);
  35. bool sleep(1: i32 ms);
  36. void close(1: i32 ms);
  37. }