unifly_api/integration/client/
policy.rs1use uuid::Uuid;
2
3use super::{Error, IntegrationClient, types};
4
5impl IntegrationClient {
6 pub async fn list_acl_rules(
9 &self,
10 site_id: &Uuid,
11 offset: i64,
12 limit: i32,
13 ) -> Result<types::Page<types::AclRuleResponse>, Error> {
14 self.get_with_params(
15 &format!("v1/sites/{site_id}/acl-rules"),
16 &[("offset", offset.to_string()), ("limit", limit.to_string())],
17 )
18 .await
19 }
20
21 pub async fn get_acl_rule(
22 &self,
23 site_id: &Uuid,
24 rule_id: &Uuid,
25 ) -> Result<types::AclRuleResponse, Error> {
26 self.get(&format!("v1/sites/{site_id}/acl-rules/{rule_id}"))
27 .await
28 }
29
30 pub async fn create_acl_rule(
31 &self,
32 site_id: &Uuid,
33 body: &types::AclRuleCreateUpdate,
34 ) -> Result<types::AclRuleResponse, Error> {
35 self.post(&format!("v1/sites/{site_id}/acl-rules"), body)
36 .await
37 }
38
39 pub async fn update_acl_rule(
40 &self,
41 site_id: &Uuid,
42 rule_id: &Uuid,
43 body: &types::AclRuleCreateUpdate,
44 ) -> Result<types::AclRuleResponse, Error> {
45 self.put(&format!("v1/sites/{site_id}/acl-rules/{rule_id}"), body)
46 .await
47 }
48
49 pub async fn delete_acl_rule(&self, site_id: &Uuid, rule_id: &Uuid) -> Result<(), Error> {
50 self.delete(&format!("v1/sites/{site_id}/acl-rules/{rule_id}"))
51 .await
52 }
53
54 pub async fn get_acl_rule_ordering(
55 &self,
56 site_id: &Uuid,
57 ) -> Result<types::AclRuleOrdering, Error> {
58 self.get(&format!("v1/sites/{site_id}/acl-rules/ordering"))
59 .await
60 }
61
62 pub async fn set_acl_rule_ordering(
63 &self,
64 site_id: &Uuid,
65 body: &types::AclRuleOrdering,
66 ) -> Result<types::AclRuleOrdering, Error> {
67 self.put(&format!("v1/sites/{site_id}/acl-rules/ordering"), body)
68 .await
69 }
70
71 pub async fn list_dns_policies(
74 &self,
75 site_id: &Uuid,
76 offset: i64,
77 limit: i32,
78 ) -> Result<types::Page<types::DnsPolicyResponse>, Error> {
79 self.get_with_params(
80 &format!("v1/sites/{site_id}/dns/policies"),
81 &[("offset", offset.to_string()), ("limit", limit.to_string())],
82 )
83 .await
84 }
85
86 pub async fn get_dns_policy(
87 &self,
88 site_id: &Uuid,
89 dns_id: &Uuid,
90 ) -> Result<types::DnsPolicyResponse, Error> {
91 self.get(&format!("v1/sites/{site_id}/dns/policies/{dns_id}"))
92 .await
93 }
94
95 pub async fn create_dns_policy(
96 &self,
97 site_id: &Uuid,
98 body: &types::DnsPolicyCreateUpdate,
99 ) -> Result<types::DnsPolicyResponse, Error> {
100 self.post(&format!("v1/sites/{site_id}/dns/policies"), body)
101 .await
102 }
103
104 pub async fn update_dns_policy(
105 &self,
106 site_id: &Uuid,
107 dns_id: &Uuid,
108 body: &types::DnsPolicyCreateUpdate,
109 ) -> Result<types::DnsPolicyResponse, Error> {
110 self.put(&format!("v1/sites/{site_id}/dns/policies/{dns_id}"), body)
111 .await
112 }
113
114 pub async fn delete_dns_policy(&self, site_id: &Uuid, dns_id: &Uuid) -> Result<(), Error> {
115 self.delete(&format!("v1/sites/{site_id}/dns/policies/{dns_id}"))
116 .await
117 }
118
119 pub async fn list_traffic_matching_lists(
122 &self,
123 site_id: &Uuid,
124 offset: i64,
125 limit: i32,
126 ) -> Result<types::Page<types::TrafficMatchingListResponse>, Error> {
127 self.get_with_params(
128 &format!("v1/sites/{site_id}/traffic-matching-lists"),
129 &[("offset", offset.to_string()), ("limit", limit.to_string())],
130 )
131 .await
132 }
133
134 pub async fn get_traffic_matching_list(
135 &self,
136 site_id: &Uuid,
137 list_id: &Uuid,
138 ) -> Result<types::TrafficMatchingListResponse, Error> {
139 self.get(&format!(
140 "v1/sites/{site_id}/traffic-matching-lists/{list_id}"
141 ))
142 .await
143 }
144
145 pub async fn create_traffic_matching_list(
146 &self,
147 site_id: &Uuid,
148 body: &types::TrafficMatchingListCreateUpdate,
149 ) -> Result<types::TrafficMatchingListResponse, Error> {
150 self.post(&format!("v1/sites/{site_id}/traffic-matching-lists"), body)
151 .await
152 }
153
154 pub async fn update_traffic_matching_list(
155 &self,
156 site_id: &Uuid,
157 list_id: &Uuid,
158 body: &types::TrafficMatchingListCreateUpdate,
159 ) -> Result<types::TrafficMatchingListResponse, Error> {
160 self.put(
161 &format!("v1/sites/{site_id}/traffic-matching-lists/{list_id}"),
162 body,
163 )
164 .await
165 }
166
167 pub async fn delete_traffic_matching_list(
168 &self,
169 site_id: &Uuid,
170 list_id: &Uuid,
171 ) -> Result<(), Error> {
172 self.delete(&format!(
173 "v1/sites/{site_id}/traffic-matching-lists/{list_id}"
174 ))
175 .await
176 }
177
178 pub async fn list_vouchers(
181 &self,
182 site_id: &Uuid,
183 offset: i64,
184 limit: i32,
185 ) -> Result<types::Page<types::VoucherResponse>, Error> {
186 self.get_with_params(
187 &format!("v1/sites/{site_id}/hotspot/vouchers"),
188 &[("offset", offset.to_string()), ("limit", limit.to_string())],
189 )
190 .await
191 }
192
193 pub async fn get_voucher(
194 &self,
195 site_id: &Uuid,
196 voucher_id: &Uuid,
197 ) -> Result<types::VoucherResponse, Error> {
198 self.get(&format!("v1/sites/{site_id}/hotspot/vouchers/{voucher_id}"))
199 .await
200 }
201
202 pub async fn create_vouchers(
203 &self,
204 site_id: &Uuid,
205 body: &types::VoucherCreateRequest,
206 ) -> Result<Vec<types::VoucherResponse>, Error> {
207 self.post(&format!("v1/sites/{site_id}/hotspot/vouchers"), body)
208 .await
209 }
210
211 pub async fn delete_voucher(
212 &self,
213 site_id: &Uuid,
214 voucher_id: &Uuid,
215 ) -> Result<types::VoucherDeletionResults, Error> {
216 self.delete_with_response(&format!("v1/sites/{site_id}/hotspot/vouchers/{voucher_id}"))
217 .await
218 }
219
220 pub async fn purge_vouchers(
221 &self,
222 site_id: &Uuid,
223 filter: &str,
224 ) -> Result<types::VoucherDeletionResults, Error> {
225 self.delete_with_params(
226 &format!("v1/sites/{site_id}/hotspot/vouchers"),
227 &[("filter", filter.to_owned())],
228 )
229 .await
230 }
231}