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