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