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