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