Skip to main content

mountos_admin_sdk/
client_gen.rs

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