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
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The *ClusterComputeResource* data object aggregates the compute
/// resources of associated *HostSystem* objects into a single
/// compute resource for use by virtual machines.
///
/// The cluster services
/// such as HA (High Availability), DRS (Distributed Resource Scheduling),
/// and EVC (Enhanced vMotion Compatibility), enhance the utility of this
/// single compute resource.
///
/// Use the *Folder*.*Folder.CreateClusterEx* method
/// to create an instance of this object.
#[derive(Clone)]
pub struct ClusterComputeResource {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl ClusterComputeResource {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Opt out of the HCI workflow.
///
/// This operation is only allowed on a cluster
/// that was created with the HCI workflow.
/// When the cluster is created, but still unconfigured, the
/// *workflowState*
/// is "in\_progress". The AbandonHciWorkflow method may be called at any time before
/// cluster configuration begins; it is not possible to abandon the workflow
/// during the configuration procedure.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Errors:
///
/// Failure
pub async fn abandon_hci_workflow(&self) -> Result<()> {
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "AbandonHciWorkflow", None).await
}
/// Adds a host to the cluster.
///
/// The hostname must be either an IP address, such as
/// 192.168.0.1, or a DNS resolvable name. DNS names may be fully qualified names,
/// such as host1.domain1.com, or a short name such as host1, providing host1 resolves
/// to host1.domain1.com. The system uses DNS to resolve short names to fully qualified
/// names. If the cluster supports nested resource pools and the user specifies the
/// optional ResourcePool argument, then the host's root resource pool becomes the
/// specified resource pool. The stand-alone host resource hierarchy is imported into
/// the new nested resource pool.
///
/// If the cluster does not support nested resource pools, then the stand-alone host
/// resource hierarchy is discarded and all virtual machines on the host are put
/// under the cluster's root resource pool.
///
/// In addition to the Host.Inventory.AddHostToCluster and
/// Resource.AssignVMToPool privileges, it requires System.View privilege on
/// the VM folder that the VMs of the host will be placed on.
///
/// ***Required privileges:*** Host.Inventory.AddHostToCluster
///
/// ## Parameters:
///
/// ### spec
/// Specifies the parameters needed to add a single host.
///
/// ### as_connected
/// Flag to specify whether or not the host should be connected
/// immediately after it is added. The host will not be added if
/// a connection attempt is made and fails.
///
/// ### resource_pool
/// the resource pool for the root resource pool from the host.
///
/// ***Required privileges:*** Resource.AssignVMToPool
///
/// Refers instance of *ResourcePool*.
///
/// ### license
/// Provide a licenseKey or licenseKeyType. See *LicenseManager*
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation. The *info.result* property in the
/// *Task* contains the newly added *HostSystem* upon
/// success.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidLogin***: if "asConnected" is specified but authentication with the
/// new host fails.
///
/// ***HostConnectFault***: if an error occurred when connecting to a host.
/// Typically, a more specific subclass, such as AlreadyBeingManaged,
/// is thrown.
///
/// ***AlreadyBeingManaged***: if the host is already being managed by a
/// VirtualCenter server.
///
/// ***NotEnoughLicenses***: if no licenses are available to add this host.
///
/// ***NoHost***: if the host cannot be contacted.
///
/// ***NotSupportedHost***: if the host is running a software version that does
/// not support clustering features. It may still be possible to add
/// the host as a stand-alone host.
///
/// ***TooManyHosts***: if no additional hosts can be added to the cluster.
///
/// ***AgentInstallFailed***: if there is an error installing the VirtualCenter agent
/// on the host.
///
/// ***AlreadyConnected***: if asConnected is true and the host is already
/// connected to VirtualCenter.
///
/// ***SSLVerifyFault***: if the host certificate could not be authenticated
///
/// ***DuplicateName***: if another host in the same cluster has the name.
///
/// ***NoPermission***: if there are crypto keys to be sent to the host,
/// but the user does not have Cryptographer.RegisterHost privilege
/// on the Cluster.
pub async fn add_host_task(&self, spec: &crate::types::structs::HostConnectSpec, as_connected: bool, resource_pool: Option<&crate::types::structs::ManagedObjectReference>, license: Option<&str>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = AddHostRequestType {spec, as_connected, resource_pool, license, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "AddHost_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Applies a recommendation from the drsRecommendation or the
/// recommendation list.
///
/// Each recommendation can be applied only
/// once.
///
/// resource.applyRecommendation privilege is required if the recommendation
/// is DRS migration or power management recommendations.
///
/// ## Parameters:
///
/// ### key
/// The key field of the DrsRecommendation or Recommendation.
pub async fn apply_recommendation(&self, key: &str) -> Result<()> {
let input = ApplyRecommendationRequestType {key, };
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "ApplyRecommendation", Some(&input)).await
}
/// Cancels a recommendation.
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### key
/// The key field of the Recommendation.
pub async fn cancel_recommendation(&self, key: &str) -> Result<()> {
let input = CancelRecommendationRequestType {key, };
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "CancelRecommendation", Some(&input)).await
}
/// Configures the cluster.
///
/// This API requires Host.Inventory.EditCluster privilege on the cluster
/// and the hosts; additional privileges might be required depending on the
/// inputs.
/// This operation is only allowed on a cluster that was created
/// with the HCI workflow.
/// Before calling this method, it is recommended that
/// *ClusterComputeResource.ValidateHCIConfiguration* is
/// invoked with the DvsProfile objects listed in
/// *ClusterComputeResourceHCIConfigSpec.dvsProf* along with the hosts listed in
/// *ClusterComputeResourceHostConfigurationInput* to validate that
/// the desired network settings can be applied correctly.
///
/// ## Parameters:
///
/// ### cluster_spec
/// Specification to configure the cluster,
/// see *ClusterComputeResourceHCIConfigSpec*
/// for details. The *DistributedVirtualSwitch* and
/// *DistributedVirtualPortgroup* objects contained
/// within the specification must be in the same datacenter as the
/// cluster. Specify *ClusterComputeResourceHCIConfigSpec.vSanConfigSpec* only when
/// vSan is enabled on the cluster.
///
/// ### host_inputs
/// Inputs to configure each host in the cluster,
/// see *ClusterComputeResourceHostConfigurationInput*
/// for details. Hosts in this list should be part of the cluster and
/// should be in maintenance mode for them to be configured per
/// specification. If this parameter is not specified, the API
/// operates on all the hosts in the cluster. Hosts which were not
/// configured due to not being in maintenance
/// mode will be returned in *ClusterComputeResourceClusterConfigResult.failedHosts*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to
/// monitor the operation. The *TaskInfo.result* property
/// in the *Task* contains a *ClusterComputeResourceClusterConfigResult*
/// object, which upon completion will contain a list of hosts which
/// were successfully configured and a list of hosts
/// which could not be configured.
///
/// Refers instance of *Task*.
pub async fn configure_hci_task(&self, cluster_spec: &crate::types::structs::ClusterComputeResourceHciConfigSpec, host_inputs: Option<&[crate::types::structs::ClusterComputeResourceHostConfigurationInput]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ConfigureHciRequestType {cluster_spec, host_inputs, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "ConfigureHCI_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Destroys this object, deleting its contents and removing it from its parent
/// folder (if any).
///
/// NOTE: The appropriate privilege must be held on the parent of the destroyed
/// entity as well as the entity itself.
/// This method can throw one of several exceptions. The exact set of exceptions
/// depends on the kind of entity that is being removed. See comments for
/// each entity for more information on destroy behavior.
///
/// ***Required privileges:*** Host.Inventory.DeleteCluster
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// Failure
pub async fn destroy_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "Destroy_Task", None).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Disable network boot support for this compute resource.
///
/// This configuration can be modified only when the compute resource is
/// empty i.e. there are no hosts in it.
///
/// ***Since:*** vSphere API Release 9.0.0.0
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor
/// the operation progress and result.
///
/// Refers instance of *Task*.
pub async fn disable_network_boot_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "DisableNetworkBoot_Task", None).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Enable network boot in the specified mode for this compute resource.
///
/// Supported values are enumerated in
/// *ComputeResourceNetworkBootMode_enum*. This configuration can be
/// modified only when the compute resource is empty i.e. there are no hosts
/// in it or during compute resource creation. In addition transition to some
/// network boot mode(s) may be restricted depending on the current state of
/// the compute resource.
///
/// ***Since:*** vSphere API Release 9.0.0.0
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Parameters:
///
/// ### network_boot_mode
/// -
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor
/// the operation progress and result.
///
/// Refers instance of *Task*.
pub async fn enable_network_boot_task(&self, network_boot_mode: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = EnableNetworkBootRequestType {network_boot_mode, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "EnableNetworkBoot_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// The API takes a list of hosts in the cluster as input, and
/// returns a list of hosts in "ClusterMaintenanceResult" that the
/// server can successfully evacuate given the existing
/// constraints in the cluster, such as HA, FT, Vmotion
/// compatibility, reservations, affinity rules, etc.
///
/// The client is allowed to pass all hosts in the cluster to the
/// API, even though all of them cannot enter maintenance mode at
/// the same time. The list returned from the API contains the
/// largest number of hosts that the server can evacuate
/// simultaneously. The client can then request to enter each host
/// in the returned list into maintenance mode.
/// The client can specify an integer "DemandCapacityRatioTarget"
/// option in the "option" parameter. The allowed values of the
/// option range from 40 to 200, and the default value is 100. This
/// option controls how much resource overcommitment the server
/// should make in consolidating the VMs onto fewer hosts. A value
/// of 100 means the server will keep the same amount of powered-on
/// capacity as the current VM demands. A value less than 100 means
/// undercommitted resources. A value greater than 100 means
/// overcommitted resources.
/// The hosts are recommended based on the inventory at the time of
/// the API invocation. It is not guaranteed that the actual
/// enter-maintenance tasks on the hosts will succeed, if the
/// inventory changes after the API returns, or if vmotions fail
/// due to unexpected conditions. For possible exceptions thrown
/// by the necessary relocate operations, see
/// *VirtualMachine.MigrateVM_Task*.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### host
/// The array of hosts to put into maintenance mode.
///
/// ***Required privileges:*** Host.Config.Maintenance
///
/// Refers instances of *HostSystem*.
///
/// ### option
/// An array of *OptionValue*
/// options for this query. The specified options override the
/// advanced options in *ClusterDrsConfigInfo*.
///
/// ### info
/// ***Since:*** vSphere API Release 8.0.3.0
///
/// ## Returns:
///
/// A *ClusterEnterMaintenanceResult* object,
/// which consists of an array of recommendations for hosts that
/// can be evacuated and an array of faults for hosts that cannot
/// be evacuated.
pub async fn cluster_enter_maintenance_mode(&self, host: &[crate::types::structs::ManagedObjectReference], option: Option<&[Box<dyn crate::types::traits::OptionValueTrait>]>, info: Option<&crate::types::structs::ClusterComputeResourceMaintenanceInfo>) -> Result<crate::types::structs::ClusterEnterMaintenanceResult> {
let input = ClusterEnterMaintenanceModeRequestType {host, option, info, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "ClusterEnterMaintenanceMode", Some(&input)).await?;
let result: crate::types::structs::ClusterEnterMaintenanceResult = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// A managed object that controls Enhanced vMotion Compatibility mode for
/// this cluster.
///
/// ***Required privileges:*** System.Read
///
/// ## Returns:
///
/// Refers instance of *ClusterEVCManager*.
pub async fn evc_manager(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "EvcManager", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Extend an existing HCI cluster.
///
/// This API requires Host.Inventory.EditCluster privilege on the cluster
/// and the hosts, additional privileges might be required depending on the
/// inputs.
///
/// ## Parameters:
///
/// ### host_inputs
/// Inputs to configure specified set of hosts in the
/// cluster. See
/// *ClusterComputeResourceHostConfigurationInput*
/// for details. Hosts in this list should be part of the cluster and
/// should be in maintenance mode for them to be configured per
/// specification. Hosts which were not configured due to not
/// being in maintenance mode will be returned in
/// *ClusterComputeResourceClusterConfigResult.failedHosts*. Specify
/// *ClusterComputeResourceHostConfigurationInput.hostVmkNics* only if *dvsSetting*
/// is set.
///
/// ### v_san_config_spec
/// Specification to configure vSAN on specified set of
/// hosts. See vim.vsan.ReconfigSpec for details. This parameter
/// should be specified only when vSan is enabled on the cluster.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to
/// monitor the operation. The *TaskInfo.result* property
/// in the *Task* contains a *ClusterComputeResourceClusterConfigResult*
/// object, which upon successful completion would contain the list
/// of hosts which couldn't be configured and a list of hosts which
/// were successfully configured. This API can be called only after
/// the cluster is configured using *ClusterComputeResource.ConfigureHCI_Task* and requires
/// *ClusterComputeResourceHCIConfigInfo.workflowState* to be "done".
///
/// Refers instance of *Task*.
pub async fn extend_hci_task(&self, host_inputs: Option<&[crate::types::structs::ClusterComputeResourceHostConfigurationInput]>, v_san_config_spec: Option<&dyn crate::types::traits::SddcBaseTrait>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ExtendHciRequestType {host_inputs, v_san_config_spec, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "ExtendHCI_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Finds all enabled and disabled VM-VM Affinity and Anti-Affinity rules,
/// involving the given Virtual Machine.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The vm whose rules need to be looked up.
///
/// Refers instance of *VirtualMachine*.
pub async fn find_rules_for_vm(&self, vm: &crate::types::structs::ManagedObjectReference) -> Result<Option<Vec<Box<dyn crate::types::traits::ClusterRuleInfoTrait>>>> {
let input = FindRulesForVmRequestType {vm, };
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "FindRulesForVm", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// This API can be invoked to get the current CPU, memory and storage usage
/// in the cluster.
///
/// ***Required privileges:*** System.Read
///
/// ## Returns:
///
/// An instance of ResourceUsageSummary with following information:
/// 1. cpuCapacityMHz: Sum of CPU capacity of all the available hosts in the
/// cluster in MHz.
/// 2. cpuUsedMHz: Sum of CPU consumed in all the available hosts in the cluster
/// in MHz.
/// 3. memCapacityMB: Sum of memory capacity of all the available hosts in the
/// cluster in MB.
/// 4. memUsedMB: Sum of memory consumed in all the available hosts in this
/// cluster in MB.
/// 5. storageCapacityMB: Total storage capacity of all the accessible datastores
/// in this cluster.
/// 6. storageUsedMB: Total storage consumed in all the accessible datastores in
/// this cluster.
pub async fn get_resource_usage(&self) -> Result<crate::types::structs::ClusterResourceUsageSummary> {
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "GetResourceUsage", None).await?;
let result: crate::types::structs::ClusterResourceUsageSummary = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Deprecated as of vSphere 9.0 with no replacement. In a future release
/// of vSphere, the vCLS functionality will be disabled, vCLS
/// system VMs will be deleted, and vCLS APIs will be removed.
///
/// Retrieve all the datastores that are either listed in
/// *ClusterSystemVMsConfigInfo.notAllowedDatastores* or are
/// tagged with a category from
/// *ClusterSystemVMsConfigInfo.dsTagCategoriesToExclude*.
///
/// ***Since:*** vSphere API Release 7.0.3.0
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// a list of restricted datastores.
///
/// Refers instances of *Datastore*.
pub async fn get_system_v_ms_restricted_datastores(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "GetSystemVMsRestrictedDatastores", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Moves an existing host into a cluster.
///
/// The host must be part of the same
/// datacenter, and if the host is part of a cluster, the host must be in maintenance
/// mode.
///
/// If the host is a stand-alone host, the stand-alone ComputeResource is removed
/// as part of this operation.
///
/// All virtual machines associated with the host, regardless of whether or not they
/// are running, are moved with the host into the cluster. If there are virtual
/// machines that should not be moved, then migrate those virtual machines off the
/// host before initiating this operation.
///
/// If the host is a stand-alone host, the cluster supports nested resource pools,
/// and the user specifies the optional resourcePool argument, then the stand-alone
/// host's root resource pool becomes the specified resource pool and the stand-alone
/// host resource hierarchy is imported into the new nested resource pool. If the
/// cluster does not support nested resource pools or the resourcePool argument is not
/// specified, then the stand-alone host resource hierarchy is ignored.
///
/// vSphere Lifecycle Manager baselines (previously called vSphere Update
/// Manager VUM) is
/// <a href="https://kb.vmware.com/s/article/89519">deprecated</a> in vCenter 8.0.
/// You can instead manage the lifecycle of the hosts in your environment by using vSphere
/// Lifecycle Manager images (vLCM). A host moved from image managed cluster to baseline
/// managed cluster will become baseline managed.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Parameters:
///
/// ### host
/// The list of hosts to move into the cluster.
///
/// ***Required privileges:*** Host.Inventory.MoveHost
///
/// Refers instance of *HostSystem*.
///
/// ### resource_pool
/// The resource pool to match the root resource pool of
/// stand-alone hosts. This argument has no effect if the host is part of a
/// cluster.
///
/// Refers instance of *ResourcePool*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***NotSupportedHost***: if the host is running a software version that does
/// not support clustering.
///
/// ***TooManyHosts***: if no additional hosts can be added to the cluster.
///
/// ***InvalidArgument***: if the host is not a part of the same datacenter as
/// the cluster or if the specified resource pool is not part of the cluster
/// or if the source and destination clusters are the same.
///
/// ***InvalidState***: if a host is already part of a cluster and is not in
/// maintenance mode.
pub async fn move_host_into_task(&self, host: &crate::types::structs::ManagedObjectReference, resource_pool: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = MoveHostIntoRequestType {host, resource_pool, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "MoveHostInto_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Moves an existing host into a cluster.
///
/// The host must be part of the same
/// datacenter, and if the host is part of a cluster, the host must be in maintenance
/// mode.
///
/// If the host is part of a stand-alone ComputeResource, then the stand-alone
/// ComputeResource is removed as part of this operation.
///
/// All virtual machines associated with a host, regardless of whether or not they
/// are running, are moved with the host into the cluster. If there are virtual
/// machines that should not be moved, then migrate those virtual machines off the
/// host before initiating this operation.
///
/// For stand-alone hosts, the host resource pool hierarchy is discarded in this call.
/// To preserve a host resource pools from a stand-alone host, call moveHostInt,
/// specifying an optional resource pool. This operation is transactional only with
/// respect to each individual host. Hosts in the set are moved sequentially and are
/// committed, one at a time. If a failure is detected, then the method terminates
/// with an exception. Since hosts are moved one at a time, if this operation fails
/// while in the process of moving multiple hosts, some hosts are left unmoved.
///
/// vSphere Lifecycle Manager baselines (previously called vSphere Update
/// Manager VUM) is
/// <a href="https://kb.vmware.com/s/article/89519">deprecated</a> in vCenter 8.0.
/// You can instead manage the lifecycle of the hosts in your environment by using vSphere
/// Lifecycle Manager images (vLCM). A host moved from image managed cluster to baseline
/// managed cluster will become baseline managed.
///
/// In addition to the privileges mentioned, the user must also hold
/// Host.Inventory.EditCluster on the host's source ComputeResource object.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Parameters:
///
/// ### host
/// The list of hosts to move into the cluster.
///
/// ***Required privileges:*** Host.Inventory.MoveHost
///
/// Refers instances of *HostSystem*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***NotSupportedHost***: if the host is running a software version that does
/// not support clustering features.
///
/// ***TooManyHosts***: if no additional hosts can be added to the cluster.
///
/// ***InvalidArgument***: if one of the hosts is not part of the same datacenter
/// as the cluster.
///
/// ***InvalidState***: if a host is already part of a cluster and is not in
/// maintenance mode.
///
/// ***DuplicateName***: if the host is already in the cluster
///
/// ***DisallowedOperationOnFailoverHost***: if the host is being moved
/// from a cluster and was configured as a failover host in that
/// cluster. See *ClusterFailoverHostAdmissionControlPolicy*.
pub async fn move_into_task(&self, host: &[crate::types::structs::ManagedObjectReference]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = MoveIntoRequestType {host, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "MoveInto_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// This method returns a *PlacementResult* object.
///
/// This API can be invoked to ask DRS for a set of recommendations
/// for moving a virtual machine and its virtual disks into a cluster.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### placement_spec
/// Specification for placing a virtual machine
/// and its virtual disks
///
/// ## Errors:
///
/// ***InvalidState***: if invoked on a DRS disabled cluster.
///
/// ***InvalidArgument***: in case of errors in the input "placementSpec".
/// The API can be used for either intra-vCenter migration or
/// cross-vCenter migration, with different requirements for the
/// PlacementSpec.
/// For intra-vCenter migration, the requirements for PlacementSpec are:
/// - PlacementSpec.vm is required.
/// - PlacementSpec.relocateSpec can be used to optionally specify the
/// target host, target datastore, or target resource pool for the migration.
/// - PlacementSpec.hosts can be used to optionally specify a list of
/// compatible hosts for the incoming virtual machine. If this list is empty,
/// all hosts in the cluster will be considered for placement.
/// - PlacementSpec.datastores can be used to optionally specify a list of
/// compatible datastores for the incoming virtual machine. If this list is
/// empty, all datastores connected to the hosts in the cluster will be
/// considered for placement.
/// - PlacementSpec.storagePods can be used to optionally specify a list of
/// compatible datastore clusters for the incoming virtual machine. If this
/// list is empty, all datastores connected to the hosts in the cluster will
/// be considered for placement.
/// <!-- -->
/// For cross-vCenter migration, the requirements for PlacementSpec are:
/// - PlacementSpec.configSpec is required. Within the ConfigSpec, the
/// following elements are required if PlacementSpec.relocateSpec.host is
/// empty: version, cpuAllocation, memoryAllocation, numCPUs, memoryMB;
/// additionally, the following elements of the ConfigSpec are required if
/// PlacementSpec.relocateSpec.datastore is empty: files, swapPlacement,
/// deviceChange.
/// - PlacementSpec.relocateSpec can be used to optionally specify the
/// target host, target datastore, or target resource pool for the migration.
/// - PlacementSpec.hosts is required, if PlacementSpec.relocateSpec.host is
/// empty; otherwise, the selected hosts in the PlacementResult are not
/// guaranteed to be compatible with the incoming virtual machine.
/// - PlacementSpec.datastores is required, if PlacementSpec.relocateSpec.datastore
/// is empty; otherwise, the selected datastores in the PlacementResult are
/// not guaranteed to be compatible with the incoming virtual machine.
pub async fn place_vm(&self, placement_spec: &crate::types::structs::PlacementSpec) -> Result<crate::types::structs::PlacementResult> {
let input = PlaceVmRequestType {placement_spec, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "PlaceVm", Some(&input)).await?;
let result: crate::types::structs::PlacementResult = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Deprecated as of VI API 2.5, use *Datacenter.PowerOnMultiVM_Task*.
/// *ClusterComputeResource.RecommendHostsForVm* cannot make any recommendations if DRS cannot
/// find the specified host in the cluster.
/// With *Datacenter.PowerOnMultiVM_Task*, DRS attempts to migrate virtual machines
/// and power on hosts in standby mode, given the same conditions.
///
/// Gets a recommendation for where to power on, resume, revert
/// from powered-off state to powered on state, or to migrate a
/// specific virtual machine.
///
/// If no host is found, an empty list is
/// returned.
///
/// The type of operation is implied by the state of the virtual machine. Returned
/// hosts are intended for power-on or resume if the virtual machine is powered-off or
/// suspended. However, if the virtual machine is powered-on, the request is assumed
/// to be for migrating a virtual machine into a DRS enabled cluster. In that case,
/// the ResourcePool argument should be specified and the ResourcePool and the virtual
/// machine cannot be in the same cluster.
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### vm
/// Specifies the virtual machine for which the user is requesting a
/// recommendations.
///
/// Refers instance of *VirtualMachine*.
///
/// ### pool
/// Specifies the ResourcePool into which the virtual machine is to be
/// migrated. If the virtual machine is powered-on, this argument must be
/// specified and it is relevant only when the virtual machine is
/// powered-on. This ResourcePool cannot be in the same cluster as the
/// virtual machine.
///
/// Refers instance of *ResourcePool*.
///
/// ## Returns:
///
/// An array of HostRecommendation ordered by their rating.
pub async fn recommend_hosts_for_vm(&self, vm: &crate::types::structs::ManagedObjectReference, pool: Option<&crate::types::structs::ManagedObjectReference>) -> Result<Option<Vec<crate::types::structs::ClusterHostRecommendation>>> {
let input = RecommendHostsForVmRequestType {vm, pool, };
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "RecommendHostsForVm", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Deprecated as of VI API 2.5, use *ComputeResource.ReconfigureComputeResource_Task*.
///
/// Reconfigures a cluster.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Parameters:
///
/// ### spec
/// A set of configuration changes to apply to the cluster. The
/// specification can be a complete set of changes or a partial set of
/// changes, applied incrementally.
///
/// ### modify
/// Flag to specify whether the specification ("spec") should
/// be applied incrementally. If "modify" is false and the
/// operation succeeds, then the configuration of the cluster
/// matches the specification exactly; in this case any unset
/// portions of the specification will result in unset or
/// default portions of the configuration.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
pub async fn reconfigure_cluster_task(&self, spec: &crate::types::structs::ClusterConfigSpec, modify: bool) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ReconfigureClusterRequestType {spec, modify, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "ReconfigureCluster_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Change the compute resource configuration.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Parameters:
///
/// ### spec
/// A set of configuration changes to apply to the compute resource.
/// The specification can be a complete set of changes or a partial
/// set of changes, applied incrementally. When invoking
/// reconfigureEx on a cluster, this argument may be a
/// *ClusterConfigSpecEx* object.
///
/// ### modify
/// Flag to specify whether the specification ("spec") should
/// be applied incrementally. If "modify" is false and the
/// operation succeeds, then the configuration of the cluster
/// matches the specification exactly; in this case any unset
/// portions of the specification will result in unset or
/// default portions of the configuration.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor
/// the operation.
///
/// Refers instance of *Task*.
pub async fn reconfigure_compute_resource_task(&self, spec: &dyn crate::types::traits::ComputeResourceConfigSpecTrait, modify: bool) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ReconfigureComputeResourceRequestType {spec, modify, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "ReconfigureComputeResource_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Make DRS invoke again and return a new list of recommendations.
///
/// Concurrent "refresh" requests may be combined together and trigger only
/// one DRS invocation.
///
/// The recommendations generated is stored at *ClusterComputeResource.recommendation*.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
pub async fn refresh_recommendation(&self) -> Result<()> {
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "RefreshRecommendation", None).await
}
/// Reload the entity state.
///
/// Clients only need to call this method
/// if they changed some external state that affects the service
/// without using the Web service interface to perform the change.
/// For example, hand-editing a virtual machine configuration file
/// affects the configuration of the associated virtual machine but
/// the service managing the virtual machine might not monitor the
/// file for changes. In this case, after such an edit, a client
/// would call "reload" on the associated virtual machine to ensure
/// the service and its clients have current data for the
/// virtual machine.
///
/// ***Required privileges:*** System.Read
pub async fn reload(&self) -> Result<()> {
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "Reload", None).await
}
/// Renames this managed entity.
///
/// Any % (percent) character used in this name parameter
/// must be escaped, unless it is used to start an escape
/// sequence. Clients may also escape any other characters in
/// this name parameter.
///
/// See also *ManagedEntity.name*.
///
/// ***Required privileges:*** Host.Inventory.RenameCluster
///
/// ## Parameters:
///
/// ### new_name
/// -
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***DuplicateName***: If another object in the same folder has the target name.
///
/// ***InvalidName***: If the new name is not a valid entity name.
pub async fn rename_task(&self, new_name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = RenameRequestType {new_name, };
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "Rename_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Retrieve DAS advanced runtime info for this cluster.
///
/// ***Required privileges:*** System.Read
pub async fn retrieve_das_advanced_runtime_info(&self) -> Result<Option<Box<dyn crate::types::traits::ClusterDasAdvancedRuntimeInfoTrait>>> {
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "RetrieveDasAdvancedRuntimeInfo", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Set the desired encryption mode and host key for the cluster.
///
/// The cryptoMode parameter can be used to set crypto mode policy for the
/// cluster.
///
/// The desired host key of the cluster can also be specified optionally
/// using the policy parameter.
///
/// ***Required privileges:*** Cryptographer.RegisterHost
///
/// ## Parameters:
///
/// ### crypto_mode
/// The encryption mode for the cluster.
/// See *ClusterCryptoConfigInfoCryptoMode_enum* for
/// supported values. An empty string is treated as a valid
/// input and will be interpreted as
/// *onDemand*.
///
/// ### policy
/// The encryption mode policy for the cluster. When no policy
/// is specified, host keys will be automcatically generated
/// using the current default key provider.
///
/// ***Since:*** vSphere API Release 8.0.3.0
///
/// ## Errors:
///
/// ***InvalidRequest***: if the interface is not implemented.
///
/// ***InvalidArgument***: if one of the parameters is invalid.
pub async fn set_crypto_mode(&self, crypto_mode: &str, policy: Option<&crate::types::structs::ClusterComputeResourceCryptoModePolicy>) -> Result<()> {
let input = SetCryptoModeRequestType {crypto_mode, policy, };
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "SetCryptoMode", Some(&input)).await
}
/// Assigns a value to a custom field.
///
/// The setCustomValue method requires
/// whichever updatePrivilege is defined as one of the
/// *CustomFieldDef.fieldInstancePrivileges*
/// for the CustomFieldDef whose value is being changed.
///
/// ## Parameters:
///
/// ### key
/// The name of the field whose value is to be updated.
///
/// ### value
/// Value to be assigned to the custom field.
pub async fn set_custom_value(&self, key: &str, value: &str) -> Result<()> {
let input = SetCustomValueRequestType {key, value, };
self.client.invoke_void("", "ClusterComputeResource", &self.mo_id, "setCustomValue", Some(&input)).await
}
/// Stamp all rules in the cluster with ruleUuid.
///
/// If a rule has ruleUuid field set, and it has a value, leave it untouched.
/// If rule's ruleUuid field is unset, generate a UUID and stamp the rule.
///
/// ***Required privileges:*** Host.Inventory.EditCluster
///
/// ## Returns:
///
/// Refers instance of *Task*.
pub async fn stamp_all_rules_with_uuid_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let bytes = self.client.invoke("", "ClusterComputeResource", &self.mo_id, "StampAllRulesWithUuid_Task", None).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Validate HCI configuration in pre-configure and post-configure use-cases.
/// 1. pre-configure use-case: Validates the HCI configuration to be applied on
/// the cluster. A successful validation in this case means the HCIConfigSpec
/// can be applied without errors on the cluster using
/// *ClusterComputeResource.ConfigureHCI_Task* or
/// *ClusterComputeResource.ExtendHCI_Task*
/// These are the things the API validates:
/// 1. When providing a set of physical adapters in the
/// *ClusterComputeResourceHCIConfigSpec.dvsProf* argument,
/// the API validates that all the adapters should be present on all the
/// hosts to be validated. The adapters should either be unmapped or mapped
/// to the same vSwitch across hosts. In addition to this, if the adapters
/// are connected to a *DistributedVirtualSwitch*, it should be
/// exactly the same way as specified in the
/// *ClusterComputeResourceHCIConfigSpec.dvsProf* or in the
/// *ClusterComputeResourceHCIConfigInfo.dvsSetting*.
/// 2. The API will also validate that the ESXi versions of the hosts are
/// compatible with the version of the *DistributedVirtualSwitch*
/// being created.
/// 2. post-configure case: Validate the cluster has been configured correctly
/// as per the *ClusterComputeResourceHCIConfigInfo* for the
/// cluster. In this case, the API should be invoked with both params omitted
/// as the intent is to validate all hosts in the cluster using the existing
/// *ClusterComputeResourceHCIConfigInfo*
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### hci_config_spec
/// The *ClusterComputeResourceHCIConfigSpec*
/// to be used for validating the hosts. If not specified, the
/// existing *ClusterComputeResourceHCIConfigInfo* of the
/// cluster will be used.
/// Note:- This param must be omitted for post-configure validation.
///
/// ### hosts
/// The set of hosts to be validated. If not specified, the set
/// of existing hosts in the cluster will be used.
/// Note:- This param must be omitted for post-configure validation.
///
/// Refers instances of *HostSystem*.
///
/// ## Returns:
///
/// A list of configuration errors. A non-empty list indicates
/// validation has failed.
///
/// ## Errors:
///
/// Failure
pub async fn validate_hci_configuration(&self, hci_config_spec: Option<&crate::types::structs::ClusterComputeResourceHciConfigSpec>, hosts: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<Option<Vec<Box<dyn crate::types::traits::ClusterComputeResourceValidationResultBaseTrait>>>> {
let input = ValidateHciConfigurationRequestType {hci_config_spec, hosts, };
let bytes_opt = self.client.invoke_optional("", "ClusterComputeResource", &self.mo_id, "ValidateHCIConfiguration", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// The set of actions that have been performed recently.
pub async fn action_history(&self) -> Result<Option<Vec<crate::types::structs::ClusterActionHistory>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "actionHistory").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Whether alarm actions are enabled for this entity.
///
/// True if enabled; false otherwise.
///
/// ***Required privileges:*** System.Read
pub async fn alarm_actions_enabled(&self) -> Result<Option<bool>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "alarmActionsEnabled").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of custom field definitions that are valid for the object's type.
///
/// The fields are sorted by *CustomFieldDef.name*.
///
/// ***Required privileges:*** System.View
pub async fn available_field(&self) -> Result<Option<Vec<crate::types::structs::CustomFieldDef>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "availableField").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Current configuration issues that have been detected for this entity.
///
/// Typically,
/// these issues have already been logged as events. The entity stores these
/// events as long as they are still current. The
/// *configStatus* property provides an overall status
/// based on these events.
pub async fn config_issue(&self) -> Result<Option<Vec<crate::types::structs::Event>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "configIssue").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Flag indicating whether or not desired configuration
/// management platform is enabled on the compute resource.
///
/// This property can be set only at the time of creation or through the
/// *ComputeResource.EnableConfigurationManagement* method.
///
/// ***Since:*** vSphere API Release 8.0.0.0
///
/// ***Required privileges:*** System.View
pub async fn config_manager_enabled(&self) -> Result<Option<bool>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "configManagerEnabled").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The configStatus indicates whether or not the system has detected a configuration
/// issue involving this entity.
///
/// For example, it might have detected a
/// duplicate IP address or MAC address, or a host in a cluster
/// might be out of compliance. The meanings of the configStatus values are:
/// - red: A problem has been detected involving the entity.
/// - yellow: A problem is about to occur or a transient condition
/// has occurred (For example, reconfigure fail-over policy).
/// - green: No configuration issues have been detected.
/// - gray: The configuration status of the entity is not being monitored.
///
/// A green status indicates only that a problem has not been detected;
/// it is not a guarantee that the entity is problem-free.
///
/// The *configIssue* property contains a list of the
/// problems that have been detected.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn config_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "configStatus").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property configStatus was empty".to_string()))?;
let result: crate::types::enums::ManagedEntityStatusEnum = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Deprecated as of VI API 2.5, use *ComputeResource.configurationEx*,
/// which is a *ClusterConfigInfoEx* data object..
///
/// Configuration of the cluster.
pub async fn configuration(&self) -> Result<crate::types::structs::ClusterConfigInfo> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "configuration").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property configuration was empty".to_string()))?;
let result: crate::types::structs::ClusterConfigInfo = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Configuration of the compute resource; applies to both standalone hosts
/// and clusters.
///
/// For a cluster this property will return a
/// *ClusterConfigInfoEx* object.
pub async fn configuration_ex(&self) -> Result<Box<dyn crate::types::traits::ComputeResourceConfigInfoTrait>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "configurationEx").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property configurationEx was empty".to_string()))?;
let result: Box<dyn crate::types::traits::ComputeResourceConfigInfoTrait> = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Custom field values.
///
/// ***Required privileges:*** System.View
pub async fn custom_value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "customValue").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The datastore property is the subset of datastore objects in the datacenter
/// available in this ComputeResource.
///
/// This property is computed as the aggregate set of datastores available from all
/// the hosts that are part of this compute resource.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instances of *Datastore*.
pub async fn datastore(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "datastore").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A set of alarm states for alarms that apply to this managed entity.
///
/// The set includes alarms defined on this entity
/// and alarms inherited from the parent entity,
/// or from any ancestors in the inventory hierarchy.
///
/// Alarms are inherited if they can be triggered by this entity or its descendants.
/// This set does not include alarms that are defined on descendants of this entity.
///
/// ***Required privileges:*** System.View
pub async fn declared_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "declaredAlarmState").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of operations that are disabled, given the current runtime
/// state of the entity.
///
/// For example, a power-on operation always fails if a
/// virtual machine is already powered on. This list can be used by clients to
/// enable or disable operations in a graphical user interface.
///
/// Note: This list is determined by the current runtime state of an entity,
/// not by its permissions.
///
/// This list may include the following operations for a HostSystem:
/// - *HostSystem.EnterMaintenanceMode_Task*
/// - *HostSystem.ExitMaintenanceMode_Task*
/// - *HostSystem.RebootHost_Task*
/// - *HostSystem.ShutdownHost_Task*
/// - *HostSystem.ReconnectHost_Task*
/// - *HostSystem.DisconnectHost_Task*
///
/// This list may include the following operations for a VirtualMachine:
/// - *VirtualMachine.AnswerVM*
/// - *ManagedEntity.Rename_Task*
/// - *VirtualMachine.CloneVM_Task*
/// - *VirtualMachine.PowerOffVM_Task*
/// - *VirtualMachine.PowerOnVM_Task*
/// - *VirtualMachine.SuspendVM_Task*
/// - *VirtualMachine.ResetVM_Task*
/// - *VirtualMachine.ReconfigVM_Task*
/// - *VirtualMachine.RelocateVM_Task*
/// - *VirtualMachine.MigrateVM_Task*
/// - *VirtualMachine.CustomizeVM_Task*
/// - *VirtualMachine.ShutdownGuest*
/// - *VirtualMachine.StandbyGuest*
/// - *VirtualMachine.RebootGuest*
/// - *VirtualMachine.CreateSnapshot_Task*
/// - *VirtualMachine.RemoveAllSnapshots_Task*
/// - *VirtualMachine.RevertToCurrentSnapshot_Task*
/// - *VirtualMachine.MarkAsTemplate*
/// - *VirtualMachine.MarkAsVirtualMachine*
/// - *VirtualMachine.ResetGuestInformation*
/// - *VirtualMachine.MountToolsInstaller*
/// - *VirtualMachine.UnmountToolsInstaller*
/// - *ManagedEntity.Destroy_Task*
/// - *VirtualMachine.UpgradeVM_Task*
/// - *VirtualMachine.ExportVm*
///
/// This list may include the following operations for a ResourcePool:
/// - *ResourcePool.ImportVApp*
/// - *ResourcePool.CreateChildVM_Task*
/// - *ResourcePool.UpdateConfig*
/// - *Folder.CreateVM_Task*
/// - *ManagedEntity.Destroy_Task*
/// - *ManagedEntity.Rename_Task*
///
/// This list may include the following operations for a VirtualApp:
/// - *ManagedEntity.Destroy_Task*
/// - *VirtualApp.CloneVApp_Task*
/// - *VirtualApp.unregisterVApp_Task*
/// - *VirtualApp.ExportVApp*
/// - *VirtualApp.PowerOnVApp_Task*
/// - *VirtualApp.PowerOffVApp_Task*
/// - *VirtualApp.UpdateVAppConfig*
///
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn disabled_method(&self) -> Result<Option<Vec<String>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "disabledMethod").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A collection of the DRS faults generated in the last DRS invocation.
///
/// Each element of the collection is the set of faults generated in one
/// recommendation.
/// DRS faults are generated when DRS tries to make recommendations
/// for rule enforcement, power management, etc., and indexed in a tree
/// structure with reason for recommendations and VM to migrate (optional)
/// as the index keys.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
///
/// ***Required privileges:*** System.Read
pub async fn drs_fault(&self) -> Result<Option<Vec<crate::types::structs::ClusterDrsFaults>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "drsFault").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Deprecated as of VI API 2.5, use
/// *ClusterComputeResource.recommendation*.
/// vSphere 6.5 is the last version where this property is populated.
/// Later versions of vSphere no longer populate this property.
///
/// If DRS is enabled, this returns the set of recommended
/// migrations from the DRS module.
pub async fn drs_recommendation(&self) -> Result<Option<Vec<crate::types::structs::ClusterDrsRecommendation>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "drsRecommendation").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Access rights the current session has to this entity.
///
/// ***Required privileges:*** System.View
pub async fn effective_role(&self) -> Result<Option<Vec<i32>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "effectiveRole").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The environment browser object that identifies the environments that are supported
/// on this compute resource.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *EnvironmentBrowser*.
pub async fn environment_browser(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "environmentBrowser").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// This is applicable to clusters which are configured using the HCI
/// workflow and contains data related to the workflow and specification.
pub async fn hci_config(&self) -> Result<Option<crate::types::structs::ClusterComputeResourceHciConfigInfo>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "hciConfig").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of hosts that are part of this compute resource.
///
/// If the compute resource is a
/// standalone type, then this list contains just one element.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instances of *HostSystem*.
pub async fn host(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "host").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Flag indicating whether or not the lifecycle of the compute resource is
/// managed.
///
/// Once it is enabled, it cannot be disabled.
/// This property can be set only at the time of creation or through the
/// *ComputeResource.EnableLifecycleManagement* method.
///
/// ***Required privileges:*** System.View
pub async fn lifecycle_managed(&self) -> Result<Option<bool>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "lifecycleManaged").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The set of migration decisions that have recently been performed.
///
/// This list is populated only when DRS is in automatic mode.
pub async fn migration_history(&self) -> Result<Option<Vec<crate::types::structs::ClusterDrsMigration>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "migrationHistory").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Name of this entity, unique relative to its parent.
///
/// Any / (slash), \\ (backslash), character used in this
/// name element will be escaped. Similarly, any % (percent) character used in
/// this name element will be escaped, unless it is used to start an escape
/// sequence. A slash is escaped as %2F or %2f. A backslash is escaped as %5C or
/// %5c, and a percent is escaped as %25.
///
/// ***Required privileges:*** System.View
pub async fn name(&self) -> Result<String> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "name").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property name was empty".to_string()))?;
let result: String = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// The subset of network objects available in the datacenter that is available in
/// this ComputeResource.
///
/// This property is computed as the aggregate set of networks available from all the
/// hosts that are part of this compute resource.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instances of *Network*.
pub async fn network(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "network").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Managed property indicating whether and what kind of netwoork boot mode
/// is configured for this compute resource.
///
/// Supported values are enumerated
/// in *ComputeResourceNetworkBootMode_enum*.
/// This property can be configured via the
/// *ComputeResource.EnableNetworkBoot_Task* method or during compute
/// resource creation through the
/// *ComputeResource.networkBootMode* property.
///
/// ***Since:*** vSphere API Release 9.0.0.0
///
/// ***Required privileges:*** System.View
pub async fn network_boot_mode(&self) -> Result<Option<String>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "networkBootMode").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// General health of this managed entity.
///
/// The overall status of the managed entity is computed as the worst status
/// among its alarms and the configuration issues detected on the entity.
/// The status is reported as one of the following values:
/// - red: The entity has alarms or configuration issues with a red status.
/// - yellow: The entity does not have alarms or configuration issues with a
/// red status, and has at least one with a yellow status.
/// - green: The entity does not have alarms or configuration issues with a
/// red or yellow status, and has at least one with a green status.
/// - gray: All of the entity's alarms have a gray status and the
/// configuration status of the entity is not being monitored.
///
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn overall_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "overallStatus").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property overallStatus was empty".to_string()))?;
let result: crate::types::enums::ManagedEntityStatusEnum = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Parent of this entity.
///
/// This value is null for the root object and for
/// *VirtualMachine* objects that are part of
/// a *VirtualApp*.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *ManagedEntity*.
pub async fn parent(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "parent").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of permissions defined for this entity.
pub async fn permission(&self) -> Result<Option<Vec<crate::types::structs::Permission>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "permission").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The set of recent tasks operating on this managed entity.
///
/// This is a subset
/// of *TaskManager.recentTask* belong to this entity. A task in this
/// list could be in one of the four states: pending, running, success or error.
///
/// This property can be used to deduce intermediate power states for
/// a virtual machine entity. For example, if the current powerState is "poweredOn"
/// and there is a running task performing the "suspend" operation, then the virtual
/// machine's intermediate state might be described as "suspending."
///
/// Most tasks (such as power operations) obtain exclusive access to the virtual
/// machine, so it is unusual for this list to contain more than one running task.
/// One exception, however, is the task of cloning a virtual machine.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
///
/// ## Returns:
///
/// Refers instances of *Task*.
pub async fn recent_task(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "recentTask").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of recommended actions for the cluster.
///
/// It is
/// possible that the current set of recommendations may be empty,
/// either due to not having any running dynamic recommendation
/// generation module, or since there may be no recommended actions
/// at this time.
///
/// ***Required privileges:*** System.Read
///
/// ## Returns:
///
/// An array of recommendations, with each of them having
/// one or more actions.
pub async fn recommendation(&self) -> Result<Option<Vec<crate::types::structs::ClusterRecommendation>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "recommendation").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Reference to root resource pool.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *ResourcePool*.
pub async fn resource_pool(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "resourcePool").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Basic runtime information about a compute resource.
///
/// This information is used on
/// summary screens and in list views.
pub async fn summary(&self) -> Result<Box<dyn crate::types::traits::ComputeResourceSummaryTrait>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "summary").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property summary was empty".to_string()))?;
let result: Box<dyn crate::types::traits::ComputeResourceSummaryTrait> = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Deprecated do not use this property.
/// The same information could be obtained via
/// *ComputeResource.summary*.
///
/// The cluster summary.
///
/// ***Since:*** vSphere API Release 7.0.1.1
pub async fn summary_ex(&self) -> Result<crate::types::structs::ClusterComputeResourceSummary> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "summaryEx").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property summaryEx was empty".to_string()))?;
let result: crate::types::structs::ClusterComputeResourceSummary = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// The set of tags associated with this managed entity.
///
/// Experimental. Subject to change.
///
/// ***Required privileges:*** System.View
pub async fn tag(&self) -> Result<Option<Vec<crate::types::structs::Tag>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "tag").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A set of alarm states for alarms triggered by this entity
/// or by its descendants.
///
/// Triggered alarms are propagated up the inventory hierarchy
/// so that a user can readily tell when a descendant has triggered an alarm.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
///
/// ***Required privileges:*** System.View
pub async fn triggered_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "triggeredAlarmState").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of custom field values.
///
/// Each value uses a key to associate
/// an instance of a *CustomFieldStringValue* with
/// a custom field definition.
///
/// ***Required privileges:*** System.View
pub async fn value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
let pv_opt = self.client.fetch_property_raw("", "ClusterComputeResource", &self.mo_id, "value").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
}
struct AddHostRequestType<'a> {
spec: &'a crate::types::structs::HostConnectSpec,
as_connected: bool,
resource_pool: Option<&'a crate::types::structs::ManagedObjectReference>,
license: Option<&'a str>,
}
impl<'a> miniserde::Serialize for AddHostRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(AddHostRequestTypeSer { data: self, seq: 0 }))
}
}
struct AddHostRequestTypeSer<'b, 'a> {
data: &'b AddHostRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for AddHostRequestTypeSer<'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"), &"AddHostRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("asConnected"), &self.data.as_connected as &dyn miniserde::Serialize)),
3 => {
let Some(ref val) = self.data.resource_pool else { continue; };
return Some((std::borrow::Cow::Borrowed("resourcePool"), val as &dyn miniserde::Serialize));
}
4 => {
let Some(ref val) = self.data.license else { continue; };
return Some((std::borrow::Cow::Borrowed("license"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct ApplyRecommendationRequestType<'a> {
key: &'a str,
}
impl<'a> miniserde::Serialize for ApplyRecommendationRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ApplyRecommendationRequestTypeSer { data: self, seq: 0 }))
}
}
struct ApplyRecommendationRequestTypeSer<'b, 'a> {
data: &'b ApplyRecommendationRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ApplyRecommendationRequestTypeSer<'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"), &"ApplyRecommendationRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("key"), &self.data.key as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CancelRecommendationRequestType<'a> {
key: &'a str,
}
impl<'a> miniserde::Serialize for CancelRecommendationRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CancelRecommendationRequestTypeSer { data: self, seq: 0 }))
}
}
struct CancelRecommendationRequestTypeSer<'b, 'a> {
data: &'b CancelRecommendationRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CancelRecommendationRequestTypeSer<'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"), &"CancelRecommendationRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("key"), &self.data.key as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ConfigureHciRequestType<'a> {
cluster_spec: &'a crate::types::structs::ClusterComputeResourceHciConfigSpec,
host_inputs: Option<&'a [crate::types::structs::ClusterComputeResourceHostConfigurationInput]>,
}
impl<'a> miniserde::Serialize for ConfigureHciRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ConfigureHciRequestTypeSer { data: self, seq: 0 }))
}
}
struct ConfigureHciRequestTypeSer<'b, 'a> {
data: &'b ConfigureHciRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ConfigureHciRequestTypeSer<'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"), &"ConfigureHCIRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("clusterSpec"), &self.data.cluster_spec as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.host_inputs else { continue; };
return Some((std::borrow::Cow::Borrowed("hostInputs"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct EnableNetworkBootRequestType<'a> {
network_boot_mode: &'a str,
}
impl<'a> miniserde::Serialize for EnableNetworkBootRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(EnableNetworkBootRequestTypeSer { data: self, seq: 0 }))
}
}
struct EnableNetworkBootRequestTypeSer<'b, 'a> {
data: &'b EnableNetworkBootRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for EnableNetworkBootRequestTypeSer<'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"), &"EnableNetworkBootRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("networkBootMode"), &self.data.network_boot_mode as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ClusterEnterMaintenanceModeRequestType<'a> {
host: &'a [crate::types::structs::ManagedObjectReference],
option: Option<&'a [Box<dyn crate::types::traits::OptionValueTrait>]>,
info: Option<&'a crate::types::structs::ClusterComputeResourceMaintenanceInfo>,
}
impl<'a> miniserde::Serialize for ClusterEnterMaintenanceModeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ClusterEnterMaintenanceModeRequestTypeSer { data: self, seq: 0 }))
}
}
struct ClusterEnterMaintenanceModeRequestTypeSer<'b, 'a> {
data: &'b ClusterEnterMaintenanceModeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ClusterEnterMaintenanceModeRequestTypeSer<'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"), &"ClusterEnterMaintenanceModeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("host"), &self.data.host as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.option else { continue; };
return Some((std::borrow::Cow::Borrowed("option"), val as &dyn miniserde::Serialize));
}
3 => {
let Some(ref val) = self.data.info else { continue; };
return Some((std::borrow::Cow::Borrowed("info"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct ExtendHciRequestType<'a> {
host_inputs: Option<&'a [crate::types::structs::ClusterComputeResourceHostConfigurationInput]>,
v_san_config_spec: Option<&'a dyn crate::types::traits::SddcBaseTrait>,
}
impl<'a> miniserde::Serialize for ExtendHciRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ExtendHciRequestTypeSer { data: self, seq: 0 }))
}
}
struct ExtendHciRequestTypeSer<'b, 'a> {
data: &'b ExtendHciRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ExtendHciRequestTypeSer<'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"), &"ExtendHCIRequestType")),
1 => {
let Some(ref val) = self.data.host_inputs else { continue; };
return Some((std::borrow::Cow::Borrowed("hostInputs"), val as &dyn miniserde::Serialize));
}
2 => {
let Some(ref val) = self.data.v_san_config_spec else { continue; };
return Some((std::borrow::Cow::Borrowed("vSanConfigSpec"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct FindRulesForVmRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
}
impl<'a> miniserde::Serialize for FindRulesForVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(FindRulesForVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct FindRulesForVmRequestTypeSer<'b, 'a> {
data: &'b FindRulesForVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for FindRulesForVmRequestTypeSer<'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"), &"FindRulesForVmRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct MoveHostIntoRequestType<'a> {
host: &'a crate::types::structs::ManagedObjectReference,
resource_pool: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for MoveHostIntoRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(MoveHostIntoRequestTypeSer { data: self, seq: 0 }))
}
}
struct MoveHostIntoRequestTypeSer<'b, 'a> {
data: &'b MoveHostIntoRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for MoveHostIntoRequestTypeSer<'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"), &"MoveHostIntoRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("host"), &self.data.host as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.resource_pool else { continue; };
return Some((std::borrow::Cow::Borrowed("resourcePool"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct MoveIntoRequestType<'a> {
host: &'a [crate::types::structs::ManagedObjectReference],
}
impl<'a> miniserde::Serialize for MoveIntoRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(MoveIntoRequestTypeSer { data: self, seq: 0 }))
}
}
struct MoveIntoRequestTypeSer<'b, 'a> {
data: &'b MoveIntoRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for MoveIntoRequestTypeSer<'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"), &"MoveIntoRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("host"), &self.data.host as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct PlaceVmRequestType<'a> {
placement_spec: &'a crate::types::structs::PlacementSpec,
}
impl<'a> miniserde::Serialize for PlaceVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PlaceVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct PlaceVmRequestTypeSer<'b, 'a> {
data: &'b PlaceVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PlaceVmRequestTypeSer<'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"), &"PlaceVmRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("placementSpec"), &self.data.placement_spec as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RecommendHostsForVmRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
pool: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for RecommendHostsForVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RecommendHostsForVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct RecommendHostsForVmRequestTypeSer<'b, 'a> {
data: &'b RecommendHostsForVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RecommendHostsForVmRequestTypeSer<'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"), &"RecommendHostsForVmRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.pool else { continue; };
return Some((std::borrow::Cow::Borrowed("pool"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct ReconfigureClusterRequestType<'a> {
spec: &'a crate::types::structs::ClusterConfigSpec,
modify: bool,
}
impl<'a> miniserde::Serialize for ReconfigureClusterRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ReconfigureClusterRequestTypeSer { data: self, seq: 0 }))
}
}
struct ReconfigureClusterRequestTypeSer<'b, 'a> {
data: &'b ReconfigureClusterRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ReconfigureClusterRequestTypeSer<'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"), &"ReconfigureClusterRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("modify"), &self.data.modify as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ReconfigureComputeResourceRequestType<'a> {
spec: &'a dyn crate::types::traits::ComputeResourceConfigSpecTrait,
modify: bool,
}
impl<'a> miniserde::Serialize for ReconfigureComputeResourceRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ReconfigureComputeResourceRequestTypeSer { data: self, seq: 0 }))
}
}
struct ReconfigureComputeResourceRequestTypeSer<'b, 'a> {
data: &'b ReconfigureComputeResourceRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ReconfigureComputeResourceRequestTypeSer<'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"), &"ReconfigureComputeResourceRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("modify"), &self.data.modify as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RenameRequestType<'a> {
new_name: &'a str,
}
impl<'a> miniserde::Serialize for RenameRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RenameRequestTypeSer { data: self, seq: 0 }))
}
}
struct RenameRequestTypeSer<'b, 'a> {
data: &'b RenameRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RenameRequestTypeSer<'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"), &"RenameRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("newName"), &self.data.new_name as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct SetCryptoModeRequestType<'a> {
crypto_mode: &'a str,
policy: Option<&'a crate::types::structs::ClusterComputeResourceCryptoModePolicy>,
}
impl<'a> miniserde::Serialize for SetCryptoModeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(SetCryptoModeRequestTypeSer { data: self, seq: 0 }))
}
}
struct SetCryptoModeRequestTypeSer<'b, 'a> {
data: &'b SetCryptoModeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for SetCryptoModeRequestTypeSer<'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"), &"SetCryptoModeRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("cryptoMode"), &self.data.crypto_mode as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.policy else { continue; };
return Some((std::borrow::Cow::Borrowed("policy"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct SetCustomValueRequestType<'a> {
key: &'a str,
value: &'a str,
}
impl<'a> miniserde::Serialize for SetCustomValueRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(SetCustomValueRequestTypeSer { data: self, seq: 0 }))
}
}
struct SetCustomValueRequestTypeSer<'b, 'a> {
data: &'b SetCustomValueRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for SetCustomValueRequestTypeSer<'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"), &"setCustomValueRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("key"), &self.data.key as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("value"), &self.data.value as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ValidateHciConfigurationRequestType<'a> {
hci_config_spec: Option<&'a crate::types::structs::ClusterComputeResourceHciConfigSpec>,
hosts: Option<&'a [crate::types::structs::ManagedObjectReference]>,
}
impl<'a> miniserde::Serialize for ValidateHciConfigurationRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ValidateHciConfigurationRequestTypeSer { data: self, seq: 0 }))
}
}
struct ValidateHciConfigurationRequestTypeSer<'b, 'a> {
data: &'b ValidateHciConfigurationRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ValidateHciConfigurationRequestTypeSer<'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"), &"ValidateHCIConfigurationRequestType")),
1 => {
let Some(ref val) = self.data.hci_config_spec else { continue; };
return Some((std::borrow::Cow::Borrowed("hciConfigSpec"), val as &dyn miniserde::Serialize));
}
2 => {
let Some(ref val) = self.data.hosts else { continue; };
return Some((std::borrow::Cow::Borrowed("hosts"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}