graph_http/traits/odata_query.rs
1pub trait ODataQuery<RHS = Self>
2where
3 Self: Sized,
4{
5 fn append_query_pair<KV: AsRef<str>>(self, key: KV, value: KV) -> Self;
6
7 /// Retrieves the total count of matching resources.
8 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#count-parameter)
9 fn count<S: AsRef<str>>(self, value: S) -> Self {
10 self.append_query_pair("$count", value.as_ref())
11 }
12
13 /// Filters properties (columns).
14 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#select-parameter)
15 fn select(self, value: &[&str]) -> Self {
16 let s = value.join(",");
17 self.append_query_pair("$select", &s)
18 }
19
20 /// Retrieves related resources.
21 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#expand-parameter)
22 fn expand(self, value: &[&str]) -> Self {
23 let s = value.join(" ");
24 self.append_query_pair("$expand", &s)
25 }
26
27 /// Filters results (rows).
28 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter)
29 fn filter(self, value: &[&str]) -> Self {
30 let s = value.join(",");
31 self.append_query_pair("$filter", &s)
32 }
33
34 /// Orders results.
35 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#orderby-parameter)
36 fn order_by(self, value: &[&str]) -> Self {
37 let s = value.join(" ");
38 self.append_query_pair("$orderby", &s)
39 }
40
41 /// Returns results based on search criteria.
42 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#search-parameter)
43 fn search<S: AsRef<str>>(self, value: S) -> Self {
44 self.append_query_pair("$search", value.as_ref())
45 }
46
47 /// Returns the results in the specified media format.
48 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#format-parameter)
49 fn format<S: AsRef<str>>(self, value: S) -> Self {
50 self.append_query_pair("$format", value.as_ref())
51 }
52
53 /// Indexes into a result set. Also used by some APIs to implement paging and can be used
54 /// together with $top to manually page results.
55 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#skip-parameter)
56 fn skip<S: AsRef<str>>(self, value: S) -> Self {
57 self.append_query_pair("$skip", value.as_ref())
58 }
59
60 /// Retrieves the next page of results from result sets that span multiple pages.
61 /// (Some APIs use $skip instead.)
62 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#skiptoken-parameter)
63 fn skip_token<S: AsRef<str>>(self, value: S) -> Self {
64 self.append_query_pair("$skipToken", value.as_ref())
65 }
66
67 /// Retrieves the next page of results from result sets that span multiple pages.
68 /// (Some APIs use $skip instead.)
69 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#skiptoken-parameter)
70 fn delta_token<S: AsRef<str>>(self, value: S) -> Self {
71 self.append_query_pair("$deltaToken", value.as_ref())
72 }
73
74 /// Sets the page size of results.
75 /// [See the docs](https://docs.microsoft.com/en-us/graph/query-parameters#top-parameter)
76 fn top<S: AsRef<str>>(self, value: S) -> Self {
77 self.append_query_pair("$top", value.as_ref())
78 }
79}