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