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 metadata_clusters: MetadataClustersService,
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            metadata_clusters: MetadataClustersService { 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<MetadataCluster>, 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 `MetadataClusters` resource.
230pub struct MetadataClustersService {
231    inner: Arc<ClientInner>,
232}
233
234impl MetadataClustersService {
235    pub async fn create(&self, region_id: i64, req: &CreateMetadataClusterRequest) -> 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<&MetadataClusterListOptions>) -> Result<PaginatedResponse<MetadataCluster>, 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<MetadataCluster, 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: &EditMetadataClusterRequest) -> 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: &SetMetadataClusterReadyRequest) -> Result<SetReadyMetadataClusterResponse, 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<IdResponse, 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 list_copysets(&self, storage_id: i64, state: Option<&str>, include_retired: Option<bool>) -> Result<Vec<Copyset>, Error> {
349        let mut query: Vec<(&str, String)> = Vec::new();
350        if let Some(v) = state {
351            query.push(("state", v.to_string()));
352        }
353        if let Some(v) = include_retired {
354            query.push(("includeRetired", v.to_string()));
355        }
356        self.inner.get(&format!("/api/v1/storages/{}/copysets", storage_id), &query).await
357    }
358
359    pub async fn get_copyset_status(&self, storage_id: i64, copyset_id: &str) -> Result<Copyset, Error> {
360        self.inner.get(&format!("/api/v1/storages/{}/copysets/{}", storage_id, crate::http::encode_segment(copyset_id)), &[]).await
361    }
362
363    pub async fn drain_copyset(&self, storage_id: i64, copyset_id: &str, req: &DrainStorageCopysetRequest) -> Result<DrainCopysetStorageResponse, Error> {
364        self.inner.post(&format!("/api/v1/storages/{}/copysets/{}/drain", storage_id, crate::http::encode_segment(copyset_id)), req).await
365    }
366
367    pub async fn cancel_drain(&self, storage_id: i64, copyset_id: &str, req: &CancelStorageDrainRequest) -> Result<CancelDrainStorageResponse, Error> {
368        self.inner.post(&format!("/api/v1/storages/{}/copysets/{}/cancel-drain", storage_id, crate::http::encode_segment(copyset_id)), req).await
369    }
370
371    pub async fn update_tags(&self, storage_id: i64, copyset_id: &str, req: &UpdateStorageTagsRequest) -> Result<Copyset, Error> {
372        self.inner.put(&format!("/api/v1/storages/{}/copysets/{}/tags", storage_id, crate::http::encode_segment(copyset_id)), req).await
373    }
374
375    pub async fn register_copyset(&self, storage_id: i64, req: &RegisterStorageCopysetRequest) -> Result<Copyset, Error> {
376        self.inner.post(&format!("/api/v1/storages/{}/copysets", storage_id), req).await
377    }
378
379    pub async fn register_copysets_bulk(&self, storage_id: i64, req: &RegisterStorageCopysetsBulkRequest) -> Result<RegisterCopysetsBulkStorageResponse, Error> {
380        self.inner.post(&format!("/api/v1/storages/{}/copysets/bulk", storage_id), req).await
381    }
382
383    pub async fn add_copyset_member(&self, storage_id: i64, copyset_id: &str, req: &AddStorageCopysetMemberRequest) -> Result<PoolMember, Error> {
384        self.inner.post(&format!("/api/v1/storages/{}/copysets/{}/members", storage_id, crate::http::encode_segment(copyset_id)), req).await
385    }
386
387    pub async fn mark_member_lost(&self, storage_id: i64, copyset_id: &str, req: &MarkStorageMemberLostRequest) -> Result<PoolMember, Error> {
388        self.inner.post(&format!("/api/v1/storages/{}/copysets/{}/members/mark-lost", storage_id, crate::http::encode_segment(copyset_id)), req).await
389    }
390
391    pub async fn remove_member(&self, storage_id: i64, block_volume_id: &str) -> Result<RemoveMemberStorageResponse, Error> {
392        self.inner.delete(&format!("/api/v1/storages/{}/members/{}", storage_id, crate::http::encode_segment(block_volume_id))).await
393    }
394
395    pub async fn backfill_fingerprints(&self) -> Result<BackfillFingerprintsStorageResponse, Error> {
396        self.inner.post_empty("/api/v1/storages/backfill-fingerprints").await
397    }
398}
399
400/// Operations on the `Volumes` resource.
401pub struct VolumesService {
402    inner: Arc<ClientInner>,
403}
404
405impl VolumesService {
406    pub async fn create(&self, req: &CreateVolumeRequest) -> Result<CreateVolumeResponse, Error> {
407        self.inner.post("/api/v1/volumes/create", req).await
408    }
409
410    pub async fn list(&self, opts: &VolumeListOptions) -> Result<PaginatedResponse<Volume>, Error> {
411        let mut query: Vec<(&str, String)> = Vec::new();
412        query.push(("accountId", opts.account_id.to_string()));
413        if let Some(v) = &opts.region_id {
414            query.push(("regionId", v.to_string()));
415        }
416        if let Some(v) = &opts.metadata_cluster_id {
417            query.push(("metadataClusterId", v.to_string()));
418        }
419        if let Some(v) = &opts.storage_id {
420            query.push(("storageId", v.to_string()));
421        }
422        if let Some(v) = &opts.volume_type {
423            query.push(("volumeType", v.to_string()));
424        }
425        if let Some(v) = &opts.locked {
426            query.push(("locked", v.to_string()));
427        }
428        if let Some(v) = &opts.is_active {
429            query.push(("isActive", v.to_string()));
430        }
431        if let Some(v) = &opts.page {
432            query.push(("page", v.to_string()));
433        }
434        if let Some(v) = &opts.limit {
435            query.push(("limit", v.to_string()));
436        }
437        self.inner.get("/api/v1/volumes/list", &query).await
438    }
439
440    pub async fn get(&self, volume_id: i64) -> Result<Volume, Error> {
441        self.inner.get(&format!("/api/v1/volumes/{}", volume_id), &[]).await
442    }
443
444    pub async fn edit(&self, volume_id: i64, req: &EditVolumeRequest) -> Result<IdResponse, Error> {
445        self.inner.put(&format!("/api/v1/volumes/{}", volume_id), req).await
446    }
447
448    pub async fn lock(&self, volume_id: i64) -> Result<IdResponse, Error> {
449        self.inner.post_empty(&format!("/api/v1/volumes/{}/lock", volume_id)).await
450    }
451
452    pub async fn unlock(&self, volume_id: i64) -> Result<IdResponse, Error> {
453        self.inner.post_empty(&format!("/api/v1/volumes/{}/unlock", volume_id)).await
454    }
455
456    pub async fn move_cluster(&self, volume_id: i64, req: &MoveVolumeClusterRequest) -> Result<MoveClusterVolumeResponse, Error> {
457        self.inner.post(&format!("/api/v1/volumes/{}/move-cluster", volume_id), req).await
458    }
459
460    pub async fn deactivate(&self, volume_id: i64, req: &DeactivateVolumeRequest) -> Result<IdResponse, Error> {
461        self.inner.post(&format!("/api/v1/volumes/{}/deactivate", volume_id), req).await
462    }
463
464    pub async fn activate(&self, volume_id: i64) -> Result<IdResponse, Error> {
465        self.inner.post_empty(&format!("/api/v1/volumes/{}/activate", volume_id)).await
466    }
467
468    pub async fn generate_api_keys(&self, volume_id: i64, req: &GenerateVolumeAPIKeysRequest) -> Result<GenerateAPIKeysVolumeResponse, Error> {
469        self.inner.post(&format!("/api/v1/volumes/{}/api-keys/generate", volume_id), req).await
470    }
471
472    pub async fn list_api_keys(&self, volume_id: i64) -> Result<ListAPIKeysVolumeResponse, Error> {
473        self.inner.get(&format!("/api/v1/volumes/{}/api-keys", volume_id), &[]).await
474    }
475
476    pub async fn revoke_api_key(&self, volume_id: i64, req: &RevokeVolumeAPIKeyRequest) -> Result<(), Error> {
477        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke", volume_id), req).await.map(|_| ())
478    }
479
480    pub async fn revoke_api_keys_by_user(&self, volume_id: i64, req: &RevokeVolumeAPIKeysByUserRequest) -> Result<(), Error> {
481        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke-by-user", volume_id), req).await.map(|_| ())
482    }
483
484    pub async fn generate_stt_key(&self, volume_id: i64, req: &GenerateVolumeSttKeyRequest) -> Result<GenerateSttKeyVolumeResponse, Error> {
485        self.inner.post(&format!("/api/v1/volumes/{}/stt-key/generate", volume_id), req).await
486    }
487
488    pub async fn update_quota(&self, volume_id: i64, req: &UpdateVolumeQuotaRequest) -> Result<IdResponse, Error> {
489        self.inner.put(&format!("/api/v1/volumes/{}/quota", volume_id), req).await
490    }
491
492    pub async fn get_copyset_config(&self, volume_id: i64) -> Result<VolumeBlockPlacementConfig, Error> {
493        self.inner.get(&format!("/api/v1/volumes/{}/copyset-config", volume_id), &[]).await
494    }
495
496    pub async fn update_copyset_config(&self, volume_id: i64, req: &UpdateVolumeCopysetConfigRequest) -> Result<VolumeBlockPlacementResizeResult, Error> {
497        self.inner.put(&format!("/api/v1/volumes/{}/copyset-config", volume_id), req).await
498    }
499
500    pub async fn stats(&self, volume_id: i64) -> Result<StatsVolumeResponse, Error> {
501        self.inner.get(&format!("/api/v1/volumes/{}/stats", volume_id), &[]).await
502    }
503
504    pub async fn size_history(&self, volume_id: i64, from: Option<&str>, to: Option<&str>) -> Result<SizeHistoryVolumeResponse, Error> {
505        let mut query: Vec<(&str, String)> = Vec::new();
506        if let Some(v) = from {
507            query.push(("from", v.to_string()));
508        }
509        if let Some(v) = to {
510            query.push(("to", v.to_string()));
511        }
512        self.inner.get(&format!("/api/v1/volumes/{}/size-history", volume_id), &query).await
513    }
514
515    pub async fn create_fork(&self, volume_id: i64, req: &CreateVolumeForkRequest) -> Result<Fork, Error> {
516        self.inner.post(&format!("/api/v1/volumes/{}/forks/create", volume_id), req).await
517    }
518
519    pub async fn exclusive_grants(&self, volume_id: i64, limit: Option<i64>) -> Result<ExclusiveGrantsResponse, Error> {
520        let mut query: Vec<(&str, String)> = Vec::new();
521        if let Some(v) = limit {
522            query.push(("limit", v.to_string()));
523        }
524        self.inner.get(&format!("/api/v1/volumes/{}/exclusive-grants", volume_id), &query).await
525    }
526
527    pub async fn list_forks(&self, volume_id: i64, volume_type: Option<&str>, include_inactive: Option<bool>) -> Result<Vec<Fork>, Error> {
528        let mut query: Vec<(&str, String)> = Vec::new();
529        if let Some(v) = volume_type {
530            query.push(("volumeType", v.to_string()));
531        }
532        if let Some(v) = include_inactive {
533            query.push(("includeInactive", v.to_string()));
534        }
535        self.inner.get(&format!("/api/v1/volumes/{}/forks", volume_id), &query).await
536    }
537
538    pub async fn delete_fork(&self, volume_id: i64, fork_name: &str, req: &DeleteVolumeForkRequest) -> Result<DeleteForkVolumeResponse, Error> {
539        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/delete", volume_id, crate::http::encode_segment(fork_name)), req).await
540    }
541
542    pub async fn restore_fork(&self, volume_id: i64, fork_name: &str, req: &RestoreVolumeForkRequest) -> Result<Fork, Error> {
543        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/restore", volume_id, crate::http::encode_segment(fork_name)), req).await
544    }
545}
546
547/// Operations on the `VolumeForkTrees` resource.
548pub struct VolumeForkTreesService {
549    inner: Arc<ClientInner>,
550}
551
552impl VolumeForkTreesService {
553    pub async fn list(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkTreeListOptions>) -> Result<StringCursorPaginatedResponse<ForkTreeEntry>, Error> {
554        let mut query: Vec<(&str, String)> = Vec::new();
555        if let Some(opts) = opts {
556            if let Some(v) = &opts.path {
557                query.push(("path", v.to_string()));
558            }
559            if let Some(v) = &opts.as_of {
560                query.push(("asOf", v.to_string()));
561            }
562            if let Some(v) = &opts.cursor {
563                query.push(("cursor", v.to_string()));
564            }
565            if let Some(v) = &opts.limit {
566                query.push(("limit", v.to_string()));
567            }
568            if let Some(v) = &opts.sort {
569                query.push(("sort", v.to_string()));
570            }
571            if let Some(v) = &opts.kind {
572                query.push(("kind", v.to_string()));
573            }
574        }
575        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/tree", volume_id, crate::http::encode_segment(fork_name)), &query).await
576    }
577}
578
579/// Operations on the `VolumeForkEntries` resource.
580pub struct VolumeForkEntriesService {
581    inner: Arc<ClientInner>,
582}
583
584impl VolumeForkEntriesService {
585    pub async fn get(&self, volume_id: i64, fork_name: &str, path: Option<&str>, inode: Option<i64>, as_of: Option<i64>) -> Result<ForkEntryDetail, Error> {
586        let mut query: Vec<(&str, String)> = Vec::new();
587        if let Some(v) = path {
588            query.push(("path", v.to_string()));
589        }
590        if let Some(v) = inode {
591            query.push(("inode", v.to_string()));
592        }
593        if let Some(v) = as_of {
594            query.push(("asOf", v.to_string()));
595        }
596        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry", volume_id, crate::http::encode_segment(fork_name)), &query).await
597    }
598
599    pub async fn versions(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkEntryListOptions>) -> Result<CursorPaginatedResponse<ForkEntryVersion>, Error> {
600        let mut query: Vec<(&str, String)> = Vec::new();
601        if let Some(opts) = opts {
602            if let Some(v) = &opts.path {
603                query.push(("path", v.to_string()));
604            }
605            if let Some(v) = &opts.cursor {
606                query.push(("cursor", v.to_string()));
607            }
608            if let Some(v) = &opts.limit {
609                query.push(("limit", v.to_string()));
610            }
611        }
612        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry/versions", volume_id, crate::http::encode_segment(fork_name)), &query).await
613    }
614}
615
616/// Operations on the `VolumeForkSearches` resource.
617pub struct VolumeForkSearchesService {
618    inner: Arc<ClientInner>,
619}
620
621impl VolumeForkSearchesService {
622    pub async fn find(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkSearchListOptions>) -> Result<CursorPaginatedResponse<ForkTreeMatch>, Error> {
623        let mut query: Vec<(&str, String)> = Vec::new();
624        if let Some(opts) = opts {
625            if let Some(v) = &opts.q {
626                query.push(("q", v.to_string()));
627            }
628            if let Some(v) = &opts.path {
629                query.push(("path", v.to_string()));
630            }
631            if let Some(v) = &opts.as_of {
632                query.push(("asOf", v.to_string()));
633            }
634            if let Some(v) = &opts.exact {
635                query.push(("exact", v.to_string()));
636            }
637            if let Some(v) = &opts.cursor {
638                query.push(("cursor", v.to_string()));
639            }
640            if let Some(v) = &opts.limit {
641                query.push(("limit", v.to_string()));
642            }
643            if let Some(v) = &opts.kind {
644                query.push(("kind", v.to_string()));
645            }
646        }
647        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/search", volume_id, crate::http::encode_segment(fork_name)), &query).await
648    }
649}
650
651/// Operations on the `AuditLogs` resource.
652pub struct AuditLogsService {
653    inner: Arc<ClientInner>,
654}
655
656impl AuditLogsService {
657    pub async fn list(&self, opts: &AuditLogListOptions) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
658        let mut query: Vec<(&str, String)> = Vec::new();
659        query.push(("accountId", opts.account_id.to_string()));
660        if let Some(v) = &opts.region_id {
661            query.push(("regionId", v.to_string()));
662        }
663        if let Some(v) = &opts.metadata_cluster_id {
664            query.push(("metadataClusterId", v.to_string()));
665        }
666        if let Some(v) = &opts.cursor {
667            query.push(("cursor", v.to_string()));
668        }
669        if let Some(v) = &opts.limit {
670            query.push(("limit", v.to_string()));
671        }
672        if let Some(v) = &opts.subject {
673            query.push(("subject", v.to_string()));
674        }
675        if let Some(v) = &opts.created_by {
676            query.push(("createdBy", v.to_string()));
677        }
678        self.inner.get("/api/v1/audit-logs/list", &query).await
679    }
680}
681
682/// Operations on the `RegionAuditLogs` resource.
683pub struct RegionAuditLogsService {
684    inner: Arc<ClientInner>,
685}
686
687impl RegionAuditLogsService {
688    pub async fn list(&self, region_id: i64, opts: Option<&RegionAuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
689        let mut query: Vec<(&str, String)> = Vec::new();
690        if let Some(opts) = opts {
691            if let Some(v) = &opts.metadata_cluster_id {
692                query.push(("metadataClusterId", v.to_string()));
693            }
694            if let Some(v) = &opts.cursor {
695                query.push(("cursor", v.to_string()));
696            }
697            if let Some(v) = &opts.limit {
698                query.push(("limit", v.to_string()));
699            }
700            if let Some(v) = &opts.subject {
701                query.push(("subject", v.to_string()));
702            }
703            if let Some(v) = &opts.node {
704                query.push(("node", v.to_string()));
705            }
706        }
707        self.inner.get(&format!("/api/v1/regions/{}/audit-logs/list", region_id), &query).await
708    }
709}
710
711/// Operations on the `ServiceNodes` resource.
712pub struct ServiceNodesService {
713    inner: Arc<ClientInner>,
714}
715
716impl ServiceNodesService {
717    pub async fn list(&self, region_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>, metadata_cluster_id: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
718        let mut query: Vec<(&str, String)> = Vec::new();
719        if let Some(v) = service_type {
720            query.push(("serviceType", v.to_string()));
721        }
722        if let Some(v) = status {
723            query.push(("status", v.to_string()));
724        }
725        if let Some(v) = inactive_hours {
726            query.push(("inactiveHours", v.to_string()));
727        }
728        if let Some(v) = metadata_cluster_id {
729            query.push(("metadataClusterId", v.to_string()));
730        }
731        self.inner.get(&format!("/api/v1/regions/{}/nodes", region_id), &query).await
732    }
733
734    pub async fn stats(&self, region_id: i64, node_id: &str) -> Result<String, Error> {
735        self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats", region_id, crate::http::encode_segment(node_id)), &[]).await
736    }
737
738    pub async fn stats_history(&self, region_id: i64, node_id: &str) -> Result<StatsHistoryServiceNodeResponse, Error> {
739        self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats/history", region_id, crate::http::encode_segment(node_id)), &[]).await
740    }
741}
742
743/// Operations on the `Nodes` resource.
744pub struct NodesService {
745    inner: Arc<ClientInner>,
746}
747
748impl NodesService {
749    pub async fn list(&self, account_id: i64, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
750        let mut query: Vec<(&str, String)> = Vec::new();
751        query.push(("accountId", account_id.to_string()));
752        if let Some(v) = service_type {
753            query.push(("serviceType", v.to_string()));
754        }
755        if let Some(v) = status {
756            query.push(("status", v.to_string()));
757        }
758        if let Some(v) = inactive_hours {
759            query.push(("inactiveHours", v.to_string()));
760        }
761        self.inner.get("/api/v1/nodes", &query).await
762    }
763}
764
765/// Operations on the `ClientSessions` resource.
766pub struct ClientSessionsService {
767    inner: Arc<ClientInner>,
768}
769
770impl ClientSessionsService {
771    pub async fn list(&self, opts: &ClientSessionListOptions) -> Result<PaginatedResponse<ClientSession>, Error> {
772        let mut query: Vec<(&str, String)> = Vec::new();
773        query.push(("accountId", opts.account_id.to_string()));
774        if let Some(v) = &opts.region_id {
775            query.push(("regionId", v.to_string()));
776        }
777        if let Some(v) = &opts.metadata_cluster_id {
778            query.push(("metadataClusterId", v.to_string()));
779        }
780        if let Some(v) = &opts.volume_id {
781            query.push(("volumeId", v.to_string()));
782        }
783        if let Some(v) = &opts.user_id {
784            query.push(("userId", v.to_string()));
785        }
786        if let Some(v) = &opts.client_type {
787            query.push(("clientType", v.to_string()));
788        }
789        if let Some(v) = &opts.status {
790            query.push(("status", v.to_string()));
791        }
792        if let Some(v) = &opts.is_active {
793            query.push(("isActive", v.to_string()));
794        }
795        if let Some(v) = &opts.os_name {
796            query.push(("osName", v.to_string()));
797        }
798        if let Some(v) = &opts.platform {
799            query.push(("platform", v.to_string()));
800        }
801        if let Some(v) = &opts.search {
802            query.push(("search", v.to_string()));
803        }
804        if let Some(v) = &opts.page {
805            query.push(("page", v.to_string()));
806        }
807        if let Some(v) = &opts.limit {
808            query.push(("limit", v.to_string()));
809        }
810        self.inner.get("/api/v1/client-sessions/list", &query).await
811    }
812
813    pub async fn get(&self, session_id: i64) -> Result<ClientSession, Error> {
814        self.inner.get(&format!("/api/v1/client-sessions/{}", session_id), &[]).await
815    }
816
817    pub async fn summary(&self, account_id: i64, region_id: Option<i64>, metadata_cluster_id: Option<i64>, volume_id: Option<i64>, user_id: Option<i64>) -> Result<SessionSummary, Error> {
818        let mut query: Vec<(&str, String)> = Vec::new();
819        query.push(("accountId", account_id.to_string()));
820        if let Some(v) = region_id {
821            query.push(("regionId", v.to_string()));
822        }
823        if let Some(v) = metadata_cluster_id {
824            query.push(("metadataClusterId", v.to_string()));
825        }
826        if let Some(v) = volume_id {
827            query.push(("volumeId", v.to_string()));
828        }
829        if let Some(v) = user_id {
830            query.push(("userId", v.to_string()));
831        }
832        self.inner.get("/api/v1/client-sessions/summary", &query).await
833    }
834
835    pub async fn mount_report(&self, session_id: i64) -> Result<MountReportResponse, Error> {
836        self.inner.get(&format!("/api/v1/client-sessions/{}/mount-report", session_id), &[]).await
837    }
838
839    pub async fn support_bundle(&self, session_id: i64) -> Result<SupportBundle, Error> {
840        self.inner.get(&format!("/api/v1/client-sessions/{}/support-bundle", session_id), &[]).await
841    }
842}
843
844/// Operations on the `Discover` resource.
845pub struct DiscoverService {
846    inner: Arc<ClientInner>,
847}
848
849impl DiscoverService {
850    pub async fn meta(&self, access_key_id: &str) -> Result<DiscoverMetaResponse, Error> {
851        let mut query: Vec<(&str, String)> = Vec::new();
852        query.push(("accessKeyId", access_key_id.to_string()));
853        self.inner.get("/api/v1/discover/meta", &query).await
854    }
855
856    pub async fn metrics_targets(&self) -> Result<Vec<MetricsTarget>, Error> {
857        self.inner.get("/api/v1/discover/metrics-targets", &[]).await
858    }
859}
860
861/// Operations on the `Metrics` resource.
862pub struct MetricsService {
863    inner: Arc<ClientInner>,
864}
865
866impl MetricsService {
867    pub async fn generate_token(&self, req: &GenerateMetricTokenRequest) -> Result<MetricsTokenResponse, Error> {
868        self.inner.post("/api/v1/metrics/token", req).await
869    }
870}
871
872/// Operations on the `Dashboard` resource.
873pub struct DashboardService {
874    inner: Arc<ClientInner>,
875}
876
877impl DashboardService {
878    pub async fn stats(&self, account_id: i64) -> Result<DashboardStats, Error> {
879        let mut query: Vec<(&str, String)> = Vec::new();
880        query.push(("accountId", account_id.to_string()));
881        self.inner.get("/api/v1/dashboard/stats", &query).await
882    }
883}
884
885/// Operations on the `License` resource.
886pub struct LicenseService {
887    inner: Arc<ClientInner>,
888}
889
890impl LicenseService {
891    pub async fn get(&self) -> Result<LicenseDetails, Error> {
892        self.inner.get("/api/v1/license", &[]).await
893    }
894
895    pub async fn terms(&self) -> Result<LicenseTerms, Error> {
896        self.inner.get("/api/v1/license/terms", &[]).await
897    }
898
899    pub async fn load(&self, req: &LoadLicenseRequest) -> Result<LicenseLoadResult, Error> {
900        self.inner.post("/api/v1/license/load", req).await
901    }
902
903    pub async fn list(&self) -> Result<LicenseList, Error> {
904        self.inner.get("/api/v1/license/list", &[]).await
905    }
906}
907
908/// Operations on the `Alerts` resource.
909pub struct AlertsService {
910    inner: Arc<ClientInner>,
911}
912
913impl AlertsService {
914    pub async fn list(&self, opts: Option<&AlertListOptions>) -> Result<PaginatedResponse<ServiceAlert>, Error> {
915        let mut query: Vec<(&str, String)> = Vec::new();
916        if let Some(opts) = opts {
917            if let Some(v) = &opts.active {
918                query.push(("active", v.to_string()));
919            }
920            if let Some(v) = &opts.account_id {
921                query.push(("accountId", v.to_string()));
922            }
923            if let Some(v) = &opts.region_id {
924                query.push(("regionId", v.to_string()));
925            }
926            if let Some(v) = &opts.severity {
927                query.push(("severity", v.to_string()));
928            }
929            if let Some(v) = &opts.category {
930                query.push(("category", v.to_string()));
931            }
932            if let Some(v) = &opts.since {
933                query.push(("since", v.to_string()));
934            }
935            if let Some(v) = &opts.page {
936                query.push(("page", v.to_string()));
937            }
938            if let Some(v) = &opts.limit {
939                query.push(("limit", v.to_string()));
940            }
941        }
942        self.inner.get("/api/v1/alerts/list", &query).await
943    }
944
945    pub async fn count(&self) -> Result<AlertCountResponse, Error> {
946        self.inner.get("/api/v1/alerts/count", &[]).await
947    }
948
949    pub async fn resolve(&self, alert_id: &str) -> Result<ResolveAlertResponse, Error> {
950        self.inner.post_empty(&format!("/api/v1/alerts/{}/resolve", crate::http::encode_segment(alert_id))).await
951    }
952}
953
954/// Operations on the `RegionAlerts` resource.
955pub struct RegionAlertsService {
956    inner: Arc<ClientInner>,
957}
958
959impl RegionAlertsService {
960    pub async fn list(&self, region_id: i64, opts: Option<&RegionAlertListOptions>) -> Result<PaginatedResponse<RegionAlert>, Error> {
961        let mut query: Vec<(&str, String)> = Vec::new();
962        if let Some(opts) = opts {
963            if let Some(v) = &opts.active {
964                query.push(("active", v.to_string()));
965            }
966            if let Some(v) = &opts.severity {
967                query.push(("severity", v.to_string()));
968            }
969            if let Some(v) = &opts.category {
970                query.push(("category", v.to_string()));
971            }
972            if let Some(v) = &opts.node_id {
973                query.push(("nodeId", v.to_string()));
974            }
975            if let Some(v) = &opts.metadata_cluster_id {
976                query.push(("metadataClusterId", v.to_string()));
977            }
978            if let Some(v) = &opts.since {
979                query.push(("since", v.to_string()));
980            }
981            if let Some(v) = &opts.page {
982                query.push(("page", v.to_string()));
983            }
984            if let Some(v) = &opts.limit {
985                query.push(("limit", v.to_string()));
986            }
987        }
988        self.inner.get(&format!("/api/v1/regions/{}/alerts/list", region_id), &query).await
989    }
990
991    pub async fn count(&self, region_id: i64, metadata_cluster_id: Option<i64>) -> Result<AlertCountResponse, Error> {
992        let mut query: Vec<(&str, String)> = Vec::new();
993        if let Some(v) = metadata_cluster_id {
994            query.push(("metadataClusterId", v.to_string()));
995        }
996        self.inner.get(&format!("/api/v1/regions/{}/alerts/count", region_id), &query).await
997    }
998
999    pub async fn resolve(&self, region_id: i64, alert_id: &str) -> Result<ResolveRegionAlertResponse, Error> {
1000        self.inner.post_empty(&format!("/api/v1/regions/{}/alerts/{}/resolve", region_id, crate::http::encode_segment(alert_id))).await
1001    }
1002}
1003
1004/// Operations on the `GCWorkerEvents` resource.
1005pub struct GCWorkerEventsService {
1006    inner: Arc<ClientInner>,
1007}
1008
1009impl GCWorkerEventsService {
1010    pub async fn list(&self, region_id: i64, opts: Option<&GCWorkerEventListOptions>) -> Result<PaginatedResponse<GCWorkerEvent>, Error> {
1011        let mut query: Vec<(&str, String)> = Vec::new();
1012        if let Some(opts) = opts {
1013            if let Some(v) = &opts.node_id {
1014                query.push(("nodeId", v.to_string()));
1015            }
1016            if let Some(v) = &opts.goal {
1017                query.push(("goal", v.to_string()));
1018            }
1019            if let Some(v) = &opts.sid {
1020                query.push(("sid", v.to_string()));
1021            }
1022            if let Some(v) = &opts.metadata_cluster_id {
1023                query.push(("metadataClusterId", v.to_string()));
1024            }
1025            if let Some(v) = &opts.since {
1026                query.push(("since", v.to_string()));
1027            }
1028            if let Some(v) = &opts.page {
1029                query.push(("page", v.to_string()));
1030            }
1031            if let Some(v) = &opts.limit {
1032                query.push(("limit", v.to_string()));
1033            }
1034        }
1035        self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/list", region_id), &query).await
1036    }
1037
1038    pub async fn histogram(&self, region_id: i64, node_id: Option<&str>, goal: Option<&str>, sid: Option<i64>, metadata_cluster_id: Option<i64>, since: Option<&str>, bucket_seconds: Option<i64>) -> Result<GCWorkerEventHistogramResponse, Error> {
1039        let mut query: Vec<(&str, String)> = Vec::new();
1040        if let Some(v) = node_id {
1041            query.push(("nodeId", v.to_string()));
1042        }
1043        if let Some(v) = goal {
1044            query.push(("goal", v.to_string()));
1045        }
1046        if let Some(v) = sid {
1047            query.push(("sid", v.to_string()));
1048        }
1049        if let Some(v) = metadata_cluster_id {
1050            query.push(("metadataClusterId", v.to_string()));
1051        }
1052        if let Some(v) = since {
1053            query.push(("since", v.to_string()));
1054        }
1055        if let Some(v) = bucket_seconds {
1056            query.push(("bucketSeconds", v.to_string()));
1057        }
1058        self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/histogram", region_id), &query).await
1059    }
1060
1061    pub async fn goals(&self, region_id: i64, node_id: Option<&str>) -> Result<GCWorkerEventGoalsResponse, Error> {
1062        let mut query: Vec<(&str, String)> = Vec::new();
1063        if let Some(v) = node_id {
1064            query.push(("nodeId", v.to_string()));
1065        }
1066        self.inner.get(&format!("/api/v1/regions/{}/gc-worker-events/goals", region_id), &query).await
1067    }
1068}
1069
1070/// Operations on the `Vault` resource.
1071pub struct VaultService {
1072    inner: Arc<ClientInner>,
1073}
1074
1075impl VaultService {
1076    pub async fn resync(&self) -> Result<(), Error> {
1077        self.inner.post_empty::<serde_json::Value>("/api/v1/vault/resync").await.map(|_| ())
1078    }
1079}