Skip to main content

mountos_admin_sdk/
client_gen.rs

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