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 revoke_api_key(&self, volume_id: i64, req: &RevokeVolumeAPIKeyRequest) -> Result<(), Error> {
408        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke", volume_id), req).await.map(|_| ())
409    }
410
411    pub async fn revoke_api_keys_by_user(&self, volume_id: i64, req: &RevokeVolumeAPIKeysByUserRequest) -> Result<(), Error> {
412        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke-by-user", volume_id), req).await.map(|_| ())
413    }
414
415    pub async fn update_quota(&self, volume_id: i64, req: &UpdateVolumeQuotaRequest) -> Result<IdResponse, Error> {
416        self.inner.put(&format!("/api/v1/volumes/{}/quota", volume_id), req).await
417    }
418
419    pub async fn stats(&self, volume_id: i64) -> Result<StatsVolumeResponse, Error> {
420        self.inner.get(&format!("/api/v1/volumes/{}/stats", volume_id), &[]).await
421    }
422
423    pub async fn size_history(&self, volume_id: i64, from: Option<&str>, to: Option<&str>) -> Result<SizeHistoryVolumeResponse, Error> {
424        let mut query: Vec<(&str, String)> = Vec::new();
425        if let Some(v) = from {
426            query.push(("from", v.to_string()));
427        }
428        if let Some(v) = to {
429            query.push(("to", v.to_string()));
430        }
431        self.inner.get(&format!("/api/v1/volumes/{}/size-history", volume_id), &query).await
432    }
433
434    pub async fn create_fork(&self, volume_id: i64, req: &CreateVolumeForkRequest) -> Result<Fork, Error> {
435        self.inner.post(&format!("/api/v1/volumes/{}/forks/create", volume_id), req).await
436    }
437
438    pub async fn list_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
439        let mut query: Vec<(&str, String)> = Vec::new();
440        if let Some(v) = volume_type {
441            query.push(("volumeType", v.to_string()));
442        }
443        self.inner.get(&format!("/api/v1/volumes/{}/forks", volume_id), &query).await
444    }
445
446    pub async fn list_all_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?include_inactive=true", volume_id), &query).await
452    }
453
454    pub async fn delete_fork(&self, volume_id: i64, fork_name: &str, req: &DeleteVolumeForkRequest) -> Result<DeleteForkVolumeResponse, Error> {
455        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/delete", volume_id, fork_name), req).await
456    }
457
458    pub async fn restore_fork(&self, volume_id: i64, fork_name: &str, req: &RestoreVolumeForkRequest) -> Result<Fork, Error> {
459        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/restore", volume_id, fork_name), req).await
460    }
461}
462
463/// Operations on the `VolumeForkTrees` resource.
464pub struct VolumeForkTreesService {
465    inner: Arc<ClientInner>,
466}
467
468impl VolumeForkTreesService {
469    pub async fn list(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkTreeListOptions>) -> Result<CursorPaginatedResponse<ForkTreeEntry>, Error> {
470        let mut query: Vec<(&str, String)> = Vec::new();
471        if let Some(opts) = opts {
472            if let Some(v) = &opts.path {
473                query.push(("path", v.to_string()));
474            }
475            if let Some(v) = &opts.as_of {
476                query.push(("asOf", v.to_string()));
477            }
478            if let Some(v) = &opts.cursor {
479                query.push(("cursor", v.to_string()));
480            }
481            if let Some(v) = &opts.limit {
482                query.push(("limit", v.to_string()));
483            }
484            if let Some(v) = &opts.sort {
485                query.push(("sort", v.to_string()));
486            }
487            if let Some(v) = &opts.kind {
488                query.push(("kind", v.to_string()));
489            }
490        }
491        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/tree", volume_id, fork_name), &query).await
492    }
493}
494
495/// Operations on the `VolumeForkEntries` resource.
496pub struct VolumeForkEntriesService {
497    inner: Arc<ClientInner>,
498}
499
500impl VolumeForkEntriesService {
501    pub async fn get(&self, volume_id: i64, fork_name: &str, path: Option<&str>, inode: Option<i64>, as_of: Option<i64>) -> Result<ForkEntryDetail, Error> {
502        let mut query: Vec<(&str, String)> = Vec::new();
503        if let Some(v) = path {
504            query.push(("path", v.to_string()));
505        }
506        if let Some(v) = inode {
507            query.push(("inode", v.to_string()));
508        }
509        if let Some(v) = as_of {
510            query.push(("asOf", v.to_string()));
511        }
512        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry", volume_id, fork_name), &query).await
513    }
514
515    pub async fn versions(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkEntryListOptions>) -> Result<CursorPaginatedResponse<ForkEntryVersion>, Error> {
516        let mut query: Vec<(&str, String)> = Vec::new();
517        if let Some(opts) = opts {
518            if let Some(v) = &opts.path {
519                query.push(("path", v.to_string()));
520            }
521            if let Some(v) = &opts.cursor {
522                query.push(("cursor", v.to_string()));
523            }
524            if let Some(v) = &opts.limit {
525                query.push(("limit", v.to_string()));
526            }
527        }
528        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry/versions", volume_id, fork_name), &query).await
529    }
530}
531
532/// Operations on the `VolumeForkSearches` resource.
533pub struct VolumeForkSearchesService {
534    inner: Arc<ClientInner>,
535}
536
537impl VolumeForkSearchesService {
538    pub async fn find(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkSearchListOptions>) -> Result<CursorPaginatedResponse<ForkTreeMatch>, Error> {
539        let mut query: Vec<(&str, String)> = Vec::new();
540        if let Some(opts) = opts {
541            if let Some(v) = &opts.q {
542                query.push(("q", v.to_string()));
543            }
544            if let Some(v) = &opts.path {
545                query.push(("path", v.to_string()));
546            }
547            if let Some(v) = &opts.as_of {
548                query.push(("asOf", v.to_string()));
549            }
550            if let Some(v) = &opts.exact {
551                query.push(("exact", v.to_string()));
552            }
553            if let Some(v) = &opts.cursor {
554                query.push(("cursor", v.to_string()));
555            }
556            if let Some(v) = &opts.limit {
557                query.push(("limit", v.to_string()));
558            }
559            if let Some(v) = &opts.kind {
560                query.push(("kind", v.to_string()));
561            }
562        }
563        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/search", volume_id, fork_name), &query).await
564    }
565}
566
567/// Operations on the `AuditLogs` resource.
568pub struct AuditLogsService {
569    inner: Arc<ClientInner>,
570}
571
572impl AuditLogsService {
573    pub async fn list(&self, opts: &AuditLogListOptions) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
574        let mut query: Vec<(&str, String)> = Vec::new();
575        query.push(("accountId", opts.account_id.to_string()));
576        if let Some(v) = &opts.region_id {
577            query.push(("regionId", v.to_string()));
578        }
579        if let Some(v) = &opts.region_cluster_id {
580            query.push(("regionClusterId", v.to_string()));
581        }
582        if let Some(v) = &opts.cursor {
583            query.push(("cursor", v.to_string()));
584        }
585        if let Some(v) = &opts.limit {
586            query.push(("limit", v.to_string()));
587        }
588        if let Some(v) = &opts.subject {
589            query.push(("subject", v.to_string()));
590        }
591        self.inner.get("/api/v1/audit-logs/list", &query).await
592    }
593}
594
595/// Operations on the `RegionAuditLogs` resource.
596pub struct RegionAuditLogsService {
597    inner: Arc<ClientInner>,
598}
599
600impl RegionAuditLogsService {
601    pub async fn list(&self, region_id: i64, opts: Option<&RegionAuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
602        let mut query: Vec<(&str, String)> = Vec::new();
603        if let Some(opts) = opts {
604            if let Some(v) = &opts.region_cluster_id {
605                query.push(("regionClusterId", v.to_string()));
606            }
607            if let Some(v) = &opts.cursor {
608                query.push(("cursor", v.to_string()));
609            }
610            if let Some(v) = &opts.limit {
611                query.push(("limit", v.to_string()));
612            }
613            if let Some(v) = &opts.subject {
614                query.push(("subject", v.to_string()));
615            }
616            if let Some(v) = &opts.node {
617                query.push(("node", v.to_string()));
618            }
619        }
620        self.inner.get(&format!("/api/v1/regions/{}/audit-logs/list", region_id), &query).await
621    }
622}
623
624/// Operations on the `ServiceNodes` resource.
625pub struct ServiceNodesService {
626    inner: Arc<ClientInner>,
627}
628
629impl ServiceNodesService {
630    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> {
631        let mut query: Vec<(&str, String)> = Vec::new();
632        if let Some(v) = service_type {
633            query.push(("serviceType", v.to_string()));
634        }
635        if let Some(v) = status {
636            query.push(("status", v.to_string()));
637        }
638        if let Some(v) = inactive_hours {
639            query.push(("inactiveHours", v.to_string()));
640        }
641        if let Some(v) = region_cluster_id {
642            query.push(("regionClusterId", v.to_string()));
643        }
644        self.inner.get(&format!("/api/v1/regions/{}/nodes", region_id), &query).await
645    }
646
647    pub async fn stats(&self, region_id: i64, node_id: &str) -> Result<String, Error> {
648        self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats", region_id, crate::http::encode_segment(node_id)), &[]).await
649    }
650}
651
652/// Operations on the `Nodes` resource.
653pub struct NodesService {
654    inner: Arc<ClientInner>,
655}
656
657impl NodesService {
658    pub async fn list_all(&self, account_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
659        let mut query: Vec<(&str, String)> = Vec::new();
660        query.push(("accountId", account_id.to_string()));
661        if let Some(v) = service_type {
662            query.push(("serviceType", v.to_string()));
663        }
664        if let Some(v) = status {
665            query.push(("status", v.to_string()));
666        }
667        if let Some(v) = inactive_hours {
668            query.push(("inactiveHours", v.to_string()));
669        }
670        self.inner.get("/api/v1/nodes", &query).await
671    }
672}
673
674/// Operations on the `ClientSessions` resource.
675pub struct ClientSessionsService {
676    inner: Arc<ClientInner>,
677}
678
679impl ClientSessionsService {
680    pub async fn list(&self, opts: &ClientSessionListOptions) -> Result<PaginatedResponse<ClientSession>, Error> {
681        let mut query: Vec<(&str, String)> = Vec::new();
682        query.push(("accountId", opts.account_id.to_string()));
683        if let Some(v) = &opts.region_id {
684            query.push(("regionId", v.to_string()));
685        }
686        if let Some(v) = &opts.region_cluster_id {
687            query.push(("regionClusterId", v.to_string()));
688        }
689        if let Some(v) = &opts.volume_id {
690            query.push(("volumeId", v.to_string()));
691        }
692        if let Some(v) = &opts.user_id {
693            query.push(("userId", v.to_string()));
694        }
695        if let Some(v) = &opts.client_type {
696            query.push(("clientType", v.to_string()));
697        }
698        if let Some(v) = &opts.status {
699            query.push(("status", v.to_string()));
700        }
701        if let Some(v) = &opts.is_active {
702            query.push(("isActive", v.to_string()));
703        }
704        if let Some(v) = &opts.os_name {
705            query.push(("osName", v.to_string()));
706        }
707        if let Some(v) = &opts.platform {
708            query.push(("platform", v.to_string()));
709        }
710        if let Some(v) = &opts.search {
711            query.push(("search", v.to_string()));
712        }
713        if let Some(v) = &opts.page {
714            query.push(("page", v.to_string()));
715        }
716        if let Some(v) = &opts.limit {
717            query.push(("limit", v.to_string()));
718        }
719        self.inner.get("/api/v1/client-sessions/list", &query).await
720    }
721
722    pub async fn get(&self, session_id: i64) -> Result<ClientSession, Error> {
723        self.inner.get(&format!("/api/v1/client-sessions/{}", session_id), &[]).await
724    }
725
726    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> {
727        let mut query: Vec<(&str, String)> = Vec::new();
728        query.push(("accountId", account_id.to_string()));
729        if let Some(v) = region_id {
730            query.push(("regionId", v.to_string()));
731        }
732        if let Some(v) = region_cluster_id {
733            query.push(("regionClusterId", v.to_string()));
734        }
735        if let Some(v) = volume_id {
736            query.push(("volumeId", v.to_string()));
737        }
738        if let Some(v) = user_id {
739            query.push(("userId", v.to_string()));
740        }
741        self.inner.get("/api/v1/client-sessions/summary", &query).await
742    }
743}
744
745/// Operations on the `Discover` resource.
746pub struct DiscoverService {
747    inner: Arc<ClientInner>,
748}
749
750impl DiscoverService {
751    pub async fn meta(&self, access_key_id: &str) -> Result<DiscoverMetaResponse, Error> {
752        let mut query: Vec<(&str, String)> = Vec::new();
753        query.push(("access_key_id", access_key_id.to_string()));
754        self.inner.get("/api/v1/discover/meta", &query).await
755    }
756}
757
758/// Operations on the `Dashboard` resource.
759pub struct DashboardService {
760    inner: Arc<ClientInner>,
761}
762
763impl DashboardService {
764    pub async fn stats(&self, account_id: i64) -> Result<DashboardStats, Error> {
765        let mut query: Vec<(&str, String)> = Vec::new();
766        query.push(("accountId", account_id.to_string()));
767        self.inner.get("/api/v1/dashboard/stats", &query).await
768    }
769}
770
771/// Operations on the `License` resource.
772pub struct LicenseService {
773    inner: Arc<ClientInner>,
774}
775
776impl LicenseService {
777    pub async fn get(&self) -> Result<LicenseDetails, Error> {
778        self.inner.get("/api/v1/license", &[]).await
779    }
780
781    pub async fn terms(&self) -> Result<LicenseTerms, Error> {
782        self.inner.get("/api/v1/license/terms", &[]).await
783    }
784
785    pub async fn load(&self, req: &LoadLicenseRequest) -> Result<LicenseLoadResult, Error> {
786        self.inner.post("/api/v1/license/load", req).await
787    }
788
789    pub async fn list(&self) -> Result<LicenseList, Error> {
790        self.inner.get("/api/v1/license/list", &[]).await
791    }
792}
793
794/// Operations on the `Alerts` resource.
795pub struct AlertsService {
796    inner: Arc<ClientInner>,
797}
798
799impl AlertsService {
800    pub async fn list(&self, opts: Option<&AlertListOptions>) -> Result<PaginatedResponse<ServiceAlert>, Error> {
801        let mut query: Vec<(&str, String)> = Vec::new();
802        if let Some(opts) = opts {
803            if let Some(v) = &opts.active {
804                query.push(("active", v.to_string()));
805            }
806            if let Some(v) = &opts.account_id {
807                query.push(("accountId", v.to_string()));
808            }
809            if let Some(v) = &opts.region_id {
810                query.push(("regionId", v.to_string()));
811            }
812            if let Some(v) = &opts.severity {
813                query.push(("severity", v.to_string()));
814            }
815            if let Some(v) = &opts.category {
816                query.push(("category", v.to_string()));
817            }
818            if let Some(v) = &opts.since {
819                query.push(("since", v.to_string()));
820            }
821            if let Some(v) = &opts.page {
822                query.push(("page", v.to_string()));
823            }
824            if let Some(v) = &opts.limit {
825                query.push(("limit", v.to_string()));
826            }
827        }
828        self.inner.get("/api/v1/alerts/list", &query).await
829    }
830
831    pub async fn count(&self) -> Result<AlertCountResponse, Error> {
832        self.inner.get("/api/v1/alerts/count", &[]).await
833    }
834
835    pub async fn resolve(&self, alert_id: &str) -> Result<(), Error> {
836        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/alerts/{}/resolve", alert_id)).await.map(|_| ())
837    }
838}
839
840/// Operations on the `RegionAlerts` resource.
841pub struct RegionAlertsService {
842    inner: Arc<ClientInner>,
843}
844
845impl RegionAlertsService {
846    pub async fn list(&self, region_id: i64, opts: Option<&RegionAlertListOptions>) -> Result<PaginatedResponse<RegionAlert>, Error> {
847        let mut query: Vec<(&str, String)> = Vec::new();
848        if let Some(opts) = opts {
849            if let Some(v) = &opts.active {
850                query.push(("active", v.to_string()));
851            }
852            if let Some(v) = &opts.severity {
853                query.push(("severity", v.to_string()));
854            }
855            if let Some(v) = &opts.category {
856                query.push(("category", v.to_string()));
857            }
858            if let Some(v) = &opts.node_id {
859                query.push(("nodeId", v.to_string()));
860            }
861            if let Some(v) = &opts.region_cluster_id {
862                query.push(("regionClusterId", v.to_string()));
863            }
864            if let Some(v) = &opts.since {
865                query.push(("since", v.to_string()));
866            }
867            if let Some(v) = &opts.page {
868                query.push(("page", v.to_string()));
869            }
870            if let Some(v) = &opts.limit {
871                query.push(("limit", v.to_string()));
872            }
873        }
874        self.inner.get(&format!("/api/v1/regions/{}/alerts/list", region_id), &query).await
875    }
876
877    pub async fn count(&self, region_id: i64, region_cluster_id: Option<i64>) -> Result<AlertCountResponse, Error> {
878        let mut query: Vec<(&str, String)> = Vec::new();
879        if let Some(v) = region_cluster_id {
880            query.push(("regionClusterId", v.to_string()));
881        }
882        self.inner.get(&format!("/api/v1/regions/{}/alerts/count", region_id), &query).await
883    }
884
885    pub async fn resolve(&self, region_id: i64, alert_id: &str) -> Result<(), Error> {
886        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/regions/{}/alerts/{}/resolve", region_id, alert_id)).await.map(|_| ())
887    }
888}
889
890/// Operations on the `Vault` resource.
891pub struct VaultService {
892    inner: Arc<ClientInner>,
893}
894
895impl VaultService {
896    pub async fn resync(&self) -> Result<(), Error> {
897        self.inner.post_empty::<serde_json::Value>("/api/v1/vault/resync").await.map(|_| ())
898    }
899}