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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: Apache-2.0
//! Contacts tool arguments and structured results.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
fn default_page_limit() -> u32 {
25
}
/// Arguments for `contacts_search`.
#[derive(Debug, Default, Deserialize, JsonSchema)]
pub struct SearchContactsParams {
/// A name, an email address or a phone number, or part of one.
pub query: String,
/// Most contacts to return. Omitted means 25. More than 100 is rejected.
#[serde(default = "default_page_limit")]
pub limit: u32,
/// Also return groups, to find the id of a group for `contacts_set_group_membership`.
#[serde(default)]
pub include_groups: Option<bool>,
}
/// Arguments for `contacts_create`.
#[derive(Debug, Default, Deserialize, JsonSchema)]
pub struct CreateContactParams {
/// Full name, such as `Ada Lovelace`.
pub full_name: String,
/// Email addresses.
#[serde(default)]
pub emails: Vec<String>,
/// Phone numbers.
#[serde(default)]
pub phones: Vec<String>,
}
/// Arguments for `contacts_update`.
#[derive(Debug, Default, Deserialize, JsonSchema)]
pub struct UpdateContactParams {
/// Opaque contact id.
pub id: String,
/// The `etag` from the last read. A different one means the contact changed.
pub etag: String,
/// New full name. Omit to keep it.
#[serde(default)]
pub full_name: Option<String>,
/// The full list of email addresses the contact should have. Omit to keep them.
#[serde(default)]
pub emails: Option<Vec<String>>,
/// The full list of phone numbers the contact should have. Omit to keep them.
#[serde(default)]
pub phones: Option<Vec<String>>,
}
/// Arguments for `contacts_set_group_membership`.
#[derive(Debug, Default, Deserialize, JsonSchema)]
pub struct SetGroupMembershipParams {
/// Id of an existing group, from `contacts_search` with `include_groups`
/// or from a contact's `groups`.
pub group: String,
/// Id of the contact to add or remove.
pub contact: String,
/// `add` or `remove`.
pub action: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub(crate) struct LabeledOut {
/// As stored on the card.
pub(crate) value: String,
/// As stored on the card.
pub(crate) label: Option<String>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub(crate) struct GroupOut {
/// Pass as `group` to `contacts_set_group_membership`.
pub(crate) id: String,
/// As stored on the card.
pub(crate) name: String,
}
#[derive(Debug, Serialize, JsonSchema)]
pub(crate) struct ContactOut {
pub(crate) id: String,
pub(crate) etag: String,
/// As stored on the card.
pub(crate) name: String,
pub(crate) emails: Vec<LabeledOut>,
pub(crate) phones: Vec<LabeledOut>,
/// As stored on the card.
pub(crate) organization: Option<String>,
/// As stored on the card.
pub(crate) note: Option<String>,
/// The card is a group, not a person.
pub(crate) is_group: bool,
/// Groups the contact is in. Only `contacts_get` fills this.
pub(crate) groups: Vec<GroupOut>,
}
#[derive(Debug, Serialize, JsonSchema)]
pub(crate) struct ContactListOut {
pub(crate) contacts: Vec<ContactOut>,
/// Cards that could not be read and were skipped.
pub(crate) warnings: u32,
}
#[derive(Debug, Serialize, JsonSchema)]
pub(crate) struct MembershipOut {
pub(crate) updated: bool,
}