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