mountos-admin-sdk 0.77.0

Rust SDK for the mountOS provider API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
// Code generated by gen; DO NOT EDIT.

use std::sync::Arc;

use crate::errors::Error;
use crate::http::ClientInner;
use crate::types_gen::*;

/// mountOS Admin API client. Construct with [`Client::new`].
pub struct Client {
    pub accounts: AccountsService,
    pub users: UsersService,
    pub regions: RegionsService,
    pub region_clusters: RegionClustersService,
    pub storages: StoragesService,
    pub volumes: VolumesService,
    pub volume_fork_trees: VolumeForkTreesService,
    pub volume_fork_entries: VolumeForkEntriesService,
    pub volume_fork_searches: VolumeForkSearchesService,
    pub audit_logs: AuditLogsService,
    pub region_audit_logs: RegionAuditLogsService,
    pub service_nodes: ServiceNodesService,
    pub nodes: NodesService,
    pub client_sessions: ClientSessionsService,
    pub discover: DiscoverService,
    pub dashboard: DashboardService,
    pub license: LicenseService,
    pub alerts: AlertsService,
    pub region_alerts: RegionAlertsService,
    pub vault: VaultService,
}

impl Client {
    /// Create a client from configuration. Fails if the private key is invalid.
    pub fn new(config: Config) -> Result<Self, Error> {
        let inner = Arc::new(ClientInner::new(config)?);
        Ok(Self {
            accounts: AccountsService { inner: Arc::clone(&inner) },
            users: UsersService { inner: Arc::clone(&inner) },
            regions: RegionsService { inner: Arc::clone(&inner) },
            region_clusters: RegionClustersService { inner: Arc::clone(&inner) },
            storages: StoragesService { inner: Arc::clone(&inner) },
            volumes: VolumesService { inner: Arc::clone(&inner) },
            volume_fork_trees: VolumeForkTreesService { inner: Arc::clone(&inner) },
            volume_fork_entries: VolumeForkEntriesService { inner: Arc::clone(&inner) },
            volume_fork_searches: VolumeForkSearchesService { inner: Arc::clone(&inner) },
            audit_logs: AuditLogsService { inner: Arc::clone(&inner) },
            region_audit_logs: RegionAuditLogsService { inner: Arc::clone(&inner) },
            service_nodes: ServiceNodesService { inner: Arc::clone(&inner) },
            nodes: NodesService { inner: Arc::clone(&inner) },
            client_sessions: ClientSessionsService { inner: Arc::clone(&inner) },
            discover: DiscoverService { inner: Arc::clone(&inner) },
            dashboard: DashboardService { inner: Arc::clone(&inner) },
            license: LicenseService { inner: Arc::clone(&inner) },
            alerts: AlertsService { inner: Arc::clone(&inner) },
            region_alerts: RegionAlertsService { inner: Arc::clone(&inner) },
            vault: VaultService { inner: Arc::clone(&inner) },
        })
    }
}

/// Operations on the `Accounts` resource.
pub struct AccountsService {
    inner: Arc<ClientInner>,
}

impl AccountsService {
    pub async fn create(&self, req: &CreateAccountRequest) -> Result<IdResponse, Error> {
        self.inner.post("/api/v1/accounts/create", req).await
    }

    pub async fn list(&self, opts: Option<&AccountListOptions>) -> Result<PaginatedResponse<Account>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/accounts/list", &query).await
    }

    pub async fn get(&self, account_id: i64) -> Result<Account, Error> {
        self.inner.get(&format!("/api/v1/accounts/{}", account_id), &[]).await
    }

    pub async fn edit(&self, account_id: i64, req: &EditAccountRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/accounts/{}/edit", account_id), req).await
    }

    pub async fn lock(&self, account_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/accounts/{}/lock", account_id)).await
    }

    pub async fn unlock(&self, account_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/accounts/{}/unlock", account_id)).await
    }

    pub async fn deactivate(&self, account_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/accounts/{}/deactivate", account_id)).await
    }

    pub async fn update_quota(&self, account_id: i64, req: &UpdateAccountQuotaRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/accounts/{}/quota", account_id), req).await
    }
}

/// Operations on the `Users` resource.
pub struct UsersService {
    inner: Arc<ClientInner>,
}

impl UsersService {
    pub async fn add(&self, req: &AddUserRequest) -> Result<IdResponse, Error> {
        self.inner.post("/api/v1/users/add", req).await
    }

    pub async fn list(&self, opts: Option<&UserListOptions>) -> Result<PaginatedResponse<User>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            query.push(("accountId", opts.account_id.to_string()));
            if let Some(v) = &opts.search {
                query.push(("search", v.to_string()));
            }
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/users/list", &query).await
    }

    pub async fn get(&self, user_id: i64) -> Result<User, Error> {
        self.inner.get(&format!("/api/v1/users/{}", user_id), &[]).await
    }

    pub async fn bulk(&self, req: &BulkUserRequest) -> Result<BulkUserResponse, Error> {
        self.inner.post("/api/v1/users/bulk", req).await
    }

    pub async fn edit(&self, user_id: i64, req: &EditUserRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/users/{}/edit", user_id), req).await
    }

    pub async fn deactivate(&self, user_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/users/{}/deactivate", user_id)).await
    }
}

/// Operations on the `Regions` resource.
pub struct RegionsService {
    inner: Arc<ClientInner>,
}

impl RegionsService {
    pub async fn create(&self, req: &CreateRegionRequest) -> Result<IdResponse, Error> {
        self.inner.post("/api/v1/regions/create", req).await
    }

    pub async fn list(&self, opts: Option<&RegionListOptions>) -> Result<PaginatedResponse<Region>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/regions/list", &query).await
    }

    pub async fn get(&self, region_id: i64) -> Result<Region, Error> {
        self.inner.get(&format!("/api/v1/regions/{}", region_id), &[]).await
    }

    pub async fn edit(&self, region_id: i64, req: &EditRegionRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/regions/{}/edit", region_id), req).await
    }

    pub async fn deactivate(&self, region_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/regions/{}/deactivate", region_id)).await
    }
}

/// Operations on the `RegionClusters` resource.
pub struct RegionClustersService {
    inner: Arc<ClientInner>,
}

impl RegionClustersService {
    pub async fn create(&self, region_id: i64, req: &CreateRegionClusterRequest) -> Result<IdResponse, Error> {
        self.inner.post(&format!("/api/v1/regions/{}/clusters/create", region_id), req).await
    }

    pub async fn list(&self, region_id: i64, opts: Option<&RegionClusterListOptions>) -> Result<PaginatedResponse<RegionCluster>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/regions/{}/clusters/list", region_id), &query).await
    }

    pub async fn get(&self, region_id: i64, cluster_id: i64) -> Result<RegionCluster, Error> {
        self.inner.get(&format!("/api/v1/regions/{}/clusters/{}", region_id, cluster_id), &[]).await
    }

    pub async fn edit(&self, region_id: i64, cluster_id: i64, req: &EditRegionClusterRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/regions/{}/clusters/{}/edit", region_id, cluster_id), req).await
    }

    pub async fn set_default(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/set-default", region_id, cluster_id)).await
    }

    pub async fn set_ready(&self, region_id: i64, cluster_id: i64, req: &SetRegionClusterReadyRequest) -> Result<SetReadyRegionClusterResponse, Error> {
        self.inner.post(&format!("/api/v1/regions/{}/clusters/{}/set-ready", region_id, cluster_id), req).await
    }

    pub async fn deactivate(&self, region_id: i64, cluster_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/regions/{}/clusters/{}/deactivate", region_id, cluster_id)).await
    }
}

/// Operations on the `Storages` resource.
pub struct StoragesService {
    inner: Arc<ClientInner>,
}

impl StoragesService {
    pub async fn create(&self, req: &CreateStorageRequest) -> Result<IdResponse, Error> {
        self.inner.post("/api/v1/storages/create", req).await
    }

    pub async fn list(&self, opts: Option<&StorageListOptions>) -> Result<PaginatedResponse<Storage>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            query.push(("accountId", opts.account_id.to_string()));
            if let Some(v) = &opts.search {
                query.push(("search", v.to_string()));
            }
            if let Some(v) = &opts.region_id {
                query.push(("regionId", v.to_string()));
            }
            if let Some(v) = &opts.storage_type {
                query.push(("storageType", v.to_string()));
            }
            if let Some(v) = &opts.provider_type {
                query.push(("providerType", v.to_string()));
            }
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/storages/list", &query).await
    }

    pub async fn get(&self, storage_id: i64) -> Result<Storage, Error> {
        self.inner.get(&format!("/api/v1/storages/{}", storage_id), &[]).await
    }

    pub async fn edit(&self, storage_id: i64, req: &EditStorageRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/storages/{}/edit", storage_id), req).await
    }

    pub async fn deactivate(&self, storage_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/storages/{}/deactivate", storage_id)).await
    }

    pub async fn test_bucket(&self, req: &TestStorageBucketRequest) -> Result<TestBucketStorageResponse, Error> {
        self.inner.post("/api/v1/storages/test-bucket", req).await
    }

    pub async fn test_storage_bucket(&self, storage_id: i64) -> Result<TestStorageBucketStorageResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/storages/{}/test-bucket", storage_id)).await
    }
}

/// Operations on the `Volumes` resource.
pub struct VolumesService {
    inner: Arc<ClientInner>,
}

impl VolumesService {
    pub async fn create(&self, req: &CreateVolumeRequest) -> Result<CreateVolumeResponse, Error> {
        self.inner.post("/api/v1/volumes/create", req).await
    }

    pub async fn list(&self, opts: Option<&VolumeListOptions>) -> Result<PaginatedResponse<Volume>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            query.push(("accountId", opts.account_id.to_string()));
            if let Some(v) = &opts.region_id {
                query.push(("regionId", v.to_string()));
            }
            if let Some(v) = &opts.region_cluster_id {
                query.push(("regionClusterId", v.to_string()));
            }
            if let Some(v) = &opts.storage_id {
                query.push(("storageId", v.to_string()));
            }
            if let Some(v) = &opts.volume_type {
                query.push(("volumeType", v.to_string()));
            }
            if let Some(v) = &opts.locked {
                query.push(("locked", v.to_string()));
            }
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/volumes/list", &query).await
    }

    pub async fn get(&self, volume_id: i64) -> Result<Volume, Error> {
        self.inner.get(&format!("/api/v1/volumes/{}", volume_id), &[]).await
    }

    pub async fn edit(&self, volume_id: i64, req: &EditVolumeRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/volumes/{}/edit", volume_id), req).await
    }

    pub async fn lock(&self, volume_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/volumes/{}/lock", volume_id)).await
    }

    pub async fn unlock(&self, volume_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/volumes/{}/unlock", volume_id)).await
    }

    pub async fn move_cluster(&self, volume_id: i64, req: &MoveVolumeClusterRequest) -> Result<MoveClusterVolumeResponse, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/move-cluster", volume_id), req).await
    }

    pub async fn deactivate(&self, volume_id: i64, req: &DeactivateVolumeRequest) -> Result<IdResponse, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/deactivate", volume_id), req).await
    }

    pub async fn activate(&self, volume_id: i64) -> Result<IdResponse, Error> {
        self.inner.post_empty(&format!("/api/v1/volumes/{}/activate", volume_id)).await
    }

    pub async fn generate_api_keys(&self, volume_id: i64, req: &GenerateVolumeAPIKeysRequest) -> Result<GenerateAPIKeysVolumeResponse, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/api-keys/generate", volume_id), req).await
    }

    pub async fn revoke_api_key(&self, volume_id: i64, req: &RevokeVolumeAPIKeyRequest) -> Result<(), Error> {
        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke", volume_id), req).await.map(|_| ())
    }

    pub async fn revoke_api_keys_by_user(&self, volume_id: i64, req: &RevokeVolumeAPIKeysByUserRequest) -> Result<(), Error> {
        self.inner.post::<serde_json::Value, _>(&format!("/api/v1/volumes/{}/api-keys/revoke-by-user", volume_id), req).await.map(|_| ())
    }

    pub async fn update_quota(&self, volume_id: i64, req: &UpdateVolumeQuotaRequest) -> Result<IdResponse, Error> {
        self.inner.put(&format!("/api/v1/volumes/{}/quota", volume_id), req).await
    }

    pub async fn stats(&self, volume_id: i64) -> Result<StatsVolumeResponse, Error> {
        self.inner.get(&format!("/api/v1/volumes/{}/stats", volume_id), &[]).await
    }

    pub async fn size_history(&self, volume_id: i64, from: Option<&str>, to: Option<&str>) -> Result<SizeHistoryVolumeResponse, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = from {
            query.push(("from", v.to_string()));
        }
        if let Some(v) = to {
            query.push(("to", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/volumes/{}/size-history", volume_id), &query).await
    }

    pub async fn create_fork(&self, volume_id: i64, req: &CreateVolumeForkRequest) -> Result<Fork, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/forks/create", volume_id), req).await
    }

    pub async fn list_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = volume_type {
            query.push(("volumeType", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks", volume_id), &query).await
    }

    pub async fn list_all_forks(&self, volume_id: i64, volume_type: Option<&str>) -> Result<Vec<Fork>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = volume_type {
            query.push(("volumeType", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks?include_inactive=true", volume_id), &query).await
    }

    pub async fn delete_fork(&self, volume_id: i64, fork_name: &str, req: &DeleteVolumeForkRequest) -> Result<DeleteForkVolumeResponse, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/delete", volume_id, fork_name), req).await
    }

    pub async fn restore_fork(&self, volume_id: i64, fork_name: &str, req: &RestoreVolumeForkRequest) -> Result<Fork, Error> {
        self.inner.post(&format!("/api/v1/volumes/{}/forks/{}/restore", volume_id, fork_name), req).await
    }
}

/// Operations on the `VolumeForkTrees` resource.
pub struct VolumeForkTreesService {
    inner: Arc<ClientInner>,
}

impl VolumeForkTreesService {
    pub async fn list(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkTreeListOptions>) -> Result<CursorPaginatedResponse<ForkTreeEntry>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.path {
                query.push(("path", v.to_string()));
            }
            if let Some(v) = &opts.as_of {
                query.push(("asOf", v.to_string()));
            }
            if let Some(v) = &opts.cursor {
                query.push(("cursor", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
            if let Some(v) = &opts.sort {
                query.push(("sort", v.to_string()));
            }
            if let Some(v) = &opts.kind {
                query.push(("kind", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/tree", volume_id, fork_name), &query).await
    }
}

/// Operations on the `VolumeForkEntries` resource.
pub struct VolumeForkEntriesService {
    inner: Arc<ClientInner>,
}

impl VolumeForkEntriesService {
    pub async fn get(&self, volume_id: i64, fork_name: &str, path: Option<&str>, inode: Option<i64>, as_of: Option<i64>) -> Result<ForkEntryDetail, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = path {
            query.push(("path", v.to_string()));
        }
        if let Some(v) = inode {
            query.push(("inode", v.to_string()));
        }
        if let Some(v) = as_of {
            query.push(("asOf", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry", volume_id, fork_name), &query).await
    }

    pub async fn versions(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkEntryListOptions>) -> Result<CursorPaginatedResponse<ForkEntryVersion>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.path {
                query.push(("path", v.to_string()));
            }
            if let Some(v) = &opts.cursor {
                query.push(("cursor", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/entry/versions", volume_id, fork_name), &query).await
    }
}

/// Operations on the `VolumeForkSearches` resource.
pub struct VolumeForkSearchesService {
    inner: Arc<ClientInner>,
}

impl VolumeForkSearchesService {
    pub async fn find(&self, volume_id: i64, fork_name: &str, opts: Option<&VolumeForkSearchListOptions>) -> Result<CursorPaginatedResponse<ForkTreeMatch>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.q {
                query.push(("q", v.to_string()));
            }
            if let Some(v) = &opts.path {
                query.push(("path", v.to_string()));
            }
            if let Some(v) = &opts.as_of {
                query.push(("asOf", v.to_string()));
            }
            if let Some(v) = &opts.exact {
                query.push(("exact", v.to_string()));
            }
            if let Some(v) = &opts.cursor {
                query.push(("cursor", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
            if let Some(v) = &opts.kind {
                query.push(("kind", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/volumes/{}/forks/{}/search", volume_id, fork_name), &query).await
    }
}

/// Operations on the `AuditLogs` resource.
pub struct AuditLogsService {
    inner: Arc<ClientInner>,
}

impl AuditLogsService {
    pub async fn list(&self, opts: Option<&AuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.account_id {
                query.push(("accountId", v.to_string()));
            }
            if let Some(v) = &opts.region_id {
                query.push(("regionId", v.to_string()));
            }
            if let Some(v) = &opts.region_cluster_id {
                query.push(("regionClusterId", v.to_string()));
            }
            if let Some(v) = &opts.cursor {
                query.push(("cursor", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
            if let Some(v) = &opts.subject {
                query.push(("subject", v.to_string()));
            }
        }
        self.inner.get("/api/v1/audit-logs/list", &query).await
    }
}

/// Operations on the `RegionAuditLogs` resource.
pub struct RegionAuditLogsService {
    inner: Arc<ClientInner>,
}

impl RegionAuditLogsService {
    pub async fn list(&self, region_id: i64, opts: Option<&RegionAuditLogListOptions>) -> Result<CursorPaginatedResponse<AuditLog>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.region_cluster_id {
                query.push(("regionClusterId", v.to_string()));
            }
            if let Some(v) = &opts.cursor {
                query.push(("cursor", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
            if let Some(v) = &opts.subject {
                query.push(("subject", v.to_string()));
            }
            if let Some(v) = &opts.node {
                query.push(("node", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/regions/{}/audit-logs/list", region_id), &query).await
    }
}

/// Operations on the `ServiceNodes` resource.
pub struct ServiceNodesService {
    inner: Arc<ClientInner>,
}

impl ServiceNodesService {
    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> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = service_type {
            query.push(("serviceType", v.to_string()));
        }
        if let Some(v) = status {
            query.push(("status", v.to_string()));
        }
        if let Some(v) = inactive_hours {
            query.push(("inactiveHours", v.to_string()));
        }
        if let Some(v) = region_cluster_id {
            query.push(("regionClusterId", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/regions/{}/nodes", region_id), &query).await
    }

    pub async fn stats(&self, region_id: i64, node_id: &str) -> Result<String, Error> {
        self.inner.get(&format!("/api/v1/regions/{}/nodes/{}/stats", region_id, crate::http::encode_segment(node_id)), &[]).await
    }
}

/// Operations on the `Nodes` resource.
pub struct NodesService {
    inner: Arc<ClientInner>,
}

impl NodesService {
    pub async fn list_all(&self, service_type: Option<&str>, status: Option<&str>, inactive_hours: Option<i64>) -> Result<Vec<ServiceNode>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = service_type {
            query.push(("serviceType", v.to_string()));
        }
        if let Some(v) = status {
            query.push(("status", v.to_string()));
        }
        if let Some(v) = inactive_hours {
            query.push(("inactiveHours", v.to_string()));
        }
        self.inner.get("/api/v1/nodes", &query).await
    }
}

/// Operations on the `ClientSessions` resource.
pub struct ClientSessionsService {
    inner: Arc<ClientInner>,
}

impl ClientSessionsService {
    pub async fn list(&self, opts: Option<&ClientSessionListOptions>) -> Result<PaginatedResponse<ClientSession>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.account_id {
                query.push(("accountId", v.to_string()));
            }
            if let Some(v) = &opts.region_id {
                query.push(("regionId", v.to_string()));
            }
            if let Some(v) = &opts.region_cluster_id {
                query.push(("regionClusterId", v.to_string()));
            }
            if let Some(v) = &opts.volume_id {
                query.push(("volumeId", v.to_string()));
            }
            if let Some(v) = &opts.user_id {
                query.push(("userId", v.to_string()));
            }
            if let Some(v) = &opts.client_type {
                query.push(("clientType", v.to_string()));
            }
            if let Some(v) = &opts.status {
                query.push(("status", v.to_string()));
            }
            if let Some(v) = &opts.is_active {
                query.push(("isActive", v.to_string()));
            }
            if let Some(v) = &opts.os_name {
                query.push(("osName", v.to_string()));
            }
            if let Some(v) = &opts.platform {
                query.push(("platform", v.to_string()));
            }
            if let Some(v) = &opts.search {
                query.push(("search", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/client-sessions/list", &query).await
    }

    pub async fn get(&self, session_id: i64) -> Result<ClientSession, Error> {
        self.inner.get(&format!("/api/v1/client-sessions/{}", session_id), &[]).await
    }

    pub async fn summary(&self, account_id: Option<i64>, region_id: Option<i64>, region_cluster_id: Option<i64>, volume_id: Option<i64>, user_id: Option<i64>) -> Result<SessionSummary, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = account_id {
            query.push(("accountId", v.to_string()));
        }
        if let Some(v) = region_id {
            query.push(("regionId", v.to_string()));
        }
        if let Some(v) = region_cluster_id {
            query.push(("regionClusterId", v.to_string()));
        }
        if let Some(v) = volume_id {
            query.push(("volumeId", v.to_string()));
        }
        if let Some(v) = user_id {
            query.push(("userId", v.to_string()));
        }
        self.inner.get("/api/v1/client-sessions/summary", &query).await
    }
}

/// Operations on the `Discover` resource.
pub struct DiscoverService {
    inner: Arc<ClientInner>,
}

impl DiscoverService {
    pub async fn meta(&self, access_key_id: &str) -> Result<DiscoverMetaResponse, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        query.push(("access_key_id", access_key_id.to_string()));
        self.inner.get("/api/v1/discover/meta", &query).await
    }
}

/// Operations on the `Dashboard` resource.
pub struct DashboardService {
    inner: Arc<ClientInner>,
}

impl DashboardService {
    pub async fn stats(&self, account_id: i64) -> Result<DashboardStats, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        query.push(("accountId", account_id.to_string()));
        self.inner.get("/api/v1/dashboard/stats", &query).await
    }
}

/// Operations on the `License` resource.
pub struct LicenseService {
    inner: Arc<ClientInner>,
}

impl LicenseService {
    pub async fn get(&self) -> Result<LicenseDetails, Error> {
        self.inner.get("/api/v1/license", &[]).await
    }

    pub async fn terms(&self) -> Result<LicenseTerms, Error> {
        self.inner.get("/api/v1/license/terms", &[]).await
    }
}

/// Operations on the `Alerts` resource.
pub struct AlertsService {
    inner: Arc<ClientInner>,
}

impl AlertsService {
    pub async fn list(&self, opts: Option<&AlertListOptions>) -> Result<PaginatedResponse<ServiceAlert>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.active {
                query.push(("active", v.to_string()));
            }
            if let Some(v) = &opts.account_id {
                query.push(("accountId", v.to_string()));
            }
            if let Some(v) = &opts.region_id {
                query.push(("regionId", v.to_string()));
            }
            if let Some(v) = &opts.severity {
                query.push(("severity", v.to_string()));
            }
            if let Some(v) = &opts.category {
                query.push(("category", v.to_string()));
            }
            if let Some(v) = &opts.since {
                query.push(("since", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get("/api/v1/alerts/list", &query).await
    }

    pub async fn count(&self) -> Result<AlertCountResponse, Error> {
        self.inner.get("/api/v1/alerts/count", &[]).await
    }

    pub async fn resolve(&self, alert_id: &str) -> Result<(), Error> {
        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/alerts/{}/resolve", alert_id)).await.map(|_| ())
    }
}

/// Operations on the `RegionAlerts` resource.
pub struct RegionAlertsService {
    inner: Arc<ClientInner>,
}

impl RegionAlertsService {
    pub async fn list(&self, region_id: i64, opts: Option<&RegionAlertListOptions>) -> Result<PaginatedResponse<RegionAlert>, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(opts) = opts {
            if let Some(v) = &opts.active {
                query.push(("active", v.to_string()));
            }
            if let Some(v) = &opts.severity {
                query.push(("severity", v.to_string()));
            }
            if let Some(v) = &opts.category {
                query.push(("category", v.to_string()));
            }
            if let Some(v) = &opts.node_id {
                query.push(("nodeId", v.to_string()));
            }
            if let Some(v) = &opts.region_cluster_id {
                query.push(("regionClusterId", v.to_string()));
            }
            if let Some(v) = &opts.since {
                query.push(("since", v.to_string()));
            }
            if let Some(v) = &opts.page {
                query.push(("page", v.to_string()));
            }
            if let Some(v) = &opts.limit {
                query.push(("limit", v.to_string()));
            }
        }
        self.inner.get(&format!("/api/v1/regions/{}/alerts/list", region_id), &query).await
    }

    pub async fn count(&self, region_id: i64, region_cluster_id: Option<i64>) -> Result<AlertCountResponse, Error> {
        let mut query: Vec<(&str, String)> = Vec::new();
        if let Some(v) = region_cluster_id {
            query.push(("regionClusterId", v.to_string()));
        }
        self.inner.get(&format!("/api/v1/regions/{}/alerts/count", region_id), &query).await
    }

    pub async fn resolve(&self, region_id: i64, alert_id: &str) -> Result<(), Error> {
        self.inner.post_empty::<serde_json::Value>(&format!("/api/v1/regions/{}/alerts/{}/resolve", region_id, alert_id)).await.map(|_| ())
    }
}

/// Operations on the `Vault` resource.
pub struct VaultService {
    inner: Arc<ClientInner>,
}

impl VaultService {
    pub async fn resync(&self) -> Result<(), Error> {
        self.inner.post_empty::<serde_json::Value>("/api/v1/vault/resync").await.map(|_| ())
    }
}