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: Option<&UserListOptions>) -> Result<PaginatedResponse<User>, Error> {
126        let mut query: Vec<(&str, String)> = Vec::new();
127        if let Some(opts) = opts {
128            query.push(("accountId", opts.account_id.to_string()));
129            if let Some(v) = &opts.search {
130                query.push(("search", v.to_string()));
131            }
132            if let Some(v) = &opts.is_active {
133                query.push(("isActive", v.to_string()));
134            }
135            if let Some(v) = &opts.page {
136                query.push(("page", v.to_string()));
137            }
138            if let Some(v) = &opts.limit {
139                query.push(("limit", v.to_string()));
140            }
141        }
142        self.inner.get("/api/v1/users/list", &query).await
143    }
144
145    pub async fn get(&self, user_id: i64) -> Result<User, Error> {
146        self.inner.get(&format!("/api/v1/users/{}", user_id), &[]).await
147    }
148
149    pub async fn bulk(&self, req: &BulkUserRequest) -> Result<BulkUserResponse, Error> {
150        self.inner.post("/api/v1/users/bulk", req).await
151    }
152
153    pub async fn edit(&self, user_id: i64, req: &EditUserRequest) -> Result<IdResponse, Error> {
154        self.inner.put(&format!("/api/v1/users/{}/edit", user_id), req).await
155    }
156
157    pub async fn deactivate(&self, user_id: i64) -> Result<IdResponse, Error> {
158        self.inner.post_empty(&format!("/api/v1/users/{}/deactivate", user_id)).await
159    }
160}
161
162/// Operations on the `Regions` resource.
163pub struct RegionsService {
164    inner: Arc<ClientInner>,
165}
166
167impl RegionsService {
168    pub async fn create(&self, req: &CreateRegionRequest) -> Result<IdResponse, Error> {
169        self.inner.post("/api/v1/regions/create", req).await
170    }
171
172    pub async fn list(&self, opts: Option<&RegionListOptions>) -> Result<PaginatedResponse<Region>, Error> {
173        let mut query: Vec<(&str, String)> = Vec::new();
174        if let Some(opts) = opts {
175            if let Some(v) = &opts.is_active {
176                query.push(("isActive", v.to_string()));
177            }
178            if let Some(v) = &opts.page {
179                query.push(("page", v.to_string()));
180            }
181            if let Some(v) = &opts.limit {
182                query.push(("limit", v.to_string()));
183            }
184        }
185        self.inner.get("/api/v1/regions/list", &query).await
186    }
187
188    pub async fn get(&self, region_id: i64) -> Result<Region, Error> {
189        self.inner.get(&format!("/api/v1/regions/{}", region_id), &[]).await
190    }
191
192    pub async fn edit(&self, region_id: i64, req: &EditRegionRequest) -> Result<IdResponse, Error> {
193        self.inner.put(&format!("/api/v1/regions/{}/edit", region_id), req).await
194    }
195
196    pub async fn deactivate(&self, region_id: i64) -> Result<IdResponse, Error> {
197        self.inner.post_empty(&format!("/api/v1/regions/{}/deactivate", region_id)).await
198    }
199}
200
201/// Operations on the `Clusters` resource.
202pub struct ClustersService {
203    inner: Arc<ClientInner>,
204}
205
206impl ClustersService {
207    pub async fn list(&self, opts: Option<&ClusterListOptions>) -> Result<PaginatedResponse<RegionCluster>, Error> {
208        let mut query: Vec<(&str, String)> = Vec::new();
209        if let Some(opts) = opts {
210            query.push(("accountId", opts.account_id.to_string()));
211            if let Some(v) = &opts.region_id {
212                query.push(("regionId", v.to_string()));
213            }
214            if let Some(v) = &opts.is_active {
215                query.push(("isActive", v.to_string()));
216            }
217            if let Some(v) = &opts.page {
218                query.push(("page", v.to_string()));
219            }
220            if let Some(v) = &opts.limit {
221                query.push(("limit", v.to_string()));
222            }
223        }
224        self.inner.get("/api/v1/clusters/list", &query).await
225    }
226}
227
228/// Operations on the `RegionClusters` resource.
229pub struct RegionClustersService {
230    inner: Arc<ClientInner>,
231}
232
233impl RegionClustersService {
234    pub async fn create(&self, region_id: i64, req: &CreateRegionClusterRequest) -> Result<IdResponse, Error> {
235        self.inner.post(&format!("/api/v1/regions/{}/clusters/create", region_id), req).await
236    }
237
238    pub async fn list(&self, region_id: i64, opts: Option<&RegionClusterListOptions>) -> Result<PaginatedResponse<RegionCluster>, Error> {
239        let mut query: Vec<(&str, String)> = Vec::new();
240        if let Some(opts) = opts {
241            if let Some(v) = &opts.is_active {
242                query.push(("isActive", v.to_string()));
243            }
244            if let Some(v) = &opts.page {
245                query.push(("page", v.to_string()));
246            }
247            if let Some(v) = &opts.limit {
248                query.push(("limit", v.to_string()));
249            }
250        }
251        self.inner.get(&format!("/api/v1/regions/{}/clusters/list", region_id), &query).await
252    }
253
254    pub async fn get(&self, region_id: i64, cluster_id: i64) -> Result<RegionCluster, Error> {
255        self.inner.get(&format!("/api/v1/regions/{}/clusters/{}", region_id, cluster_id), &[]).await
256    }
257
258    pub async fn edit(&self, region_id: i64, cluster_id: i64, req: &EditRegionClusterRequest) -> Result<IdResponse, Error> {
259        self.inner.put(&format!("/api/v1/regions/{}/clusters/{}/edit", region_id, cluster_id), req).await
260    }
261
262    pub async fn set_default(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
263        self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/set-default", region_id, cluster_id)).await
264    }
265
266    pub async fn set_ready(&self, region_id: i64, cluster_id: i64, req: &SetRegionClusterReadyRequest) -> Result<SetReadyRegionClusterResponse, Error> {
267        self.inner.post(&format!("/api/v1/regions/{}/clusters/{}/set-ready", region_id, cluster_id), req).await
268    }
269
270    pub async fn deactivate(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
271        self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/deactivate", region_id, cluster_id)).await
272    }
273}
274
275/// Operations on the `Storages` resource.
276pub struct StoragesService {
277    inner: Arc<ClientInner>,
278}
279
280impl StoragesService {
281    pub async fn create(&self, req: &CreateStorageRequest) -> Result<CreateStorageResponse, Error> {
282        self.inner.post("/api/v1/storages/create", req).await
283    }
284
285    pub async fn list(&self, opts: Option<&StorageListOptions>) -> Result<PaginatedResponse<Storage>, Error> {
286        let mut query: Vec<(&str, String)> = Vec::new();
287        if let Some(opts) = opts {
288            query.push(("accountId", opts.account_id.to_string()));
289            if let Some(v) = &opts.search {
290                query.push(("search", v.to_string()));
291            }
292            if let Some(v) = &opts.region_id {
293                query.push(("regionId", v.to_string()));
294            }
295            if let Some(v) = &opts.storage_type {
296                query.push(("storageType", v.to_string()));
297            }
298            if let Some(v) = &opts.provider_type {
299                query.push(("providerType", v.to_string()));
300            }
301            if let Some(v) = &opts.is_active {
302                query.push(("isActive", v.to_string()));
303            }
304            if let Some(v) = &opts.page {
305                query.push(("page", v.to_string()));
306            }
307            if let Some(v) = &opts.limit {
308                query.push(("limit", v.to_string()));
309            }
310        }
311        self.inner.get("/api/v1/storages/list", &query).await
312    }
313
314    pub async fn get(&self, storage_id: i64) -> Result<Storage, Error> {
315        self.inner.get(&format!("/api/v1/storages/{}", storage_id), &[]).await
316    }
317
318    pub async fn list_block_volumes(&self, storage_id: i64) -> Result<Vec<BlockVolume>, Error> {
319        self.inner.get(&format!("/api/v1/storages/{}/block-volumes", storage_id), &[]).await
320    }
321
322    pub async fn edit(&self, storage_id: i64, req: &EditStorageRequest) -> Result<IdResponse, Error> {
323        self.inner.put(&format!("/api/v1/storages/{}/edit", storage_id), req).await
324    }
325
326    pub async fn deactivate(&self, storage_id: i64) -> Result<IdResponse, Error> {
327        self.inner.post_empty(&format!("/api/v1/storages/{}/deactivate", storage_id)).await
328    }
329
330    pub async fn test_bucket(&self, req: &TestStorageBucketRequest) -> Result<TestBucketStorageResponse, Error> {
331        self.inner.post("/api/v1/storages/test-bucket", req).await
332    }
333
334    pub async fn test_storage_bucket(&self, storage_id: i64) -> Result<TestStorageBucketStorageResponse, Error> {
335        self.inner.post_empty(&format!("/api/v1/storages/{}/test-bucket", storage_id)).await
336    }
337}
338
339/// Operations on the `Volumes` resource.
340pub struct VolumesService {
341    inner: Arc<ClientInner>,
342}
343
344impl VolumesService {
345    pub async fn create(&self, req: &CreateVolumeRequest) -> Result<CreateVolumeResponse, Error> {
346        self.inner.post("/api/v1/volumes/create", req).await
347    }
348
349    pub async fn list(&self, opts: Option<&VolumeListOptions>) -> Result<PaginatedResponse<Volume>, Error> {
350        let mut query: Vec<(&str, String)> = Vec::new();
351        if let Some(opts) = opts {
352            query.push(("accountId", opts.account_id.to_string()));
353            if let Some(v) = &opts.region_id {
354                query.push(("regionId", v.to_string()));
355            }
356            if let Some(v) = &opts.region_cluster_id {
357                query.push(("regionClusterId", v.to_string()));
358            }
359            if let Some(v) = &opts.storage_id {
360                query.push(("storageId", v.to_string()));
361            }
362            if let Some(v) = &opts.volume_type {
363                query.push(("volumeType", v.to_string()));
364            }
365            if let Some(v) = &opts.locked {
366                query.push(("locked", v.to_string()));
367            }
368            if let Some(v) = &opts.is_active {
369                query.push(("isActive", v.to_string()));
370            }
371            if let Some(v) = &opts.page {
372                query.push(("page", v.to_string()));
373            }
374            if let Some(v) = &opts.limit {
375                query.push(("limit", v.to_string()));
376            }
377        }
378        self.inner.get("/api/v1/volumes/list", &query).await
379    }
380
381    pub async fn get(&self, volume_id: i64) -> Result<Volume, Error> {
382        self.inner.get(&format!("/api/v1/volumes/{}", volume_id), &[]).await
383    }
384
385    pub async fn edit(&self, volume_id: i64, req: &EditVolumeRequest) -> Result<IdResponse, Error> {
386        self.inner.put(&format!("/api/v1/volumes/{}/edit", volume_id), req).await
387    }
388
389    pub async fn lock(&self, volume_id: i64) -> Result<IdResponse, Error> {
390        self.inner.post_empty(&format!("/api/v1/volumes/{}/lock", volume_id)).await
391    }
392
393    pub async fn unlock(&self, volume_id: i64) -> Result<IdResponse, Error> {
394        self.inner.post_empty(&format!("/api/v1/volumes/{}/unlock", volume_id)).await
395    }
396
397    pub async fn move_cluster(&self, volume_id: i64, req: &MoveVolumeClusterRequest) -> Result<MoveClusterVolumeResponse, Error> {
398        self.inner.post(&format!("/api/v1/volumes/{}/move-cluster", volume_id), req).await
399    }
400
401    pub async fn deactivate(&self, volume_id: i64, req: &DeactivateVolumeRequest) -> Result<IdResponse, Error> {
402        self.inner.post(&format!("/api/v1/volumes/{}/deactivate", volume_id), req).await
403    }
404
405    pub async fn activate(&self, volume_id: i64) -> Result<IdResponse, Error> {
406        self.inner.post_empty(&format!("/api/v1/volumes/{}/activate", volume_id)).await
407    }
408
409    pub async fn generate_api_keys(&self, volume_id: i64, req: &GenerateVolumeAPIKeysRequest) -> Result<GenerateAPIKeysVolumeResponse, Error> {
410        self.inner.post(&format!("/api/v1/volumes/{}/api-keys/generate", volume_id), req).await
411    }
412
413    pub async fn revoke_api_key(&self, volume_id: i64, req: &RevokeVolumeAPIKeyRequest) -> Result<(), Error> {
414        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke", volume_id), req).await.map(|_| ())
415    }
416
417    pub async fn revoke_api_keys_by_user(&self, volume_id: i64, req: &RevokeVolumeAPIKeysByUserRequest) -> Result<(), Error> {
418        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke-by-user", volume_id), req).await.map(|_| ())
419    }
420
421    pub async fn update_quota(&self, volume_id: i64, req: &UpdateVolumeQuotaRequest) -> Result<IdResponse, Error> {
422        self.inner.put(&format!("/api/v1/volumes/{}/quota", volume_id), req).await
423    }
424
425    pub async fn stats(&self, volume_id: i64) -> Result<StatsVolumeResponse, Error> {
426        self.inner.get(&format!("/api/v1/volumes/{}/stats", volume_id), &[]).await
427    }
428
429    pub async fn size_history(&self, volume_id: i64, from: Option<&str>, to: Option<&str>) -> Result<SizeHistoryVolumeResponse, Error> {
430        let mut query: Vec<(&str, String)> = Vec::new();
431        if let Some(v) = from {
432            query.push(("from", v.to_string()));
433        }
434        if let Some(v) = to {
435            query.push(("to", v.to_string()));
436        }
437        self.inner.get(&format!("/api/v1/volumes/{}/size-history", volume_id), &query).await
438    }
439
440    pub async fn create_fork(&self, volume_id: i64, req: &CreateVolumeForkRequest) -> Result<Fork, Error> {
441        self.inner.post(&format!("/api/v1/volumes/{}/forks/create", volume_id), req).await
442    }
443
444    pub async fn list_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
445        let mut query: Vec<(&str, String)> = Vec::new();
446        if let Some(v) = volume_type {
447            query.push(("volumeType", v.to_string()));
448        }
449        self.inner.get(&format!("/api/v1/volumes/{}/forks", volume_id), &query).await
450    }
451
452    pub async fn list_all_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
453        let mut query: Vec<(&str, String)> = Vec::new();
454        if let Some(v) = volume_type {
455            query.push(("volumeType", v.to_string()));
456        }
457        self.inner.get(&format!("/api/v1/volumes/{}/forks?include_inactive=true", volume_id), &query).await
458    }
459
460    pub async fn delete_fork(&self, volume_id: i64, fork_name: &str, req: &DeleteVolumeForkRequest) -> Result<DeleteForkVolumeResponse, Error> {
461        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/delete", volume_id, fork_name), req).await
462    }
463
464    pub async fn restore_fork(&self, volume_id: i64, fork_name: &str, req: &RestoreVolumeForkRequest) -> Result<Fork, Error> {
465        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/restore", volume_id, fork_name), req).await
466    }
467}
468
469/// Operations on the `VolumeForkTrees` resource.
470pub struct VolumeForkTreesService {
471    inner: Arc<ClientInner>,
472}
473
474impl VolumeForkTreesService {
475    pub async fn list(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkTreeListOptions>) -> Result<CursorPaginatedResponse<ForkTreeEntry>, Error> {
476        let mut query: Vec<(&str, String)> = Vec::new();
477        if let Some(opts) = opts {
478            if let Some(v) = &opts.path {
479                query.push(("path", v.to_string()));
480            }
481            if let Some(v) = &opts.as_of {
482                query.push(("asOf", v.to_string()));
483            }
484            if let Some(v) = &opts.cursor {
485                query.push(("cursor", v.to_string()));
486            }
487            if let Some(v) = &opts.limit {
488                query.push(("limit", v.to_string()));
489            }
490            if let Some(v) = &opts.sort {
491                query.push(("sort", v.to_string()));
492            }
493            if let Some(v) = &opts.kind {
494                query.push(("kind", v.to_string()));
495            }
496        }
497        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/tree", volume_id, fork_name), &query).await
498    }
499}
500
501/// Operations on the `VolumeForkEntries` resource.
502pub struct VolumeForkEntriesService {
503    inner: Arc<ClientInner>,
504}
505
506impl VolumeForkEntriesService {
507    pub async fn get(&self, volume_id: i64, fork_name: &str, path: Option<&str>, inode: Option<i64>, as_of: Option<i64>) -> Result<ForkEntryDetail, Error> {
508        let mut query: Vec<(&str, String)> = Vec::new();
509        if let Some(v) = path {
510            query.push(("path", v.to_string()));
511        }
512        if let Some(v) = inode {
513            query.push(("inode", v.to_string()));
514        }
515        if let Some(v) = as_of {
516            query.push(("asOf", v.to_string()));
517        }
518        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry", volume_id, fork_name), &query).await
519    }
520
521    pub async fn versions(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkEntryListOptions>) -> Result<CursorPaginatedResponse<ForkEntryVersion>, Error> {
522        let mut query: Vec<(&str, String)> = Vec::new();
523        if let Some(opts) = opts {
524            if let Some(v) = &opts.path {
525                query.push(("path", v.to_string()));
526            }
527            if let Some(v) = &opts.cursor {
528                query.push(("cursor", v.to_string()));
529            }
530            if let Some(v) = &opts.limit {
531                query.push(("limit", v.to_string()));
532            }
533        }
534        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry/versions", volume_id, fork_name), &query).await
535    }
536}
537
538/// Operations on the `VolumeForkSearches` resource.
539pub struct VolumeForkSearchesService {
540    inner: Arc<ClientInner>,
541}
542
543impl VolumeForkSearchesService {
544    pub async fn find(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkSearchListOptions>) -> Result<CursorPaginatedResponse<ForkTreeMatch>, Error> {
545        let mut query: Vec<(&str, String)> = Vec::new();
546        if let Some(opts) = opts {
547            if let Some(v) = &opts.q {
548                query.push(("q", v.to_string()));
549            }
550            if let Some(v) = &opts.path {
551                query.push(("path", v.to_string()));
552            }
553            if let Some(v) = &opts.as_of {
554                query.push(("asOf", v.to_string()));
555            }
556            if let Some(v) = &opts.exact {
557                query.push(("exact", v.to_string()));
558            }
559            if let Some(v) = &opts.cursor {
560                query.push(("cursor", v.to_string()));
561            }
562            if let Some(v) = &opts.limit {
563                query.push(("limit", v.to_string()));
564            }
565            if let Some(v) = &opts.kind {
566                query.push(("kind", v.to_string()));
567            }
568        }
569        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/search", volume_id, fork_name), &query).await
570    }
571}
572
573/// Operations on the `AuditLogs` resource.
574pub struct AuditLogsService {
575    inner: Arc<ClientInner>,
576}
577
578impl AuditLogsService {
579    pub async fn list(&self, opts: Option<&AuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
580        let mut query: Vec<(&str, String)> = Vec::new();
581        if let Some(opts) = opts {
582            if let Some(v) = &opts.account_id {
583                query.push(("accountId", v.to_string()));
584            }
585            if let Some(v) = &opts.region_id {
586                query.push(("regionId", v.to_string()));
587            }
588            if let Some(v) = &opts.region_cluster_id {
589                query.push(("regionClusterId", v.to_string()));
590            }
591            if let Some(v) = &opts.cursor {
592                query.push(("cursor", v.to_string()));
593            }
594            if let Some(v) = &opts.limit {
595                query.push(("limit", v.to_string()));
596            }
597            if let Some(v) = &opts.subject {
598                query.push(("subject", v.to_string()));
599            }
600        }
601        self.inner.get("/api/v1/audit-logs/list", &query).await
602    }
603}
604
605/// Operations on the `RegionAuditLogs` resource.
606pub struct RegionAuditLogsService {
607    inner: Arc<ClientInner>,
608}
609
610impl RegionAuditLogsService {
611    pub async fn list(&self, region_id: i64, opts: Option<&RegionAuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
612        let mut query: Vec<(&str, String)> = Vec::new();
613        if let Some(opts) = opts {
614            if let Some(v) = &opts.region_cluster_id {
615                query.push(("regionClusterId", v.to_string()));
616            }
617            if let Some(v) = &opts.cursor {
618                query.push(("cursor", v.to_string()));
619            }
620            if let Some(v) = &opts.limit {
621                query.push(("limit", v.to_string()));
622            }
623            if let Some(v) = &opts.subject {
624                query.push(("subject", v.to_string()));
625            }
626            if let Some(v) = &opts.node {
627                query.push(("node", v.to_string()));
628            }
629        }
630        self.inner.get(&format!("/api/v1/regions/{}/audit-logs/list", region_id), &query).await
631    }
632}
633
634/// Operations on the `ServiceNodes` resource.
635pub struct ServiceNodesService {
636    inner: Arc<ClientInner>,
637}
638
639impl ServiceNodesService {
640    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> {
641        let mut query: Vec<(&str, String)> = Vec::new();
642        if let Some(v) = service_type {
643            query.push(("serviceType", v.to_string()));
644        }
645        if let Some(v) = status {
646            query.push(("status", v.to_string()));
647        }
648        if let Some(v) = inactive_hours {
649            query.push(("inactiveHours", v.to_string()));
650        }
651        if let Some(v) = region_cluster_id {
652            query.push(("regionClusterId", v.to_string()));
653        }
654        self.inner.get(&format!("/api/v1/regions/{}/nodes", region_id), &query).await
655    }
656
657    pub async fn stats(&self, region_id: i64, node_id: &str) -> Result<String, Error> {
658        self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats", region_id, crate::http::encode_segment(node_id)), &[]).await
659    }
660}
661
662/// Operations on the `Nodes` resource.
663pub struct NodesService {
664    inner: Arc<ClientInner>,
665}
666
667impl NodesService {
668    pub async fn list_all(&self, account_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
669        let mut query: Vec<(&str, String)> = Vec::new();
670        query.push(("accountId", account_id.to_string()));
671        if let Some(v) = service_type {
672            query.push(("serviceType", v.to_string()));
673        }
674        if let Some(v) = status {
675            query.push(("status", v.to_string()));
676        }
677        if let Some(v) = inactive_hours {
678            query.push(("inactiveHours", v.to_string()));
679        }
680        self.inner.get("/api/v1/nodes", &query).await
681    }
682}
683
684/// Operations on the `ClientSessions` resource.
685pub struct ClientSessionsService {
686    inner: Arc<ClientInner>,
687}
688
689impl ClientSessionsService {
690    pub async fn list(&self, opts: Option<&ClientSessionListOptions>) -> Result<PaginatedResponse<ClientSession>, Error> {
691        let mut query: Vec<(&str, String)> = Vec::new();
692        if let Some(opts) = opts {
693            if let Some(v) = &opts.account_id {
694                query.push(("accountId", v.to_string()));
695            }
696            if let Some(v) = &opts.region_id {
697                query.push(("regionId", v.to_string()));
698            }
699            if let Some(v) = &opts.region_cluster_id {
700                query.push(("regionClusterId", v.to_string()));
701            }
702            if let Some(v) = &opts.volume_id {
703                query.push(("volumeId", v.to_string()));
704            }
705            if let Some(v) = &opts.user_id {
706                query.push(("userId", v.to_string()));
707            }
708            if let Some(v) = &opts.client_type {
709                query.push(("clientType", v.to_string()));
710            }
711            if let Some(v) = &opts.status {
712                query.push(("status", v.to_string()));
713            }
714            if let Some(v) = &opts.is_active {
715                query.push(("isActive", v.to_string()));
716            }
717            if let Some(v) = &opts.os_name {
718                query.push(("osName", v.to_string()));
719            }
720            if let Some(v) = &opts.platform {
721                query.push(("platform", v.to_string()));
722            }
723            if let Some(v) = &opts.search {
724                query.push(("search", v.to_string()));
725            }
726            if let Some(v) = &opts.page {
727                query.push(("page", v.to_string()));
728            }
729            if let Some(v) = &opts.limit {
730                query.push(("limit", v.to_string()));
731            }
732        }
733        self.inner.get("/api/v1/client-sessions/list", &query).await
734    }
735
736    pub async fn get(&self, session_id: i64) -> Result<ClientSession, Error> {
737        self.inner.get(&format!("/api/v1/client-sessions/{}", session_id), &[]).await
738    }
739
740    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> {
741        let mut query: Vec<(&str, String)> = Vec::new();
742        if let Some(v) = account_id {
743            query.push(("accountId", v.to_string()));
744        }
745        if let Some(v) = region_id {
746            query.push(("regionId", v.to_string()));
747        }
748        if let Some(v) = region_cluster_id {
749            query.push(("regionClusterId", v.to_string()));
750        }
751        if let Some(v) = volume_id {
752            query.push(("volumeId", v.to_string()));
753        }
754        if let Some(v) = user_id {
755            query.push(("userId", v.to_string()));
756        }
757        self.inner.get("/api/v1/client-sessions/summary", &query).await
758    }
759}
760
761/// Operations on the `Discover` resource.
762pub struct DiscoverService {
763    inner: Arc<ClientInner>,
764}
765
766impl DiscoverService {
767    pub async fn meta(&self, access_key_id: &str) -> Result<DiscoverMetaResponse, Error> {
768        let mut query: Vec<(&str, String)> = Vec::new();
769        query.push(("access_key_id", access_key_id.to_string()));
770        self.inner.get("/api/v1/discover/meta", &query).await
771    }
772}
773
774/// Operations on the `Dashboard` resource.
775pub struct DashboardService {
776    inner: Arc<ClientInner>,
777}
778
779impl DashboardService {
780    pub async fn stats(&self, account_id: i64) -> Result<DashboardStats, Error> {
781        let mut query: Vec<(&str, String)> = Vec::new();
782        query.push(("accountId", account_id.to_string()));
783        self.inner.get("/api/v1/dashboard/stats", &query).await
784    }
785}
786
787/// Operations on the `License` resource.
788pub struct LicenseService {
789    inner: Arc<ClientInner>,
790}
791
792impl LicenseService {
793    pub async fn get(&self) -> Result<LicenseDetails, Error> {
794        self.inner.get("/api/v1/license", &[]).await
795    }
796
797    pub async fn terms(&self) -> Result<LicenseTerms, Error> {
798        self.inner.get("/api/v1/license/terms", &[]).await
799    }
800}
801
802/// Operations on the `Alerts` resource.
803pub struct AlertsService {
804    inner: Arc<ClientInner>,
805}
806
807impl AlertsService {
808    pub async fn list(&self, opts: Option<&AlertListOptions>) -> Result<PaginatedResponse<ServiceAlert>, Error> {
809        let mut query: Vec<(&str, String)> = Vec::new();
810        if let Some(opts) = opts {
811            if let Some(v) = &opts.active {
812                query.push(("active", v.to_string()));
813            }
814            if let Some(v) = &opts.account_id {
815                query.push(("accountId", v.to_string()));
816            }
817            if let Some(v) = &opts.region_id {
818                query.push(("regionId", v.to_string()));
819            }
820            if let Some(v) = &opts.severity {
821                query.push(("severity", v.to_string()));
822            }
823            if let Some(v) = &opts.category {
824                query.push(("category", v.to_string()));
825            }
826            if let Some(v) = &opts.since {
827                query.push(("since", v.to_string()));
828            }
829            if let Some(v) = &opts.page {
830                query.push(("page", v.to_string()));
831            }
832            if let Some(v) = &opts.limit {
833                query.push(("limit", v.to_string()));
834            }
835        }
836        self.inner.get("/api/v1/alerts/list", &query).await
837    }
838
839    pub async fn count(&self) -> Result<AlertCountResponse, Error> {
840        self.inner.get("/api/v1/alerts/count", &[]).await
841    }
842
843    pub async fn resolve(&self, alert_id: &str) -> Result<(), Error> {
844        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/alerts/{}/resolve", alert_id)).await.map(|_| ())
845    }
846}
847
848/// Operations on the `RegionAlerts` resource.
849pub struct RegionAlertsService {
850    inner: Arc<ClientInner>,
851}
852
853impl RegionAlertsService {
854    pub async fn list(&self, region_id: i64, opts: Option<&RegionAlertListOptions>) -> Result<PaginatedResponse<RegionAlert>, Error> {
855        let mut query: Vec<(&str, String)> = Vec::new();
856        if let Some(opts) = opts {
857            if let Some(v) = &opts.active {
858                query.push(("active", v.to_string()));
859            }
860            if let Some(v) = &opts.severity {
861                query.push(("severity", v.to_string()));
862            }
863            if let Some(v) = &opts.category {
864                query.push(("category", v.to_string()));
865            }
866            if let Some(v) = &opts.node_id {
867                query.push(("nodeId", v.to_string()));
868            }
869            if let Some(v) = &opts.region_cluster_id {
870                query.push(("regionClusterId", v.to_string()));
871            }
872            if let Some(v) = &opts.since {
873                query.push(("since", v.to_string()));
874            }
875            if let Some(v) = &opts.page {
876                query.push(("page", v.to_string()));
877            }
878            if let Some(v) = &opts.limit {
879                query.push(("limit", v.to_string()));
880            }
881        }
882        self.inner.get(&format!("/api/v1/regions/{}/alerts/list", region_id), &query).await
883    }
884
885    pub async fn count(&self, region_id: i64, region_cluster_id: Option<i64>) -> Result<AlertCountResponse, Error> {
886        let mut query: Vec<(&str, String)> = Vec::new();
887        if let Some(v) = region_cluster_id {
888            query.push(("regionClusterId", v.to_string()));
889        }
890        self.inner.get(&format!("/api/v1/regions/{}/alerts/count", region_id), &query).await
891    }
892
893    pub async fn resolve(&self, region_id: i64, alert_id: &str) -> Result<(), Error> {
894        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/regions/{}/alerts/{}/resolve", region_id, alert_id)).await.map(|_| ())
895    }
896}
897
898/// Operations on the `Vault` resource.
899pub struct VaultService {
900    inner: Arc<ClientInner>,
901}
902
903impl VaultService {
904    pub async fn resync(&self) -> Result<(), Error> {
905        self.inner.post_empty::<serde_json::Value>("/api/v1/vault/resync").await.map(|_| ())
906    }
907}