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