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