1#![allow(clippy::too_many_arguments)]
4
5use std::sync::Arc;
6
7use crate::errors::Error;
8use crate::http::ClientInner;
9use crate::types_gen::*;
10
11pub struct Client {
13 pub accounts: AccountsService,
14 pub users: UsersService,
15 pub regions: RegionsService,
16 pub clusters: ClustersService,
17 pub region_clusters: RegionClustersService,
18 pub storages: StoragesService,
19 pub volumes: VolumesService,
20 pub volume_fork_trees: VolumeForkTreesService,
21 pub volume_fork_entries: VolumeForkEntriesService,
22 pub volume_fork_searches: VolumeForkSearchesService,
23 pub audit_logs: AuditLogsService,
24 pub region_audit_logs: RegionAuditLogsService,
25 pub service_nodes: ServiceNodesService,
26 pub nodes: NodesService,
27 pub client_sessions: ClientSessionsService,
28 pub discover: DiscoverService,
29 pub dashboard: DashboardService,
30 pub license: LicenseService,
31 pub alerts: AlertsService,
32 pub region_alerts: RegionAlertsService,
33 pub gc_worker_events: GCWorkerEventsService,
34 pub vault: VaultService,
35}
36
37impl Client {
38 pub fn new(config: Config) -> Result<Self, Error> {
40 let inner = Arc::new(ClientInner::new(config)?);
41 Ok(Self {
42 accounts: AccountsService { inner: Arc::clone(&inner) },
43 users: UsersService { inner: Arc::clone(&inner) },
44 regions: RegionsService { inner: Arc::clone(&inner) },
45 clusters: ClustersService { inner: Arc::clone(&inner) },
46 region_clusters: RegionClustersService { inner: Arc::clone(&inner) },
47 storages: StoragesService { inner: Arc::clone(&inner) },
48 volumes: VolumesService { inner: Arc::clone(&inner) },
49 volume_fork_trees: VolumeForkTreesService { inner: Arc::clone(&inner) },
50 volume_fork_entries: VolumeForkEntriesService { inner: Arc::clone(&inner) },
51 volume_fork_searches: VolumeForkSearchesService { inner: Arc::clone(&inner) },
52 audit_logs: AuditLogsService { inner: Arc::clone(&inner) },
53 region_audit_logs: RegionAuditLogsService { inner: Arc::clone(&inner) },
54 service_nodes: ServiceNodesService { inner: Arc::clone(&inner) },
55 nodes: NodesService { inner: Arc::clone(&inner) },
56 client_sessions: ClientSessionsService { inner: Arc::clone(&inner) },
57 discover: DiscoverService { inner: Arc::clone(&inner) },
58 dashboard: DashboardService { inner: Arc::clone(&inner) },
59 license: LicenseService { inner: Arc::clone(&inner) },
60 alerts: AlertsService { inner: Arc::clone(&inner) },
61 region_alerts: RegionAlertsService { inner: Arc::clone(&inner) },
62 gc_worker_events: GCWorkerEventsService { inner: Arc::clone(&inner) },
63 vault: VaultService { inner: Arc::clone(&inner) },
64 })
65 }
66}
67
68pub struct AccountsService {
70 inner: Arc<ClientInner>,
71}
72
73impl AccountsService {
74 pub async fn create(&self, req: &CreateAccountRequest) -> Result<IdResponse, Error> {
75 self.inner.post("/api/v1/accounts/create", req).await
76 }
77
78 pub async fn list(&self, opts: Option<&AccountListOptions>) -> Result<PaginatedResponse<Account>, Error> {
79 let mut query: Vec<(&str, String)> = Vec::new();
80 if let Some(opts) = opts {
81 if let Some(v) = &opts.is_active {
82 query.push(("isActive", v.to_string()));
83 }
84 if let Some(v) = &opts.page {
85 query.push(("page", v.to_string()));
86 }
87 if let Some(v) = &opts.limit {
88 query.push(("limit", v.to_string()));
89 }
90 }
91 self.inner.get("/api/v1/accounts/list", &query).await
92 }
93
94 pub async fn get(&self, account_id: i64) -> Result<Account, Error> {
95 self.inner.get(&format!("/api/v1/accounts/{}", account_id), &[]).await
96 }
97
98 pub async fn edit(&self, account_id: i64, req: &EditAccountRequest) -> Result<IdResponse, Error> {
99 self.inner.put(&format!("/api/v1/accounts/{}/edit", account_id), req).await
100 }
101
102 pub async fn lock(&self, account_id: i64) -> Result<IdResponse, Error> {
103 self.inner.post_empty(&format!("/api/v1/accounts/{}/lock", account_id)).await
104 }
105
106 pub async fn unlock(&self, account_id: i64) -> Result<IdResponse, Error> {
107 self.inner.post_empty(&format!("/api/v1/accounts/{}/unlock", account_id)).await
108 }
109
110 pub async fn deactivate(&self, account_id: i64) -> Result<IdResponse, Error> {
111 self.inner.post_empty(&format!("/api/v1/accounts/{}/deactivate", account_id)).await
112 }
113
114 pub async fn update_quota(&self, account_id: i64, req: &UpdateAccountQuotaRequest) -> Result<IdResponse, Error> {
115 self.inner.put(&format!("/api/v1/accounts/{}/quota", account_id), req).await
116 }
117}
118
119pub struct UsersService {
121 inner: Arc<ClientInner>,
122}
123
124impl UsersService {
125 pub async fn add(&self, req: &AddUserRequest) -> Result<IdResponse, Error> {
126 self.inner.post("/api/v1/users/add", req).await
127 }
128
129 pub async fn list(&self, opts: &UserListOptions) -> Result<PaginatedResponse<User>, Error> {
130 let mut query: Vec<(&str, String)> = Vec::new();
131 query.push(("accountId", opts.account_id.to_string()));
132 if let Some(v) = &opts.search {
133 query.push(("search", v.to_string()));
134 }
135 if let Some(v) = &opts.is_active {
136 query.push(("isActive", v.to_string()));
137 }
138 if let Some(v) = &opts.page {
139 query.push(("page", v.to_string()));
140 }
141 if let Some(v) = &opts.limit {
142 query.push(("limit", v.to_string()));
143 }
144 self.inner.get("/api/v1/users/list", &query).await
145 }
146
147 pub async fn get(&self, user_id: i64) -> Result<User, Error> {
148 self.inner.get(&format!("/api/v1/users/{}", user_id), &[]).await
149 }
150
151 pub async fn bulk(&self, req: &BulkUserRequest) -> Result<BulkUserResponse, Error> {
152 self.inner.post("/api/v1/users/bulk", req).await
153 }
154
155 pub async fn edit(&self, user_id: i64, req: &EditUserRequest) -> Result<IdResponse, Error> {
156 self.inner.put(&format!("/api/v1/users/{}/edit", user_id), req).await
157 }
158
159 pub async fn deactivate(&self, user_id: i64) -> Result<IdResponse, Error> {
160 self.inner.post_empty(&format!("/api/v1/users/{}/deactivate", user_id)).await
161 }
162}
163
164pub struct RegionsService {
166 inner: Arc<ClientInner>,
167}
168
169impl RegionsService {
170 pub async fn create(&self, req: &CreateRegionRequest) -> Result<IdResponse, Error> {
171 self.inner.post("/api/v1/regions/create", req).await
172 }
173
174 pub async fn list(&self, opts: &RegionListOptions) -> Result<PaginatedResponse<Region>, Error> {
175 let mut query: Vec<(&str, String)> = Vec::new();
176 query.push(("accountId", opts.account_id.to_string()));
177 if let Some(v) = &opts.is_active {
178 query.push(("isActive", v.to_string()));
179 }
180 if let Some(v) = &opts.page {
181 query.push(("page", v.to_string()));
182 }
183 if let Some(v) = &opts.limit {
184 query.push(("limit", v.to_string()));
185 }
186 self.inner.get("/api/v1/regions/list", &query).await
187 }
188
189 pub async fn get(&self, region_id: i64) -> Result<Region, Error> {
190 self.inner.get(&format!("/api/v1/regions/{}", region_id), &[]).await
191 }
192
193 pub async fn edit(&self, region_id: i64, req: &EditRegionRequest) -> Result<IdResponse, Error> {
194 self.inner.put(&format!("/api/v1/regions/{}/edit", region_id), req).await
195 }
196
197 pub async fn deactivate(&self, region_id: i64) -> Result<IdResponse, Error> {
198 self.inner.post_empty(&format!("/api/v1/regions/{}/deactivate", region_id)).await
199 }
200}
201
202pub struct ClustersService {
204 inner: Arc<ClientInner>,
205}
206
207impl ClustersService {
208 pub async fn list(&self, opts: &ClusterListOptions) -> Result<PaginatedResponse<RegionCluster>, Error> {
209 let mut query: Vec<(&str, String)> = Vec::new();
210 query.push(("accountId", opts.account_id.to_string()));
211 if let Some(v) = &opts.region_id {
212 query.push(("regionId", v.to_string()));
213 }
214 if let Some(v) = &opts.is_active {
215 query.push(("isActive", v.to_string()));
216 }
217 if let Some(v) = &opts.page {
218 query.push(("page", v.to_string()));
219 }
220 if let Some(v) = &opts.limit {
221 query.push(("limit", v.to_string()));
222 }
223 self.inner.get("/api/v1/clusters/list", &query).await
224 }
225}
226
227pub struct RegionClustersService {
229 inner: Arc<ClientInner>,
230}
231
232impl RegionClustersService {
233 pub async fn create(&self, region_id: i64, req: &CreateRegionClusterRequest) -> Result<IdResponse, Error> {
234 self.inner.post(&format!("/api/v1/regions/{}/clusters/create", region_id), req).await
235 }
236
237 pub async fn list(&self, region_id: i64, opts: Option<&RegionClusterListOptions>) -> Result<PaginatedResponse<RegionCluster>, Error> {
238 let mut query: Vec<(&str, String)> = Vec::new();
239 if let Some(opts) = opts {
240 if let Some(v) = &opts.is_active {
241 query.push(("isActive", v.to_string()));
242 }
243 if let Some(v) = &opts.page {
244 query.push(("page", v.to_string()));
245 }
246 if let Some(v) = &opts.limit {
247 query.push(("limit", v.to_string()));
248 }
249 }
250 self.inner.get(&format!("/api/v1/regions/{}/clusters/list", region_id), &query).await
251 }
252
253 pub async fn get(&self, region_id: i64, cluster_id: i64) -> Result<RegionCluster, Error> {
254 self.inner.get(&format!("/api/v1/regions/{}/clusters/{}", region_id, cluster_id), &[]).await
255 }
256
257 pub async fn edit(&self, region_id: i64, cluster_id: i64, req: &EditRegionClusterRequest) -> Result<IdResponse, Error> {
258 self.inner.put(&format!("/api/v1/regions/{}/clusters/{}/edit", region_id, cluster_id), req).await
259 }
260
261 pub async fn set_default(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
262 self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/set-default", region_id, cluster_id)).await
263 }
264
265 pub async fn set_ready(&self, region_id: i64, cluster_id: i64, req: &SetRegionClusterReadyRequest) -> Result<SetReadyRegionClusterResponse, Error> {
266 self.inner.post(&format!("/api/v1/regions/{}/clusters/{}/set-ready", region_id, cluster_id), req).await
267 }
268
269 pub async fn deactivate(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
270 self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/deactivate", region_id, cluster_id)).await
271 }
272}
273
274pub struct StoragesService {
276 inner: Arc<ClientInner>,
277}
278
279impl StoragesService {
280 pub async fn create(&self, req: &CreateStorageRequest) -> Result<CreateStorageResponse, Error> {
281 self.inner.post("/api/v1/storages/create", req).await
282 }
283
284 pub async fn list(&self, opts: &StorageListOptions) -> Result<PaginatedResponse<Storage>, Error> {
285 let mut query: Vec<(&str, String)> = Vec::new();
286 query.push(("accountId", opts.account_id.to_string()));
287 if let Some(v) = &opts.search {
288 query.push(("search", v.to_string()));
289 }
290 if let Some(v) = &opts.region_id {
291 query.push(("regionId", v.to_string()));
292 }
293 if let Some(v) = &opts.storage_type {
294 query.push(("storageType", v.to_string()));
295 }
296 if let Some(v) = &opts.provider_type {
297 query.push(("providerType", v.to_string()));
298 }
299 if let Some(v) = &opts.is_active {
300 query.push(("isActive", v.to_string()));
301 }
302 if let Some(v) = &opts.direct_access {
303 query.push(("directAccess", v.to_string()));
304 }
305 if let Some(v) = &opts.page {
306 query.push(("page", v.to_string()));
307 }
308 if let Some(v) = &opts.limit {
309 query.push(("limit", v.to_string()));
310 }
311 self.inner.get("/api/v1/storages/list", &query).await
312 }
313
314 pub async fn get(&self, storage_id: i64) -> Result<Storage, Error> {
315 self.inner.get(&format!("/api/v1/storages/{}", storage_id), &[]).await
316 }
317
318 pub async fn list_block_volumes(&self, storage_id: i64) -> Result<Vec<BlockVolume>, Error> {
319 self.inner.get(&format!("/api/v1/storages/{}/block-volumes", storage_id), &[]).await
320 }
321
322 pub async fn edit(&self, storage_id: i64, req: &EditStorageRequest) -> Result<IdResponse, Error> {
323 self.inner.put(&format!("/api/v1/storages/{}/edit", storage_id), req).await
324 }
325
326 pub async fn deactivate(&self, storage_id: i64) -> Result<IdResponse, Error> {
327 self.inner.post_empty(&format!("/api/v1/storages/{}/deactivate", storage_id)).await
328 }
329
330 pub async fn test_bucket(&self, req: &TestStorageBucketRequest) -> Result<TestBucketStorageResponse, Error> {
331 self.inner.post("/api/v1/storages/test-bucket", req).await
332 }
333
334 pub async fn test_storage_bucket(&self, storage_id: i64) -> Result<TestStorageBucketStorageResponse, Error> {
335 self.inner.post_empty(&format!("/api/v1/storages/{}/test-bucket", storage_id)).await
336 }
337
338 pub async fn list_compatible(&self, storage_id: i64) -> Result<ListCompatibleStorageResponse, Error> {
339 self.inner.get(&format!("/api/v1/storages/{}/compatible", storage_id), &[]).await
340 }
341
342 pub async fn move_volumes(&self, storage_id: i64, req: &MoveStorageVolumesRequest) -> Result<MoveVolumesStorageResponse, Error> {
343 self.inner.post(&format!("/api/v1/storages/{}/move-volumes", storage_id), req).await
344 }
345
346 pub async fn backfill_fingerprints(&self) -> Result<BackfillFingerprintsStorageResponse, Error> {
347 self.inner.post_empty("/api/v1/storages/backfill-fingerprints").await
348 }
349}
350
351pub struct VolumesService {
353 inner: Arc<ClientInner>,
354}
355
356impl VolumesService {
357 pub async fn create(&self, req: &CreateVolumeRequest) -> Result<CreateVolumeResponse, Error> {
358 self.inner.post("/api/v1/volumes/create", req).await
359 }
360
361 pub async fn list(&self, opts: &VolumeListOptions) -> Result<PaginatedResponse<Volume>, Error> {
362 let mut query: Vec<(&str, String)> = Vec::new();
363 query.push(("accountId", opts.account_id.to_string()));
364 if let Some(v) = &opts.region_id {
365 query.push(("regionId", v.to_string()));
366 }
367 if let Some(v) = &opts.region_cluster_id {
368 query.push(("regionClusterId", v.to_string()));
369 }
370 if let Some(v) = &opts.storage_id {
371 query.push(("storageId", v.to_string()));
372 }
373 if let Some(v) = &opts.volume_type {
374 query.push(("volumeType", v.to_string()));
375 }
376 if let Some(v) = &opts.locked {
377 query.push(("locked", v.to_string()));
378 }
379 if let Some(v) = &opts.is_active {
380 query.push(("isActive", v.to_string()));
381 }
382 if let Some(v) = &opts.page {
383 query.push(("page", v.to_string()));
384 }
385 if let Some(v) = &opts.limit {
386 query.push(("limit", v.to_string()));
387 }
388 self.inner.get("/api/v1/volumes/list", &query).await
389 }
390
391 pub async fn get(&self, volume_id: i64) -> Result<Volume, Error> {
392 self.inner.get(&format!("/api/v1/volumes/{}", volume_id), &[]).await
393 }
394
395 pub async fn edit(&self, volume_id: i64, req: &EditVolumeRequest) -> Result<IdResponse, Error> {
396 self.inner.put(&format!("/api/v1/volumes/{}/edit", volume_id), req).await
397 }
398
399 pub async fn lock(&self, volume_id: i64) -> Result<IdResponse, Error> {
400 self.inner.post_empty(&format!("/api/v1/volumes/{}/lock", volume_id)).await
401 }
402
403 pub async fn unlock(&self, volume_id: i64) -> Result<IdResponse, Error> {
404 self.inner.post_empty(&format!("/api/v1/volumes/{}/unlock", volume_id)).await
405 }
406
407 pub async fn move_cluster(&self, volume_id: i64, req: &MoveVolumeClusterRequest) -> Result<MoveClusterVolumeResponse, Error> {
408 self.inner.post(&format!("/api/v1/volumes/{}/move-cluster", volume_id), req).await
409 }
410
411 pub async fn deactivate(&self, volume_id: i64, req: &DeactivateVolumeRequest) -> Result<IdResponse, Error> {
412 self.inner.post(&format!("/api/v1/volumes/{}/deactivate", volume_id), req).await
413 }
414
415 pub async fn activate(&self, volume_id: i64) -> Result<IdResponse, Error> {
416 self.inner.post_empty(&format!("/api/v1/volumes/{}/activate", volume_id)).await
417 }
418
419 pub async fn generate_api_keys(&self, volume_id: i64, req: &GenerateVolumeAPIKeysRequest) -> Result<GenerateAPIKeysVolumeResponse, Error> {
420 self.inner.post(&format!("/api/v1/volumes/{}/api-keys/generate", volume_id), req).await
421 }
422
423 pub async fn list_api_keys(&self, volume_id: i64) -> Result<ListAPIKeysVolumeResponse, Error> {
424 self.inner.get(&format!("/api/v1/volumes/{}/api-keys", volume_id), &[]).await
425 }
426
427 pub async fn revoke_api_key(&self, volume_id: i64, req: &RevokeVolumeAPIKeyRequest) -> Result<(), Error> {
428 self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke", volume_id), req).await.map(|_| ())
429 }
430
431 pub async fn revoke_api_keys_by_user(&self, volume_id: i64, req: &RevokeVolumeAPIKeysByUserRequest) -> Result<(), Error> {
432 self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke-by-user", volume_id), req).await.map(|_| ())
433 }
434
435 pub async fn generate_stt_key(&self, volume_id: i64, req: &GenerateVolumeSttKeyRequest) -> Result<GenerateSttKeyVolumeResponse, Error> {
436 self.inner.post(&format!("/api/v1/volumes/{}/stt-key/generate", volume_id), req).await
437 }
438
439 pub async fn update_quota(&self, volume_id: i64, req: &UpdateVolumeQuotaRequest) -> Result<IdResponse, Error> {
440 self.inner.put(&format!("/api/v1/volumes/{}/quota", volume_id), req).await
441 }
442
443 pub async fn stats(&self, volume_id: i64) -> Result<StatsVolumeResponse, Error> {
444 self.inner.get(&format!("/api/v1/volumes/{}/stats", volume_id), &[]).await
445 }
446
447 pub async fn size_history(&self, volume_id: i64, from: Option<&str>, to: Option<&str>) -> Result<SizeHistoryVolumeResponse, Error> {
448 let mut query: Vec<(&str, String)> = Vec::new();
449 if let Some(v) = from {
450 query.push(("from", v.to_string()));
451 }
452 if let Some(v) = to {
453 query.push(("to", v.to_string()));
454 }
455 self.inner.get(&format!("/api/v1/volumes/{}/size-history", volume_id), &query).await
456 }
457
458 pub async fn create_fork(&self, volume_id: i64, req: &CreateVolumeForkRequest) -> Result<Fork, Error> {
459 self.inner.post(&format!("/api/v1/volumes/{}/forks/create", volume_id), req).await
460 }
461
462 pub async fn list_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
463 let mut query: Vec<(&str, String)> = Vec::new();
464 if let Some(v) = volume_type {
465 query.push(("volumeType", v.to_string()));
466 }
467 self.inner.get(&format!("/api/v1/volumes/{}/forks", volume_id), &query).await
468 }
469
470 pub async fn list_all_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
471 let mut query: Vec<(&str, String)> = Vec::new();
472 if let Some(v) = volume_type {
473 query.push(("volumeType", v.to_string()));
474 }
475 self.inner.get(&format!("/api/v1/volumes/{}/forks?include_inactive=true", volume_id), &query).await
476 }
477
478 pub async fn delete_fork(&self, volume_id: i64, fork_name: &str, req: &DeleteVolumeForkRequest) -> Result<DeleteForkVolumeResponse, Error> {
479 self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/delete", volume_id, fork_name), req).await
480 }
481
482 pub async fn restore_fork(&self, volume_id: i64, fork_name: &str, req: &RestoreVolumeForkRequest) -> Result<Fork, Error> {
483 self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/restore", volume_id, fork_name), req).await
484 }
485}
486
487pub struct VolumeForkTreesService {
489 inner: Arc<ClientInner>,
490}
491
492impl VolumeForkTreesService {
493 pub async fn list(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkTreeListOptions>) -> Result<CursorPaginatedResponse<ForkTreeEntry>, Error> {
494 let mut query: Vec<(&str, String)> = Vec::new();
495 if let Some(opts) = opts {
496 if let Some(v) = &opts.path {
497 query.push(("path", v.to_string()));
498 }
499 if let Some(v) = &opts.as_of {
500 query.push(("asOf", v.to_string()));
501 }
502 if let Some(v) = &opts.cursor {
503 query.push(("cursor", v.to_string()));
504 }
505 if let Some(v) = &opts.limit {
506 query.push(("limit", v.to_string()));
507 }
508 if let Some(v) = &opts.sort {
509 query.push(("sort", v.to_string()));
510 }
511 if let Some(v) = &opts.kind {
512 query.push(("kind", v.to_string()));
513 }
514 }
515 self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/tree", volume_id, fork_name), &query).await
516 }
517}
518
519pub struct VolumeForkEntriesService {
521 inner: Arc<ClientInner>,
522}
523
524impl VolumeForkEntriesService {
525 pub async fn get(&self, volume_id: i64, fork_name: &str, path: Option<&str>, inode: Option<i64>, as_of: Option<i64>) -> Result<ForkEntryDetail, Error> {
526 let mut query: Vec<(&str, String)> = Vec::new();
527 if let Some(v) = path {
528 query.push(("path", v.to_string()));
529 }
530 if let Some(v) = inode {
531 query.push(("inode", v.to_string()));
532 }
533 if let Some(v) = as_of {
534 query.push(("asOf", v.to_string()));
535 }
536 self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry", volume_id, fork_name), &query).await
537 }
538
539 pub async fn versions(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkEntryListOptions>) -> Result<CursorPaginatedResponse<ForkEntryVersion>, Error> {
540 let mut query: Vec<(&str, String)> = Vec::new();
541 if let Some(opts) = opts {
542 if let Some(v) = &opts.path {
543 query.push(("path", v.to_string()));
544 }
545 if let Some(v) = &opts.cursor {
546 query.push(("cursor", v.to_string()));
547 }
548 if let Some(v) = &opts.limit {
549 query.push(("limit", v.to_string()));
550 }
551 }
552 self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry/versions", volume_id, fork_name), &query).await
553 }
554}
555
556pub struct VolumeForkSearchesService {
558 inner: Arc<ClientInner>,
559}
560
561impl VolumeForkSearchesService {
562 pub async fn find(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkSearchListOptions>) -> Result<CursorPaginatedResponse<ForkTreeMatch>, Error> {
563 let mut query: Vec<(&str, String)> = Vec::new();
564 if let Some(opts) = opts {
565 if let Some(v) = &opts.q {
566 query.push(("q", v.to_string()));
567 }
568 if let Some(v) = &opts.path {
569 query.push(("path", v.to_string()));
570 }
571 if let Some(v) = &opts.as_of {
572 query.push(("asOf", v.to_string()));
573 }
574 if let Some(v) = &opts.exact {
575 query.push(("exact", v.to_string()));
576 }
577 if let Some(v) = &opts.cursor {
578 query.push(("cursor", v.to_string()));
579 }
580 if let Some(v) = &opts.limit {
581 query.push(("limit", v.to_string()));
582 }
583 if let Some(v) = &opts.kind {
584 query.push(("kind", v.to_string()));
585 }
586 }
587 self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/search", volume_id, fork_name), &query).await
588 }
589}
590
591pub struct AuditLogsService {
593 inner: Arc<ClientInner>,
594}
595
596impl AuditLogsService {
597 pub async fn list(&self, opts: &AuditLogListOptions) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
598 let mut query: Vec<(&str, String)> = Vec::new();
599 query.push(("accountId", opts.account_id.to_string()));
600 if let Some(v) = &opts.region_id {
601 query.push(("regionId", v.to_string()));
602 }
603 if let Some(v) = &opts.region_cluster_id {
604 query.push(("regionClusterId", v.to_string()));
605 }
606 if let Some(v) = &opts.cursor {
607 query.push(("cursor", v.to_string()));
608 }
609 if let Some(v) = &opts.limit {
610 query.push(("limit", v.to_string()));
611 }
612 if let Some(v) = &opts.subject {
613 query.push(("subject", v.to_string()));
614 }
615 self.inner.get("/api/v1/audit-logs/list", &query).await
616 }
617}
618
619pub struct RegionAuditLogsService {
621 inner: Arc<ClientInner>,
622}
623
624impl RegionAuditLogsService {
625 pub async fn list(&self, region_id: i64, opts: Option<&RegionAuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
626 let mut query: Vec<(&str, String)> = Vec::new();
627 if let Some(opts) = opts {
628 if let Some(v) = &opts.region_cluster_id {
629 query.push(("regionClusterId", v.to_string()));
630 }
631 if let Some(v) = &opts.cursor {
632 query.push(("cursor", v.to_string()));
633 }
634 if let Some(v) = &opts.limit {
635 query.push(("limit", v.to_string()));
636 }
637 if let Some(v) = &opts.subject {
638 query.push(("subject", v.to_string()));
639 }
640 if let Some(v) = &opts.node {
641 query.push(("node", v.to_string()));
642 }
643 }
644 self.inner.get(&format!("/api/v1/regions/{}/audit-logs/list", region_id), &query).await
645 }
646}
647
648pub struct ServiceNodesService {
650 inner: Arc<ClientInner>,
651}
652
653impl ServiceNodesService {
654 pub async fn list(&self, region_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>, region_cluster_id: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
655 let mut query: Vec<(&str, String)> = Vec::new();
656 if let Some(v) = service_type {
657 query.push(("serviceType", v.to_string()));
658 }
659 if let Some(v) = status {
660 query.push(("status", v.to_string()));
661 }
662 if let Some(v) = inactive_hours {
663 query.push(("inactiveHours", v.to_string()));
664 }
665 if let Some(v) = region_cluster_id {
666 query.push(("regionClusterId", v.to_string()));
667 }
668 self.inner.get(&format!("/api/v1/regions/{}/nodes", region_id), &query).await
669 }
670
671 pub async fn stats(&self, region_id: i64, node_id: &str) -> Result<String, Error> {
672 self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats", region_id, crate::http::encode_segment(node_id)), &[]).await
673 }
674
675 pub async fn stats_history(&self, region_id: i64, node_id: &str) -> Result<StatsHistoryServiceNodeResponse, Error> {
676 self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats/history", region_id, crate::http::encode_segment(node_id)), &[]).await
677 }
678}
679
680pub struct NodesService {
682 inner: Arc<ClientInner>,
683}
684
685impl NodesService {
686 pub async fn list_all(&self, account_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
687 let mut query: Vec<(&str, String)> = Vec::new();
688 query.push(("accountId", account_id.to_string()));
689 if let Some(v) = service_type {
690 query.push(("serviceType", v.to_string()));
691 }
692 if let Some(v) = status {
693 query.push(("status", v.to_string()));
694 }
695 if let Some(v) = inactive_hours {
696 query.push(("inactiveHours", v.to_string()));
697 }
698 self.inner.get("/api/v1/nodes", &query).await
699 }
700}
701
702pub struct ClientSessionsService {
704 inner: Arc<ClientInner>,
705}
706
707impl ClientSessionsService {
708 pub async fn list(&self, opts: &ClientSessionListOptions) -> Result<PaginatedResponse<ClientSession>, Error> {
709 let mut query: Vec<(&str, String)> = Vec::new();
710 query.push(("accountId", opts.account_id.to_string()));
711 if let Some(v) = &opts.region_id {
712 query.push(("regionId", v.to_string()));
713 }
714 if let Some(v) = &opts.region_cluster_id {
715 query.push(("regionClusterId", v.to_string()));
716 }
717 if let Some(v) = &opts.volume_id {
718 query.push(("volumeId", v.to_string()));
719 }
720 if let Some(v) = &opts.user_id {
721 query.push(("userId", v.to_string()));
722 }
723 if let Some(v) = &opts.client_type {
724 query.push(("clientType", v.to_string()));
725 }
726 if let Some(v) = &opts.status {
727 query.push(("status", v.to_string()));
728 }
729 if let Some(v) = &opts.is_active {
730 query.push(("isActive", v.to_string()));
731 }
732 if let Some(v) = &opts.os_name {
733 query.push(("osName", v.to_string()));
734 }
735 if let Some(v) = &opts.platform {
736 query.push(("platform", v.to_string()));
737 }
738 if let Some(v) = &opts.search {
739 query.push(("search", v.to_string()));
740 }
741 if let Some(v) = &opts.page {
742 query.push(("page", v.to_string()));
743 }
744 if let Some(v) = &opts.limit {
745 query.push(("limit", v.to_string()));
746 }
747 self.inner.get("/api/v1/client-sessions/list", &query).await
748 }
749
750 pub async fn get(&self, session_id: i64) -> Result<ClientSession, Error> {
751 self.inner.get(&format!("/api/v1/client-sessions/{}", session_id), &[]).await
752 }
753
754 pub async fn summary(&self, account_id: i64, region_id: Option<i64>, region_cluster_id: Option<i64>, volume_id: Option<i64>, user_id: Option<i64>) -> Result<SessionSummary, Error> {
755 let mut query: Vec<(&str, String)> = Vec::new();
756 query.push(("accountId", account_id.to_string()));
757 if let Some(v) = region_id {
758 query.push(("regionId", v.to_string()));
759 }
760 if let Some(v) = region_cluster_id {
761 query.push(("regionClusterId", v.to_string()));
762 }
763 if let Some(v) = volume_id {
764 query.push(("volumeId", v.to_string()));
765 }
766 if let Some(v) = user_id {
767 query.push(("userId", v.to_string()));
768 }
769 self.inner.get("/api/v1/client-sessions/summary", &query).await
770 }
771}
772
773pub struct DiscoverService {
775 inner: Arc<ClientInner>,
776}
777
778impl DiscoverService {
779 pub async fn meta(&self, access_key_id: &str) -> Result<DiscoverMetaResponse, Error> {
780 let mut query: Vec<(&str, String)> = Vec::new();
781 query.push(("access_key_id", access_key_id.to_string()));
782 self.inner.get("/api/v1/discover/meta", &query).await
783 }
784}
785
786pub struct DashboardService {
788 inner: Arc<ClientInner>,
789}
790
791impl DashboardService {
792 pub async fn stats(&self, account_id: i64) -> Result<DashboardStats, Error> {
793 let mut query: Vec<(&str, String)> = Vec::new();
794 query.push(("accountId", account_id.to_string()));
795 self.inner.get("/api/v1/dashboard/stats", &query).await
796 }
797}
798
799pub struct LicenseService {
801 inner: Arc<ClientInner>,
802}
803
804impl LicenseService {
805 pub async fn get(&self) -> Result<LicenseDetails, Error> {
806 self.inner.get("/api/v1/license", &[]).await
807 }
808
809 pub async fn terms(&self) -> Result<LicenseTerms, Error> {
810 self.inner.get("/api/v1/license/terms", &[]).await
811 }
812
813 pub async fn load(&self, req: &LoadLicenseRequest) -> Result<LicenseLoadResult, Error> {
814 self.inner.post("/api/v1/license/load", req).await
815 }
816
817 pub async fn list(&self) -> Result<LicenseList, Error> {
818 self.inner.get("/api/v1/license/list", &[]).await
819 }
820}
821
822pub struct AlertsService {
824 inner: Arc<ClientInner>,
825}
826
827impl AlertsService {
828 pub async fn list(&self, opts: Option<&AlertListOptions>) -> Result<PaginatedResponse<ServiceAlert>, Error> {
829 let mut query: Vec<(&str, String)> = Vec::new();
830 if let Some(opts) = opts {
831 if let Some(v) = &opts.active {
832 query.push(("active", v.to_string()));
833 }
834 if let Some(v) = &opts.account_id {
835 query.push(("accountId", v.to_string()));
836 }
837 if let Some(v) = &opts.region_id {
838 query.push(("regionId", v.to_string()));
839 }
840 if let Some(v) = &opts.severity {
841 query.push(("severity", v.to_string()));
842 }
843 if let Some(v) = &opts.category {
844 query.push(("category", v.to_string()));
845 }
846 if let Some(v) = &opts.since {
847 query.push(("since", v.to_string()));
848 }
849 if let Some(v) = &opts.page {
850 query.push(("page", v.to_string()));
851 }
852 if let Some(v) = &opts.limit {
853 query.push(("limit", v.to_string()));
854 }
855 }
856 self.inner.get("/api/v1/alerts/list", &query).await
857 }
858
859 pub async fn count(&self) -> Result<AlertCountResponse, Error> {
860 self.inner.get("/api/v1/alerts/count", &[]).await
861 }
862
863 pub async fn resolve(&self, alert_id: &str) -> Result<(), Error> {
864 self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/alerts/{}/resolve", alert_id)).await.map(|_| ())
865 }
866}
867
868pub struct RegionAlertsService {
870 inner: Arc<ClientInner>,
871}
872
873impl RegionAlertsService {
874 pub async fn list(&self, region_id: i64, opts: Option<&RegionAlertListOptions>) -> Result<PaginatedResponse<RegionAlert>, Error> {
875 let mut query: Vec<(&str, String)> = Vec::new();
876 if let Some(opts) = opts {
877 if let Some(v) = &opts.active {
878 query.push(("active", v.to_string()));
879 }
880 if let Some(v) = &opts.severity {
881 query.push(("severity", v.to_string()));
882 }
883 if let Some(v) = &opts.category {
884 query.push(("category", v.to_string()));
885 }
886 if let Some(v) = &opts.node_id {
887 query.push(("nodeId", v.to_string()));
888 }
889 if let Some(v) = &opts.region_cluster_id {
890 query.push(("regionClusterId", v.to_string()));
891 }
892 if let Some(v) = &opts.since {
893 query.push(("since", v.to_string()));
894 }
895 if let Some(v) = &opts.page {
896 query.push(("page", v.to_string()));
897 }
898 if let Some(v) = &opts.limit {
899 query.push(("limit", v.to_string()));
900 }
901 }
902 self.inner.get(&format!("/api/v1/regions/{}/alerts/list", region_id), &query).await
903 }
904
905 pub async fn count(&self, region_id: i64, region_cluster_id: Option<i64>) -> Result<AlertCountResponse, Error> {
906 let mut query: Vec<(&str, String)> = Vec::new();
907 if let Some(v) = region_cluster_id {
908 query.push(("regionClusterId", v.to_string()));
909 }
910 self.inner.get(&format!("/api/v1/regions/{}/alerts/count", region_id), &query).await
911 }
912
913 pub async fn resolve(&self, region_id: i64, alert_id: &str) -> Result<(), Error> {
914 self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/regions/{}/alerts/{}/resolve", region_id, alert_id)).await.map(|_| ())
915 }
916}
917
918pub struct GCWorkerEventsService {
920 inner: Arc<ClientInner>,
921}
922
923impl GCWorkerEventsService {
924 pub async fn list(&self, region_id: i64, opts: Option<&GCWorkerEventListOptions>) -> Result<PaginatedResponse<GCWorkerEvent>, Error> {
925 let mut query: Vec<(&str, String)> = Vec::new();
926 if let Some(opts) = opts {
927 if let Some(v) = &opts.node_id {
928 query.push(("nodeId", v.to_string()));
929 }
930 if let Some(v) = &opts.goal {
931 query.push(("goal", v.to_string()));
932 }
933 if let Some(v) = &opts.sid {
934 query.push(("sid", v.to_string()));
935 }
936 if let Some(v) = &opts.region_cluster_id {
937 query.push(("regionClusterId", v.to_string()));
938 }
939 if let Some(v) = &opts.since {
940 query.push(("since", v.to_string()));
941 }
942 if let Some(v) = &opts.page {
943 query.push(("page", v.to_string()));
944 }
945 if let Some(v) = &opts.limit {
946 query.push(("limit", v.to_string()));
947 }
948 }
949 self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/list", region_id), &query).await
950 }
951
952 pub async fn histogram(&self, region_id: i64, node_id: Option<&str>, goal: Option<&str>, sid: Option<i64>, region_cluster_id: Option<i64>, since: Option<&str>, bucket_seconds: Option<i64>) -> Result<GCWorkerEventHistogramResponse, Error> {
953 let mut query: Vec<(&str, String)> = Vec::new();
954 if let Some(v) = node_id {
955 query.push(("nodeId", v.to_string()));
956 }
957 if let Some(v) = goal {
958 query.push(("goal", v.to_string()));
959 }
960 if let Some(v) = sid {
961 query.push(("sid", v.to_string()));
962 }
963 if let Some(v) = region_cluster_id {
964 query.push(("regionClusterId", v.to_string()));
965 }
966 if let Some(v) = since {
967 query.push(("since", v.to_string()));
968 }
969 if let Some(v) = bucket_seconds {
970 query.push(("bucketSeconds", v.to_string()));
971 }
972 self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/histogram", region_id), &query).await
973 }
974
975 pub async fn goals(&self, region_id: i64, node_id: Option<&str>) -> Result<GCWorkerEventGoalsResponse, Error> {
976 let mut query: Vec<(&str, String)> = Vec::new();
977 if let Some(v) = node_id {
978 query.push(("nodeId", v.to_string()));
979 }
980 self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/goals", region_id), &query).await
981 }
982}
983
984pub struct VaultService {
986 inner: Arc<ClientInner>,
987}
988
989impl VaultService {
990 pub async fn resync(&self) -> Result<(), Error> {
991 self.inner.post_empty::<serde_json::Value>("/api/v1/vault/resync").await.map(|_| ())
992 }
993}