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
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// This is the interface for managing the lifecycle of volumes that are consumed
/// by containers or pods, in case of Kubernetes.
///
/// This managed interface can be
/// accessed through MOID of cns-volume-manager, through vSAN service in vCenter.
///
/// Lifecycle of a container volume includes creation, update, query, attach,
/// detach and delete operations. This interface and its related classes are the entry
/// point for Cloud Native Storage (abbreviated to CNS) service.
///
/// These requests could come from different container orchestrator clusters running
/// on same vSphere as associated with this VolumeManager. VolumeManager is not
/// aware of presence and topology of container orchestrator clusters, except
/// for the weak association via *CnsContainerCluster*. This is a weak
/// association because it's client's responsibility to provide unique identity
/// for this container orchestrator cluster. VolumeManager will not impose any
/// uniqueness verification on cluster identification.
///
/// Provisioning APIs of this interface return vim.Task which is vCenter Task
/// object to track the progress of operation. In case of either partial or
/// complete success, the state of the task would be set to success. In case
/// of complete failure of the task when the individual specs couldn't be scheduled,
/// the task status would be set to error. The corresponding fault, if any, will be
/// set in the fault field. For a successfully scheduled task, result of this
/// operation will be a list of *CnsVolumeOperationResult* instances.
/// The client needs to go through the result and check the successful and failed
/// instances.
///
/// The Task returned by provisioning APIs is a vim.Task object. Client needs to
/// connect to vim endpoint on vCenter using the latest VSAN VMODL version
/// (not latest VIM version) to monitor task status. After the task is complete,
/// clients can refer to *CnsVolumeOperationResult* set as result field in
/// task's *TaskInfo* field.
///
/// Please refer to the required privileges in the individual API documentation and ignore
/// the **Required Privileges** section which is not used.
#[derive(Clone)]
pub struct CnsVolumeManager {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl CnsVolumeManager {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Attaches volumes(block volumes only) to specified VM instances, to make
/// volumes ready for mount and consumption by respective containers.
///
///
/// For each volume in input, this API will attach block backing for this volume
/// to the VirtualMachine specified in input, via one of the available slots on
/// SCSI controller. This API will transparently add new SCSI controller to the
/// VirtualMachine, if needed.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on datastores specified in input, required for
/// block volume only
/// - VirtualMachine.Config.AddExistingDisk on VM specified in the input
/// - VirtualMachine.Config.AddRemoveDevice on VM specified in the input
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeAttachDetachSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid input arguments, like
/// empty strings, invalid formats, invalid
/// combination of inputs.
/// - vmodl.fault.ManagedObjectNotFound set in case of the VM can not be
/// found.
/// - vim.fault.NotFound set in case of the volume can not be
/// found.
/// - vim.fault.ResourceInUse set when volume has been attached to a VM
/// and is in use, client needs to first detach
/// the volume from that VM and then retry this
/// operation.
/// - vim.fault.CnsMissingControllerFault set if the virtual machine has no
/// available controller when controllerKey is
/// unset, it is inherited from
/// vim.fault.CnsFault.
/// - vim.fault.CnsFault set in case of any other failure
/// scenario.
///
/// ## Parameters:
///
/// ### attach_specs
/// Specification for attach operation
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail. This fault will occur in
/// cases where the volume ID is empty, VM
/// is not present, volume type is FILE etc.
///
/// ***ManagedObjectNotFound***: if the VM can not be found.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***ResourceInUse***: if the volume has been attached a VM and is in
/// use, client needs to first detach the volume
/// from that VM and then retry this operation.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_attach_volume(&self, attach_specs: &[crate::types::structs::CnsVolumeAttachDetachSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsAttachVolumeRequestType {attach_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsAttachVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Modify the ACL configurations for existing volumes.
///
/// Multiple requests
/// configuring the same volume at the same time will be serialized in CNS.
///
/// Note that this API is currently supported for file volumes only.
///
/// Following privileges will be required on file volumes, to perform
/// this operation:
/// - Host.Config.Storage on vSAN file service enabled vSAN cluster,
/// required for file volume only
///
/// Faults that can be set in individual result entry, corresponding to each
/// *CnsVolumeACLConfigureSpec* instance in input:
/// - vmodl.fault.InvalidArgument Set if the input spec has invlid field.
/// - vim.fault.NotFound Set in case of the volume can not be found.
/// - vim.fault.CnsFault Set in case of any other failure scenarios.
///
/// ## Parameters:
///
/// ### acl_config_specs
/// Specifications for volumes ACL configuration.
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: Thrown if: 1) two or more ACLConfigSpec instances
/// are passed; 2) the volume ID is empty; 3) file
/// service reports the invalid inputs.
///
/// ***NotFound***: Thrown if the volume or cluster can not be found
/// by CNS.
///
/// ***CnsFault***: Thrown for any other authorization failure scenrios.
pub async fn cns_configure_volume_ac_ls(&self, acl_config_specs: &[crate::types::structs::CnsVolumeAclConfigureSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsConfigureVolumeAcLsRequestType {acl_config_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsConfigureVolumeACLs", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Creates container volume with given specifications.
///
///
/// Following privileges will be required on specified entities, to perform
/// this operation. For dynamic provisioning, the datastores that does not
/// have the necessary privileges will be ignored and other datastores that
/// have the necessary privileges will be considered for volume placement.
/// - Datastore.FileManagement on datastores specified in input, required for
/// block volume only
/// - Host.Config.Storage on vSAN file service enabled vSAN cluster,
/// required for file volume only
/// - StorageProfile.View on RootFolder to access storage policy specified in input
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeCreateSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid input arguments,
/// invalid formats, invalid combination of
/// inputs.
/// - vim.fault.NotFound set in case the existing disk that should
/// be used to back the container volume cannot be found.
/// - vim.fault.CnsFault set in case of any other failure scenario.
/// - vim.fault.CnsAlreadyRegisteredFault
/// set in case where the backing disk (either specified with
/// URL path for VMDK volume or disk id for FCD volume) is
/// already registered as CNS volume.
///
/// ## Parameters:
///
/// ### create_specs
/// Specifications for volumes to be created.
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: For block volume, if the input spec is invalid like
/// createSpecs size is not equal to 1, backing disk ID
/// in backing object details is empty and datastores is
/// empty, volume metadata in input spec is invalid,
/// backing disk ID in backing object details is not
/// present, datastore is invalid, entityMetadata
/// containing duplicate entity types, profile size
/// is not equal to 1 etc.
///
/// For file volume, if the input spec is invalid like
/// createSpecs size is not equal to 1, volume metadata
/// in input spec is invalid, backing disk ID in backing
/// object details is not present, entityMetadata
/// containing duplicate entity types, profile size
/// is not equal to 1 etc.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_create_volume(&self, create_specs: &[crate::types::structs::CnsVolumeCreateSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsCreateVolumeRequestType {create_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsCreateVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Create snapshots of given volumes
///
/// A volume with snapshot created on it, is considered in use
/// and cannot be deleted.
///
/// Create snapshot operation should be called by providing at least one SnapshotCreateSpec.
/// If an array of empty spec is passed, the operation will fail.
/// Return a task that tracks the status and result of snapshot
/// operation.
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on all involved Datastores
///
/// ## Parameters:
///
/// ### snapshot_specs
/// -
///
/// ## Returns:
///
/// *Task* to track the progress and result
/// of this operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail.
/// This exception will be thrown when invalid
/// format for VolumeId *CnsVolumeId.id*
/// is passed, or volume IDs are empty etc.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsSnapshotCreatedFault***: If the snapshot is created but CNS
/// failed to persist it into DB. Clean-up using
/// lower layer api is advised
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_create_snapshots(&self, snapshot_specs: &[crate::types::structs::CnsSnapshotCreateSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsCreateSnapshotsRequestType {snapshot_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsCreateSnapshots", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Deletes given container volumes.
///
///
/// Multiple requests for a volume, when deletion is already in progress, will
/// not return any fault. This operation will make the volume unavailable for
/// any attach, update and query operation.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on all involved Datastores, required for block
/// volume only
/// - Host.Config.Storage on vSAN file service enabled vSAN cluster,
/// required for file volume only
///
/// Faults that can be set in individual result entry, corresponding to each
/// volume ID instance in input:
/// - vmodl.fault.InvalidArgument set in case of empty volume ID
/// - vim.fault.NotFound set in case of the volume can not be found.
/// - vim.fault.ResourceInUse set when volume has been attached to a VM
/// and is in use, client needs to first detach
/// the volume from that VM and then retry this
/// operation.
/// - vim.fault.CnsFault set in case of any other failure scenario.
///
/// ## Parameters:
///
/// ### volume_ids
/// List of *CnsVolumeId* for the volumes to be
/// deleted.
///
/// ### delete_disk
/// Disk is the backing object for each container volume
/// specified in volumeIds list. If set to true, the backing
/// objects specified in volumeIds list will be deleted. If
/// set to false, the backing objects specified in volumeIds
/// list will not be deleted but will no longer be a
/// container volume.
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail.
/// This exception will be thrown when invalid
/// format for VolumeId *CnsVolumeId.id*
/// is passed, or volume IDs are empty.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***ResourceInUse***: if the volume has been attached to a VM and is in
/// use, client needs to first detach the volume
/// from that VM and then retry this operation.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_delete_volume(&self, volume_ids: &[crate::types::structs::CnsVolumeId], delete_disk: bool) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsDeleteVolumeRequestType {volume_ids, delete_disk, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsDeleteVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Delete snapshots with given volumeIds and snapshotIds.
///
///
/// Delete snapshot operation should be called by providing at least one SnapshotDeleteSpec
/// If an array of empty spec is passed, the operation will fail.
/// Return a task that tracks the status and result of delete operation
/// per given volume.
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on all involved Datastores
///
/// ## Parameters:
///
/// ### snapshot_delete_specs
/// -
///
/// ## Returns:
///
/// *Task* to track the progress and result
/// of this operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail.
/// This exception will be thrown when invalid
/// format for VolumeId *CnsVolumeId.id*
/// is passed, or volume IDs is empty etc.
///
/// ***NotFound***: if the volume or snapshot can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_delete_snapshots(&self, snapshot_delete_specs: &[crate::types::structs::CnsSnapshotDeleteSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsDeleteSnapshotsRequestType {snapshot_delete_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsDeleteSnapshots", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Detaches volumes(block volumes only) and makes those volumes unavailable
/// for consumption.
///
/// If a volume is already detached, this operation will pass,
/// without any failure for that volume.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on datastores specified in input, required for
/// block volume only
/// - VirtualMachine.Config.RemoveDisk on VM specified in the input
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeAttachDetachSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid input arguments, like
/// empty strings, invalid formats, invalid
/// combination of inputs, such as the volume is
/// not attached to any VM, or the volume is not
/// attached to the VM specfied, volume type if
/// FILE etc.
/// - vmodl.fault.ManagedObjectNotFound set in case of the VM can not be
/// found.
/// - vim.fault.NotFound set in case of the volume can not be found.
/// - vim.fault.CnsFault set in case of any other failure scenario.
///
/// ## Parameters:
///
/// ### detach_specs
/// Specification for detach operation
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail. This fault will occur
/// when the volume is not attached to any VM or
/// the volume is not attached to the VM specified
/// or the volume ID is empty etc.
///
/// ***ManagedObjectNotFound***: if the VM can not be found.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_detach_volume(&self, detach_specs: &[crate::types::structs::CnsVolumeAttachDetachSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsDetachVolumeRequestType {detach_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsDetachVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Extend the capacity for the container volumes.
///
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on datastore where the volume is placed,
/// required for block volume only
/// - Host.Config.Storage on vSAN file service enabled vSAN cluster,
/// required for file volume only
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeExtendSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid input arguments,
/// like empty strings, invalid formats,
/// invalid combination of inputs.
/// - vim.fault.NotFound set in case of the volume can not be found.
/// - vim.fault.CnsFault set in case of any other failure scenario.
///
/// ## Parameters:
///
/// ### extend_specs
/// Specifications for volumes to be extended.
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: This API supports input size of 1 only. If
/// more or less than one entries are passed as
/// input, this exception will be thrown and
/// operation will fail.
/// This API requires the new capacity of the
/// volume specified in ExtendSpec is bigger
/// than 0, this exception will be thrown and
/// operation will fail.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_extend_volume(&self, extend_specs: &[crate::types::structs::CnsVolumeExtendSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsExtendVolumeRequestType {extend_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsExtendVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Returns container volumes matching criteria set in the filter.
///
///
/// This API will not return partial result in case of invalid input, like empty
/// volume ID, volume name fields and so on. In case of valid inputs, e.g.
/// non-empty volume ID, if the output doesn't contain information for that
/// volume that would mean that CNS is not aware of the existence of that volume.
/// Note that there could be duplicate volumes or missing volumes across
/// multiple pages returned by this API when there are parallel volume
/// provisioning operations like create, delete are in progress.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Cns.Searchable on RootFolder to search over all container volumes
///
/// ***Required privileges:*** Cns.Searchable
///
/// ## Parameters:
///
/// ### filter
/// All container volumes matching the criteria set in the filter
/// will be returned. A maximum of 1000 volume ids can be provided.
/// See *CnsQueryFilter*
///
/// ### selection
/// Selection spec for the query entities to return.
/// This is an optional parameter. All volume fields would be returned
/// if the parameter is not specified. See *CnsQuerySelection*
///
/// ## Returns:
///
/// array of *CnsVolume* matching the input criteria
///
/// ## Errors:
///
/// ***InvalidArgument***: Thrown in case of invalid input arguments, like empty
/// strings, invalid formats, invalid combination of
/// inputs
///
/// ***CnsFault***: Thrown for all other failure scenarios
pub async fn cns_query_volume(&self, filter: &dyn crate::types::traits::CnsQueryFilterTrait, selection: Option<&crate::types::structs::CnsQuerySelection>) -> Result<crate::types::structs::CnsQueryResult> {
let input = CnsQueryVolumeRequestType {filter, selection, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsQueryVolume", Some(&input)).await?;
let result: crate::types::structs::CnsQueryResult = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Returns container volumes matching criteria set in the filter.
///
///
/// This API will not return partial result in case of invalid input, like empty
/// volume ID, volume name fields and so on. In case of valid inputs, e.g.
/// non-empty volume ID, if the output doesn't contain information for that
/// volume that would mean that CNS is not aware of the existence of that volume.
/// Note that there could be duplicate volumes or missing volumes across
/// multiple pages returned by this API when there are parallel volume
/// provisioning operations like create, delete are in progress.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Cns.Searchable on RootFolder to search over all container volumes
///
/// ***Required privileges:*** Cns.Searchable
///
/// ## Parameters:
///
/// ### filter
/// All container volumes matching the criteria set in the filter
/// will be returned. A maximum of 1000 volume ids can be provided.
/// See *CnsQueryFilter*
///
/// ### selection
/// Selection spec for the query entities to return.
/// This is an optional parameter. All volume fields would be returned
/// if the parameter is not specified. See *CnsQuerySelection*
///
/// ## Returns:
///
/// *Task* to track the progress and result of this operation.
/// For result type in task, see *CnsAsyncQueryResult*
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: Thrown in case of invalid input arguments, like empty
/// strings, invalid formats, invalid combination of
/// inputs
///
/// ***CnsFault***: Thrown for all other failure scenarios
pub async fn cns_query_async(&self, filter: &dyn crate::types::traits::CnsQueryFilterTrait, selection: Option<&crate::types::structs::CnsQuerySelection>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsQueryAsyncRequestType {filter, selection, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsQueryAsync", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Reconfigures the volume with the storage policy.
///
/// Currently the API is supported for only block volumes and only supports applying
/// the currently associated policy.
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on datastores specified in input, required for
/// block volume only
/// - StoragePolicy.View on policy in the spec
///
/// ## Parameters:
///
/// ### volume_policy_reconfig_specs
/// An array of spec ,
/// currently only array of size 1 is supported.
///
/// ## Returns:
///
/// *Task* vCenter Task to track the progress and overall state
/// of this operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: if:
/// - Input size is not equal to 1
/// - Volume id in input spec is empty.
/// - Policy string is empty.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_reconfig_volume_policy(&self, volume_policy_reconfig_specs: Option<&[crate::types::structs::CnsVolumePolicyReconfigSpec]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsReconfigVolumePolicyRequestType {volume_policy_reconfig_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsReconfigVolumePolicy", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Relocate container volume from the current source datastore to another
/// destination datastore.
///
/// Currently, it supports for a single block volume only.
///
/// This API comes with the following limitations:
/// - Any CNS control operations like attach, detach, update, expand, etc on a
/// volume being relocated or any other volume attached
/// to the same VM as the volume being relocated will
/// fail with CnsFault, see *CnsFault*.
/// - VMC is not fully supported for this API.
/// - Please see <a href="https://kb.vmware.com/s/article/90607">guidelines and
/// limitations of CNS relocate on vSphere</a>.
///
///
/// If an array of empty spec is passed or the size of the input spec is not
/// equal to 1, the operation will fail.
///
/// Following privileges will be required on specified entities, to perform
/// this operation.
/// - Datastore.FileManagement on both the source datastore, and the
/// destination datastore specified in input,
/// which is required for block volume only
/// - Resource.ColdMigrate on the virtual machine that volume is attached to,
/// which is required for attached block volume only.
/// - Datastore.AllocateSpace on the target datastore
/// - Resource.HotMigrate on the virtual machine that volume is attached to,
/// if the vm is powered on, which is required for
/// attached block volume only
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeRelocateSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid input arguments,
/// invalid formats.
/// - vim.fault.NotFound set in case the volume or datastore in the spec
/// can not be found.
/// - vim.fault.CnsFault set in case of any other failure scenarios.
///
/// ## Parameters:
///
/// ### relocate_specs
/// Specifications for volumes to be relocated. Block volume
/// relocation should use the child class spec, see
/// *CnsBlockVolumeRelocateSpec*.
///
/// ## Returns:
///
/// *Task* to track the progress and overall state of this
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***AlreadyExists***: Thrown in case volume is already migrated to the
/// specified destination datastore.
///
/// ***InvalidArgument***: Thrown in case of invalid input arguments, such as
/// invalid volume or datastore format, or empty volume
/// IDs
///
/// ***NotFound***: if the volume or datastore can not be found.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_relocate_volume(&self, relocate_specs: &[Box<dyn crate::types::traits::CnsVolumeRelocateSpecTrait>]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsRelocateVolumeRequestType {relocate_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsRelocateVolume", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Updates volume metadata, namely labels and container cluster information for the
/// container volumes.
///
///
/// Following privileges will be required on specified entities, to perform
/// this operation:
/// - Datastore.FileManagement on datastores specified in input, required for
/// block volume only
/// - Host.Config.Storage on vSAN file service enabled vSAN cluster, required
/// for file volume only
///
/// Faults that can be set in individual result entry, corresponding to each
/// VolumeMetadataUpdateSpec instance in input:
/// - vmodl.fault.InvalidArgument set in case of invalid but non-empty
/// volume id.
/// - vim.fault.NotFound set in case of the volume can not be found.
/// - vim.fault.CnsFault set in case of any other failure scenario.
///
/// ## Parameters:
///
/// ### update_specs
/// Specifications for volumes to be updated.
///
/// ## Returns:
///
/// *Task* vCenter Task to track the progress and overall state
/// of this operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: if:
/// - Input size is not equal to 1
/// - Volume id in input spec is empty.
/// - Volume metadata in input spec has empty
/// cluster info.
/// - Entity objects in volume metadata has empty or
/// invalid attributes.
/// - EntityMetadata in volume metadata contains
/// duplicate entity types.
///
/// ***NotFound***: if the volume can not be found.
///
/// ***CnsNotRegisteredFault***: if the volume exists in VC but not registered as CNS
/// volume.
///
/// ***CnsFault***: Thrown for all other failure scenario.
pub async fn cns_update_volume_metadata(&self, update_specs: &[crate::types::structs::CnsVolumeMetadataUpdateSpec]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CnsUpdateVolumeMetadataRequestType {update_specs, };
let bytes = self.client.invoke("vsan", "CnsVolumeManager", &self.mo_id, "CnsUpdateVolumeMetadata", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
}
struct CnsAttachVolumeRequestType<'a> {
attach_specs: &'a [crate::types::structs::CnsVolumeAttachDetachSpec],
}
impl<'a> miniserde::Serialize for CnsAttachVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsAttachVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsAttachVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsAttachVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsAttachVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsAttachVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("attachSpecs"), &self.data.attach_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsConfigureVolumeAcLsRequestType<'a> {
acl_config_specs: &'a [crate::types::structs::CnsVolumeAclConfigureSpec],
}
impl<'a> miniserde::Serialize for CnsConfigureVolumeAcLsRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsConfigureVolumeAcLsRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsConfigureVolumeAcLsRequestTypeSer<'b, 'a> {
data: &'b CnsConfigureVolumeAcLsRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsConfigureVolumeAcLsRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsConfigureVolumeACLsRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("ACLConfigSpecs"), &self.data.acl_config_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsCreateVolumeRequestType<'a> {
create_specs: &'a [crate::types::structs::CnsVolumeCreateSpec],
}
impl<'a> miniserde::Serialize for CnsCreateVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsCreateVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsCreateVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsCreateVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsCreateVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsCreateVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("createSpecs"), &self.data.create_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsCreateSnapshotsRequestType<'a> {
snapshot_specs: &'a [crate::types::structs::CnsSnapshotCreateSpec],
}
impl<'a> miniserde::Serialize for CnsCreateSnapshotsRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsCreateSnapshotsRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsCreateSnapshotsRequestTypeSer<'b, 'a> {
data: &'b CnsCreateSnapshotsRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsCreateSnapshotsRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsCreateSnapshotsRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("snapshotSpecs"), &self.data.snapshot_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsDeleteVolumeRequestType<'a> {
volume_ids: &'a [crate::types::structs::CnsVolumeId],
delete_disk: bool,
}
impl<'a> miniserde::Serialize for CnsDeleteVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsDeleteVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsDeleteVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsDeleteVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsDeleteVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsDeleteVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("volumeIds"), &self.data.volume_ids as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("deleteDisk"), &self.data.delete_disk as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsDeleteSnapshotsRequestType<'a> {
snapshot_delete_specs: &'a [crate::types::structs::CnsSnapshotDeleteSpec],
}
impl<'a> miniserde::Serialize for CnsDeleteSnapshotsRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsDeleteSnapshotsRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsDeleteSnapshotsRequestTypeSer<'b, 'a> {
data: &'b CnsDeleteSnapshotsRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsDeleteSnapshotsRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsDeleteSnapshotsRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("snapshotDeleteSpecs"), &self.data.snapshot_delete_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsDetachVolumeRequestType<'a> {
detach_specs: &'a [crate::types::structs::CnsVolumeAttachDetachSpec],
}
impl<'a> miniserde::Serialize for CnsDetachVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsDetachVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsDetachVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsDetachVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsDetachVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsDetachVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("detachSpecs"), &self.data.detach_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsExtendVolumeRequestType<'a> {
extend_specs: &'a [crate::types::structs::CnsVolumeExtendSpec],
}
impl<'a> miniserde::Serialize for CnsExtendVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsExtendVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsExtendVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsExtendVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsExtendVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsExtendVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("extendSpecs"), &self.data.extend_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsQueryVolumeRequestType<'a> {
filter: &'a dyn crate::types::traits::CnsQueryFilterTrait,
selection: Option<&'a crate::types::structs::CnsQuerySelection>,
}
impl<'a> miniserde::Serialize for CnsQueryVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsQueryVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsQueryVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsQueryVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsQueryVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsQueryVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("filter"), &self.data.filter as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.selection else { continue; };
return Some((std::borrow::Cow::Borrowed("selection"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CnsQueryAsyncRequestType<'a> {
filter: &'a dyn crate::types::traits::CnsQueryFilterTrait,
selection: Option<&'a crate::types::structs::CnsQuerySelection>,
}
impl<'a> miniserde::Serialize for CnsQueryAsyncRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsQueryAsyncRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsQueryAsyncRequestTypeSer<'b, 'a> {
data: &'b CnsQueryAsyncRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsQueryAsyncRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsQueryAsyncRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("filter"), &self.data.filter as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.selection else { continue; };
return Some((std::borrow::Cow::Borrowed("selection"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CnsReconfigVolumePolicyRequestType<'a> {
volume_policy_reconfig_specs: Option<&'a [crate::types::structs::CnsVolumePolicyReconfigSpec]>,
}
impl<'a> miniserde::Serialize for CnsReconfigVolumePolicyRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsReconfigVolumePolicyRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsReconfigVolumePolicyRequestTypeSer<'b, 'a> {
data: &'b CnsReconfigVolumePolicyRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsReconfigVolumePolicyRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsReconfigVolumePolicyRequestType")),
1 => {
let Some(ref val) = self.data.volume_policy_reconfig_specs else { continue; };
return Some((std::borrow::Cow::Borrowed("volumePolicyReconfigSpecs"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CnsRelocateVolumeRequestType<'a> {
relocate_specs: &'a [Box<dyn crate::types::traits::CnsVolumeRelocateSpecTrait>],
}
impl<'a> miniserde::Serialize for CnsRelocateVolumeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsRelocateVolumeRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsRelocateVolumeRequestTypeSer<'b, 'a> {
data: &'b CnsRelocateVolumeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsRelocateVolumeRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsRelocateVolumeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("relocateSpecs"), &self.data.relocate_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CnsUpdateVolumeMetadataRequestType<'a> {
update_specs: &'a [crate::types::structs::CnsVolumeMetadataUpdateSpec],
}
impl<'a> miniserde::Serialize for CnsUpdateVolumeMetadataRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CnsUpdateVolumeMetadataRequestTypeSer { data: self, seq: 0 }))
}
}
struct CnsUpdateVolumeMetadataRequestTypeSer<'b, 'a> {
data: &'b CnsUpdateVolumeMetadataRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CnsUpdateVolumeMetadataRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CnsUpdateVolumeMetadataRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("updateSpecs"), &self.data.update_specs as &dyn miniserde::Serialize)),
_ => return None,
}
}
}