vim_rs/mo/folder.rs
1use std::sync::Arc;
2use crate::core::client::{Client, Result};
3/// The *Folder* managed object is a container for storing and organizing
4/// inventory objects.
5///
6/// Folders can contain folders and other objects.
7/// The *Folder.childType* property identifies a folder's type
8/// and determines the types of folders and objects the folder can contain.
9/// - A folder can contain a child folder of the same type as the parent folder.
10/// - All *Datacenter* objects contain dedicated folders for:
11/// - *VirtualMachine*, templates, and *VirtualApp* objects.
12/// - *ComputeResource* hierarchies.
13/// - *Network*, *DistributedVirtualSwitch*, and
14/// *DistributedVirtualPortgroup* objects.
15/// - *Datastore* objects.
16/// - A folder can contain child objects of type *Folder.childType*.
17/// Virtual machine and network entity folders can also contain additional object types.
18/// - The root folder is a data center folder.
19///
20/// See *ServiceInstance* for a representation of the organization of the inventory.
21///
22/// The *Folder* managed object also acts as a factory object, meaning it
23/// creates new entities in a folder. The object provides methods to create
24/// child folders and objects, methods to add existing objects to folders, and
25/// methods to remove objects from folders and to delete folders.
26///
27/// *Folder* inherits the *ManagedEntity.Destroy_Task* method.
28/// *ManagedEntity.Destroy_Task* is a recursive operation that removes all child objects and
29/// folders. When you call *ManagedEntity.Destroy_Task* to destroy a folder, the system uses
30/// the specified folder as a root and traverses its descendant hierarchy, calling
31/// *ManagedEntity.Destroy_Task* on each object.
32/// *ManagedEntity.Destroy_Task* is a single operation that treats each recursive call as a
33/// single transaction, committing each call to remove an object individually.
34/// If *ManagedEntity.Destroy_Task* fails on an object, the method terminates at that point
35/// with an exception, leaving some or all of the objects still in the inventory.
36///
37/// Notes on the folder destroy method:
38/// - Calling *ManagedEntity.Destroy_Task* on a virtual machine folder recursively calls
39/// *ManagedEntity.Destroy_Task* on all the child virtual machines and vApps, which are then
40/// removed from disk.
41/// Use *Folder.UnregisterAndDestroy_Task*
42/// to unregister virtual machines or vApps recursively without
43/// removing them from the disk.
44/// - For virtual machine folders, the *ManagedEntity.Destroy_Task* method requires the
45/// VirtualMachine.Delete privilege on the folder as well as
46/// all virtual machines to be destroyed. It also requires the VirtualApp.Delete
47/// privilege on all VirtualApp objects to be destroyed.
48/// - Destroying a host folder or datacenter folder unregisters all child hosts
49/// and virtual machines from vCenter. The hosts are simply removed
50/// from the inventory, along with their virtual machines. The virtual machines
51/// are not removed from disk nor are their runtime states changed.
52/// - You can remove network and datastore folders only if they are empty.
53/// - You cannot destroy, rename, or move the virtual machine, compute resource,
54/// network entity, and datastore child folders of a Datacenter.
55#[derive(Clone)]
56pub struct Folder {
57 client: Arc<Client>,
58 mo_id: String,
59}
60impl Folder {
61 pub fn new(client: Arc<Client>, mo_id: &str) -> Self {
62 Self {
63 client,
64 mo_id: mo_id.to_string(),
65 }
66 }
67 /// Creates a new single-host compute resource.
68 ///
69 /// The name provided can be an
70 /// IP address, such as 192.168.0.120, or a string, such as esx120.
71 /// If a name is specified, a DNS lookup is used to resolve it to a fully-qualified
72 /// name, such as esx120.vmware.com. If the DNS lookup fails, the string is
73 /// stored as specified.
74 ///
75 /// Licenses for the host are allocated when making the first connection to
76 /// the host. This is because the license needed typically depends on the type
77 /// of host and the number of CPUs.
78 ///
79 /// In addition to the Host.Inventory.AddStandaloneHost privilege, it
80 /// requires System.View privilege on the VM folder that the VMs of the
81 /// host will be placed on.
82 ///
83 /// ***Required privileges:*** Host.Inventory.AddStandaloneHost
84 ///
85 /// ## Parameters:
86 ///
87 /// ### spec
88 /// Specifies the parameters needed to add a single host.
89 ///
90 /// ### comp_res_spec
91 /// Optionally specify the configuration for the compute
92 /// resource that will be created to contain the host.
93 ///
94 /// ### add_connected
95 /// Flag to specify whether or not the host should be
96 /// connected as soon as it is added. The host will not
97 /// be added if a connection attempt is made and fails.
98 ///
99 /// ### license
100 /// Provide a licenseKey or licenseKeyType. See *LicenseManager*
101 ///
102 /// ## Returns:
103 ///
104 /// This method returns a *Task* object with which to monitor the
105 /// operation. The *info.result* property in the
106 /// *Task* contains the newly added *ComputeResource* upon
107 /// success.
108 ///
109 /// Refers instance of *Task*.
110 ///
111 /// ## Errors:
112 ///
113 /// ***InvalidLogin***: if authentication with the host fails.
114 ///
115 /// ***InvalidArgument***: if an argument is specified incorrectly.
116 ///
117 /// ***AlreadyBeingManaged***: if the host is already being managed by a
118 /// vCenter server. If the host is being managed by a different
119 /// vCenter server, this can be overridden by the "force" flag in the
120 /// connection specification.
121 ///
122 /// ***NotEnoughLicenses***: if there are not enough licenses to add the host.
123 ///
124 /// ***NoHost***: if the host cannot be contacted.
125 ///
126 /// ***NotSupported***: if the host is being added to a folder whose
127 /// *Folder.childType* property does not contain
128 /// "ComputeResource".
129 ///
130 /// ***NotSupportedHost***: if the host is running a software version that is not
131 /// supported.
132 ///
133 /// ***AgentInstallFailed***: if there is an error installing the vCenter
134 /// agent on the new host.
135 ///
136 /// ***AlreadyConnected***: if addConnected is true and the host is already
137 /// connected to vCenter.
138 ///
139 /// ***HostConnectFault***: if an error occurred when attempting to connect
140 /// to a host. Typically, a more specific subclass, such as
141 /// AlreadyBeingManaged, is thrown.
142 ///
143 /// ***SSLVerifyFault***: if the host certificate could not be authenticated
144 ///
145 /// ***DuplicateName***: if another host in the same folder has the name.
146 ///
147 /// ***NoPermission***: if there are crypto keys to be sent to the host,
148 /// but the user does not have Cryptographer.RegisterHost privilege
149 /// on the Folder.
150 pub async fn add_standalone_host_task(&self, spec: &crate::types::structs::HostConnectSpec, comp_res_spec: Option<&dyn crate::types::traits::ComputeResourceConfigSpecTrait>, add_connected: bool, license: Option<&str>) -> Result<crate::types::structs::ManagedObjectReference> {
151 let input = AddStandaloneHostRequestType {spec, comp_res_spec, add_connected, license, };
152 let path = format!("/Folder/{moId}/AddStandaloneHost_Task", moId = &self.mo_id);
153 let req = self.client.post_request(&path, &input);
154 self.client.execute(req).await
155 }
156 /// Adds a set of new and existing hosts to the cluster.
157 ///
158 /// This API is a composite API and performs the following tasks before hosts
159 /// become part of the specified cluter -
160 /// - Adds all new hosts as standalone hosts.
161 /// - Move each host to the desired state.
162 /// - Move each host to the cluster.
163 ///
164 /// The dynamic privilege check will ensure that appropriate privileges
165 /// are acquired to allow this API to perform multiple actions on hosts
166 /// and cluster. Required privileges -
167 /// - Host.Inventory.EditCluster on cluster
168 /// - Host.Config.Maintenance on the hosts if desiredState is set
169 /// - Privileges for *Folder.BatchAddStandaloneHosts_Task* if newHosts is
170 /// set
171 /// - Host.Inventory.EditCluster on the hosts' source ComputeResource
172 /// - Host.Inventory.MoveHost on the hosts
173 ///
174 /// ## Parameters:
175 ///
176 /// ### cluster
177 /// Specifies the cluster to which hosts need to be
178 /// added.
179 ///
180 /// Refers instance of *ClusterComputeResource*.
181 ///
182 /// ### new_hosts
183 /// Specifies a list of new hosts to be added to
184 /// the cluster. Hosts are first added as standalone hosts.
185 ///
186 /// ### existing_hosts
187 /// Specifies a list of existing hosts to be
188 /// added to the cluster. Hosts are first moved to the desired state
189 /// before moving them to cluster.
190 ///
191 /// Refers instances of *HostSystem*.
192 ///
193 /// ### comp_res_spec
194 /// Specifies the configuration for the compute
195 /// resource that will be created to contain all the hosts.
196 ///
197 /// ### desired_state
198 /// Specifies desired state for hosts once added to
199 /// the cluster. If not specified, hosts are added to the cluster in their
200 /// current state. See *FolderDesiredHostState_enum* for valid values.
201 ///
202 /// ## Returns:
203 ///
204 /// This method returns a *Task* object with which to monitor
205 /// the operation.
206 ///
207 /// Refers instance of *Task*.
208 pub async fn batch_add_hosts_to_cluster_task(&self, cluster: &crate::types::structs::ManagedObjectReference, new_hosts: Option<&[crate::types::structs::FolderNewHostSpec]>, existing_hosts: Option<&[crate::types::structs::ManagedObjectReference]>, comp_res_spec: Option<&dyn crate::types::traits::ComputeResourceConfigSpecTrait>, desired_state: Option<&str>) -> Result<crate::types::structs::ManagedObjectReference> {
209 let input = BatchAddHostsToClusterRequestType {cluster, new_hosts, existing_hosts, comp_res_spec, desired_state, };
210 let path = format!("/Folder/{moId}/BatchAddHostsToCluster_Task", moId = &self.mo_id);
211 let req = self.client.post_request(&path, &input);
212 self.client.execute(req).await
213 }
214 /// Adds a list of hosts to inventory, as standalone hosts,
215 /// in a single invocation.
216 ///
217 /// The operation returns a result containing
218 /// a list of hosts that are successfully added.
219 ///
220 /// In addition to the Host.Inventory.AddStandaloneHost privilege, the operation
221 /// requires System.View privilege on the VM folder that the VMs of the
222 /// host will be placed on.
223 ///
224 /// ***Required privileges:*** Host.Inventory.AddStandaloneHost
225 ///
226 /// ## Parameters:
227 ///
228 /// ### new_hosts
229 /// Specifies a list of host specifications for new hosts.
230 ///
231 /// ### comp_res_spec
232 /// Specifies the configuration for the compute
233 /// resource that will be created to contain all the
234 /// hosts.
235 ///
236 /// ### add_connected
237 /// Flag to specify whether or not hosts should be
238 /// connected at the time they are added. A host will not
239 /// be added if a connection attempt is made and fails.
240 ///
241 /// ## Returns:
242 ///
243 /// This method returns a *Task* object with which to monitor
244 /// the operation.
245 ///
246 /// Refers instance of *Task*.
247 pub async fn batch_add_standalone_hosts_task(&self, new_hosts: Option<&[crate::types::structs::FolderNewHostSpec]>, comp_res_spec: Option<&dyn crate::types::traits::ComputeResourceConfigSpecTrait>, add_connected: bool) -> Result<crate::types::structs::ManagedObjectReference> {
248 let input = BatchAddStandaloneHostsRequestType {new_hosts, comp_res_spec, add_connected, };
249 let path = format!("/Folder/{moId}/BatchAddStandaloneHosts_Task", moId = &self.mo_id);
250 let req = self.client.post_request(&path, &input);
251 self.client.execute(req).await
252 }
253 /// Deprecated as of VI API 2.5, use *Folder.CreateClusterEx*.
254 ///
255 /// Creates a new cluster compute resource in this folder.
256 ///
257 /// Any % (percent) character used in this name parameter must be escaped, unless it
258 /// is used to start an escape sequence. Clients may also escape any other characters
259 /// in this name parameter.
260 ///
261 /// ***Required privileges:*** Host.Inventory.CreateCluster
262 ///
263 /// ## Parameters:
264 ///
265 /// ### name
266 /// Name for the new cluster.
267 ///
268 /// ### spec
269 /// Specification for the cluster.
270 ///
271 /// ## Returns:
272 ///
273 /// A new ClusterComputeResource instance.
274 ///
275 /// Refers instance of *ClusterComputeResource*.
276 ///
277 /// ## Errors:
278 ///
279 /// ***DuplicateName***: if an entity with that name already exists.
280 ///
281 /// ***InvalidArgument***: if the cluster configuration specification parameter is
282 /// invalid.
283 ///
284 /// ***InvalidName***: if the name is not a valid entity name.
285 ///
286 /// ***NotSupported***: if the cluster is being added to a folder whose
287 /// *Folder.childType* property value does not contain
288 /// "ComputeResource" or "ClusterComputeResource".
289 pub async fn create_cluster(&self, name: &str, spec: &crate::types::structs::ClusterConfigSpec) -> Result<crate::types::structs::ManagedObjectReference> {
290 let input = CreateClusterRequestType {name, spec, };
291 let path = format!("/Folder/{moId}/CreateCluster", moId = &self.mo_id);
292 let req = self.client.post_request(&path, &input);
293 self.client.execute(req).await
294 }
295 /// Creates a new cluster compute resource in this folder.
296 ///
297 /// Any % (percent) character used in this name parameter must be escaped, unless it
298 /// is used to start an escape sequence. Clients may also escape any other characters
299 /// in this name parameter.
300 ///
301 /// ***Required privileges:*** Host.Inventory.CreateCluster
302 ///
303 /// ## Parameters:
304 ///
305 /// ### name
306 /// Name for the new cluster.
307 ///
308 /// ### spec
309 /// Specification for the cluster.
310 ///
311 /// ## Returns:
312 ///
313 /// A new ClusterComputeResource instance.
314 ///
315 /// Refers instance of *ClusterComputeResource*.
316 ///
317 /// ## Errors:
318 ///
319 /// ***DuplicateName***: if an entity with that name already exists.
320 ///
321 /// ***InvalidArgument***: if the cluster configuration specification parameter is
322 /// invalid.
323 ///
324 /// ***InvalidName***: if the name is not a valid entity name.
325 ///
326 /// ***NotSupported***: if the cluster is being added to a folder whose
327 /// *Folder.childType* property value does not contain
328 /// "ComputeResource" or "ClusterComputeResource".
329 pub async fn create_cluster_ex(&self, name: &str, spec: &crate::types::structs::ClusterConfigSpecEx) -> Result<crate::types::structs::ManagedObjectReference> {
330 let input = CreateClusterExRequestType {name, spec, };
331 let path = format!("/Folder/{moId}/CreateClusterEx", moId = &self.mo_id);
332 let req = self.client.post_request(&path, &input);
333 self.client.execute(req).await
334 }
335 /// Creates a new datacenter with the given name.
336 ///
337 /// Any % (percent) character used in this name parameter must be escaped, unless it
338 /// is used to start an escape sequence. Clients may also escape any other characters
339 /// in this name parameter.
340 ///
341 /// ***Required privileges:*** Datacenter.Create
342 ///
343 /// ## Parameters:
344 ///
345 /// ### name
346 /// Name for the new datacenter. An entity name
347 /// must be a non-empty string of less than 80 characters.
348 /// The slash (/), backslash (\\) and percent (%) will be escaped
349 /// using the URL syntax. For example, %2F.
350 ///
351 /// ## Returns:
352 ///
353 /// A new Datacenter instance.
354 ///
355 /// Refers instance of *Datacenter*.
356 ///
357 /// ## Errors:
358 ///
359 /// ***DuplicateName***: if an entity with that name already exists.
360 ///
361 /// ***InvalidName***: if the new name is not a valid entity name.
362 ///
363 /// ***NotSupported***: if the datacenter is being created within a folder whose
364 /// *Folder.childType* property value does not contain
365 /// "Datacenter".
366 pub async fn create_datacenter(&self, name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
367 let input = CreateDatacenterRequestType {name, };
368 let path = format!("/Folder/{moId}/CreateDatacenter", moId = &self.mo_id);
369 let req = self.client.post_request(&path, &input);
370 self.client.execute(req).await
371 }
372 /// Create a *DistributedVirtualSwitch* in the folder according to the
373 /// specified *DVSCreateSpec*.
374 ///
375 /// The specified Folder
376 /// must be a Network entity folder.
377 ///
378 /// ***Required privileges:*** DVSwitch.Create
379 ///
380 /// ## Parameters:
381 ///
382 /// ### spec
383 /// The *DVSCreateSpec*
384 /// to create the distributed virtual switch.
385 ///
386 /// ## Returns:
387 ///
388 /// This method returns a *Task* object with which to monitor
389 /// the operation. After successful completion, the
390 /// *Task*.*Task.info*.*TaskInfo.result* property
391 /// contains the newly registered *DistributedVirtualSwitch*.
392 ///
393 /// Refers instance of *Task*.
394 ///
395 /// ## Errors:
396 ///
397 /// ***NotSupported***: if called directly on a host.
398 ///
399 /// ***DvsNotAuthorized***: if login-session's extension key does not match
400 /// (*DVSConfigInfo.extensionKey*).
401 pub async fn create_dvs_task(&self, spec: &crate::types::structs::DvsCreateSpec) -> Result<crate::types::structs::ManagedObjectReference> {
402 let input = CreateDvsRequestType {spec, };
403 let path = format!("/Folder/{moId}/CreateDVS_Task", moId = &self.mo_id);
404 let req = self.client.post_request(&path, &input);
405 self.client.execute(req).await
406 }
407 /// Creates a new sub-folder with the specified name.
408 ///
409 /// The *Folder.childType* property of the new folder is the same as
410 /// the *Folder.childType* property of the current folder.
411 ///
412 /// ***Required privileges:*** Folder.Create
413 ///
414 /// ## Parameters:
415 ///
416 /// ### name
417 /// The name to be given the new folder. An entity name
418 /// must be a non-empty string of less than 80 characters.
419 /// The slash (/), backslash (\\) and percent (%) will be escaped
420 /// using the URL syntax. For example, %2F. Any percent (%)
421 /// character used in this parameter must be escaped, unless
422 /// it is used to start an escape sequence. Clients may also
423 /// escape any other characters in this parameter.
424 ///
425 /// ## Returns:
426 ///
427 /// A reference to the new folder.
428 ///
429 /// Refers instance of *Folder*.
430 ///
431 /// ## Errors:
432 ///
433 /// ***DuplicateName***: if another object in the same folder has the
434 /// target name.
435 ///
436 /// ***InvalidName***: if the name is not a valid entity name.
437 pub async fn create_folder(&self, name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
438 let input = CreateFolderRequestType {name, };
439 let path = format!("/Folder/{moId}/CreateFolder", moId = &self.mo_id);
440 let req = self.client.post_request(&path, &input);
441 self.client.execute(req).await
442 }
443 /// Creates a new storage pod in this folder.
444 ///
445 /// Any % (percent) character used in this name parameter must be escaped, unless it
446 /// is used to start an escape sequence. Clients may also escape any other characters
447 /// in this name parameter.
448 ///
449 /// ***Required privileges:*** Folder.Create
450 ///
451 /// ## Parameters:
452 ///
453 /// ### name
454 /// Name for the new storage pod.
455 ///
456 /// ## Returns:
457 ///
458 /// A new StoragePod instance.
459 ///
460 /// Refers instance of *StoragePod*.
461 ///
462 /// ## Errors:
463 ///
464 /// ***DuplicateName***: if an entity with that name already exists.
465 ///
466 /// ***InvalidName***: if the name is not a valid entity name.
467 ///
468 /// ***NotSupported***: if the storage pod is being added to a folder whose
469 /// *Folder.childType* property value does not contain
470 /// "StoragePod".
471 pub async fn create_storage_pod(&self, name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
472 let input = CreateStoragePodRequestType {name, };
473 let path = format!("/Folder/{moId}/CreateStoragePod", moId = &self.mo_id);
474 let req = self.client.post_request(&path, &input);
475 self.client.execute(req).await
476 }
477 /// Creates a new virtual machine in the current folder and attaches it to the
478 /// specified resource pool.
479 ///
480 /// This operation creates a virtual machine,
481 /// instead of cloning a virtual machine from an existing one.
482 ///
483 /// The server does not support creating templates using this method.
484 /// Instead, you should create templates by marking existing virtual
485 /// machines as templates, or by cloning an existing virtual machine or
486 /// template.
487 ///
488 /// This operation only works if the folder's childType includes VirtualMachine.
489 /// In addition to the VirtualMachine.Inventory.Create privilege, may also require
490 /// any of the following privileges depending on the properties of the virtual
491 /// machine bring created:
492 /// - VirtualMachine.Config.AddExistingDisk if including a virtual disk device
493 /// that refers to an existing virtual disk file (not RDM)
494 /// - VirtualMachine.Config.AddNewDisk if including a virtual disk device that
495 /// creates a new virtual disk file (not RDM)
496 /// - VirtualMachine.Config.RawDevice if including a raw device mapping
497 /// (RDM) or SCSI passthrough device
498 /// - VirtualMachine.Config.HostUSBDevice if including a VirtualUSB device
499 /// backed by a host USB device
500 /// - VirtualMachine.Config.AdvancedConfig if setting values in
501 /// ConfigSpec.extraConfig
502 /// - VirtualMachine.Config.SwapPlacement if setting swapPlacement
503 /// - VirtualMachine.Config.ChangeTracking if setting changed
504 /// block tracking for the virtual machine's disks.
505 /// - Datastore.AllocateSpace required on all datastores where the
506 /// virtual machine and its virtual disks will be created
507 /// - Network.Assign required on the network which is assigned to the
508 /// new virtual machine that is being created
509 /// - Cryptographer.EncryptNew on the folder if the created virtual
510 /// machine is encrypted
511 /// - Cryptographer.RegisterHost on the host if the created virtual
512 /// machine is encrypted, but encryption is not enabled on the host
513 ///
514 /// To create a VirtualDisk on a persistent memory storage, the storage
515 /// must be specified via
516 /// *profile* while the datastore
517 /// property of corresponding VirtualDisk backing must be unset.
518 ///
519 /// To create a VirtualNVDIMM device, the storage
520 /// *profile* must be set to the
521 /// default persistent memory storage profile while the datastore property of
522 /// *the device backing* must be
523 /// unset.
524 ///
525 /// ***Required privileges:*** VirtualMachine.Inventory.Create
526 ///
527 /// ## Parameters:
528 ///
529 /// ### config
530 /// The configuration of the virtual machine hardware.
531 ///
532 /// ### pool
533 /// The resource pool to which the virtual machine will be attached.
534 ///
535 /// ***Required privileges:*** Resource.AssignVMToPool
536 ///
537 /// Refers instance of *ResourcePool*.
538 ///
539 /// ### host
540 /// The target host on which the virtual machine will run. This must
541 /// specify a host that is a member of the ComputeResource indirectly
542 /// specified by the pool. For a stand-alone host or a cluster with DRS,
543 /// host can be omitted, and the system selects a default.
544 ///
545 /// Refers instance of *HostSystem*.
546 ///
547 /// ## Returns:
548 ///
549 /// This method returns a *Task* object with which to monitor the
550 /// operation. The *info.result* property in the
551 /// *Task* contains the newly created *VirtualMachine*
552 /// upon success.
553 ///
554 /// Refers instance of *Task*.
555 ///
556 /// ## Errors:
557 ///
558 /// ***VmConfigFault***: if the configSpec has incorrect values. Typically, a more
559 /// specific subclass is thrown.
560 ///
561 /// ***OutOfBounds***: if Host.capability.maxSupportedVMs is exceeded.
562 ///
563 /// ***FileAlreadyExists***: if the requested cfgPath for the virtual machine's
564 /// configuration file already exists.
565 ///
566 /// ***FileFault***: if there is a problem creating the virtual machine on disk.
567 /// Typically, a more specific subclass, such as NoDiskSpace, will be thrown.
568 ///
569 /// ***DuplicateName***: if another virtual machine in the same folder already has
570 /// the specified target name.
571 ///
572 /// ***InvalidName***: if the name is not a valid entity name.
573 ///
574 /// ***NotSupported***: if the virtual machine is being created within a folder
575 /// whose *Folder.childType* property is not set to
576 /// "VirtualMachine".
577 ///
578 /// ***InsufficientResourcesFault***: if this operation would violate a resource
579 /// usage policy.
580 ///
581 /// ***InvalidDatastore***: if the operation cannot be performed on the
582 /// target datastores.
583 ///
584 /// ***VmWwnConflict***: if the WWN of the virtual machine has been used by
585 /// other virtual machines.
586 ///
587 /// ***AlreadyExists***: if the requested cfgPath (or the default cfgPath)
588 /// for the virtual machine's configuration file is already loaded
589 /// in the inventory.
590 ///
591 /// ***InvalidState***: if the operation is not allowed in current state of
592 /// the entities involved.
593 ///
594 /// ***NoPermission***: if the created virtual machine is encrypted but the
595 /// user does not have Cryptographer.EncryptNew on the folder.
596 pub async fn create_vm_task(&self, config: &crate::types::structs::VirtualMachineConfigSpec, pool: &crate::types::structs::ManagedObjectReference, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
597 let input = CreateVmRequestType {config, pool, host, };
598 let path = format!("/Folder/{moId}/CreateVM_Task", moId = &self.mo_id);
599 let req = self.client.post_request(&path, &input);
600 self.client.execute(req).await
601 }
602 /// Destroys this object, deleting its contents and removing it from its parent
603 /// folder (if any).
604 ///
605 /// NOTE: The appropriate privilege must be held on the parent of the destroyed
606 /// entity as well as the entity itself.
607 /// This method can throw one of several exceptions. The exact set of exceptions
608 /// depends on the kind of entity that is being removed. See comments for
609 /// each entity for more information on destroy behavior.
610 ///
611 /// ***Required privileges:*** Folder.Delete
612 ///
613 /// ## Returns:
614 ///
615 /// This method returns a *Task* object with which to monitor the
616 /// operation.
617 ///
618 /// Refers instance of *Task*.
619 ///
620 /// ## Errors:
621 ///
622 /// Failure
623 pub async fn destroy_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
624 let path = format!("/Folder/{moId}/Destroy_Task", moId = &self.mo_id);
625 let req = self.client.post_bare(&path);
626 self.client.execute(req).await
627 }
628 /// Moves a set of managed entities into this folder.
629 ///
630 /// This operation is typically used by clients when they implement a drag-and-drop
631 /// interface to move a set of objects into a folder.
632 ///
633 /// This operation is transactional only with respect to each individual entity.
634 /// The set of entities is moved sequentially as specified in the list, and
635 /// committed one at a time. If the *Folder.MoveIntoFolder_Task* method fails on an object, the
636 /// method terminates at that point with an exception, leaving the rest of the
637 /// managed entities in their original location.
638 ///
639 /// The objects that can be moved into a folder depends on the folder's
640 /// type (as defined by the folder's *Folder.childType* property).
641 /// For a datacenter folder, only datacenters and datacenter folders can be
642 /// moved into the folder. For a virtual machine folder, only virtual machines
643 /// and virtual machine folders can be moved into the folder.
644 /// For a host folder, ComputeResource objects, host folder objects, and
645 /// HostSystem objects can be moved into the folder.
646 ///
647 /// Moving a HostSystem into a host folder creates a stand-alone host from a
648 /// host that is currently part of a ClusterComputeResource. The host must be part
649 /// of a ClusterComputeResource in the same datacenter and the host must be in
650 /// maintenance mode. Otherwise, the operation fails.
651 ///
652 /// A ComputeResource with a single root resource pool is created for each
653 /// HostSystem. The name of the ComputeResource is the DNS or IP address of the
654 /// host. This operation moves the (physical) host resources out of a cluster.
655 /// It does not move or change the ResourcePool configuration that is part of the
656 /// ClusterComputeResource with which the host was associated.
657 ///
658 /// Note that all virtual machines associated with a host are moved with the host
659 /// into the folder. If there are virtual machines that should not be moved
660 /// with the host, then migrate them from the host before initiating this operation.
661 ///
662 /// For a HostSystem move, the privileges required are Host.Inventory.EditCluster
663 /// on the source ClusterComputeResource, Host.Inventory.MoveHost on the HostSystem,
664 /// and Host.Inventory.AddStandaloneHost on the target Folder.
665 ///
666 /// Otherwise, the privilege required for this operation varies depending on this
667 /// folder's type and is checked against the source container, destination container,
668 /// and the object:
669 /// - Folder.Move if the object is a Folder
670 /// - Datacenter.Move if the object is a Datacenter
671 /// - Host.Inventory.MoveCluster if the object is a ComputeResource
672 /// - VirtualMachine.Inventory.Move if the object is a virtual machine
673 /// or virtual machine template
674 /// - DVSwitch.Move if the object is a DistributedVirtualSwitch
675 /// - Datastore.Move if the object is a datastore
676 /// - Network.Move if the object is a network
677 ///
678 /// If the object is a HostSystem, the privileges required are
679 /// Host.Inventory.AddStandaloneHost on the folder, Host.Inventory.MoveHost on
680 /// the HostSystem, and Host.Inventory.EditCluster on the host's original
681 /// ComputeResource.
682 ///
683 /// ## Parameters:
684 ///
685 /// ### list
686 /// The list of objects to be moved into the folder.
687 ///
688 /// Refers instances of *ManagedEntity*.
689 ///
690 /// ## Returns:
691 ///
692 /// This method returns a *Task* object with which to monitor the
693 /// operation.
694 ///
695 /// Refers instance of *Task*.
696 ///
697 /// ## Errors:
698 ///
699 /// ***DuplicateName***: if this folder already contains an object with
700 /// the specified name.
701 ///
702 /// ***InvalidFolder***: if a Folder that is a parent of this Folder is part
703 /// of the list of objects.
704 ///
705 /// ***InvalidState***: if a HostSystem is not part of the same
706 /// datacenter, not part of a ClusterComputeResource, or not in
707 /// maintenance mode.
708 ///
709 /// ***NotSupported***: if the entity is being moved into a folder
710 /// whose *Folder.childType* property is not set to
711 /// the appropriate value. For example, a VirtualMachine entity
712 /// cannot be moved into a folder whose ChildType property value
713 /// does not contain "VirtualMachine".
714 ///
715 /// ***DisallowedOperationOnFailoverHost***: if the host is being moved
716 /// out of a cluster and was configured as a failover host in that
717 /// cluster. See *ClusterFailoverHostAdmissionControlPolicy*.
718 ///
719 /// ***VmAlreadyExistsInDatacenter***: if moving a standalone host between
720 /// datacenters, and one or more of the host's virtual machines is
721 /// already registered to a host in the destination datacenter.
722 pub async fn move_into_folder_task(&self, list: &[crate::types::structs::ManagedObjectReference]) -> Result<crate::types::structs::ManagedObjectReference> {
723 let input = MoveIntoFolderRequestType {list, };
724 let path = format!("/Folder/{moId}/MoveIntoFolder_Task", moId = &self.mo_id);
725 let req = self.client.post_request(&path, &input);
726 self.client.execute(req).await
727 }
728 /// Adds an existing virtual machine to the folder.
729 ///
730 /// Any % (percent) character used in this name parameter must be escaped, unless it
731 /// is used to start an escape sequence. Clients may also escape any other characters
732 /// in this name parameter.
733 ///
734 /// This operation only works if the folder's type is VirtualMachine.
735 /// In addition to the VirtualMachine.Inventory.Register and
736 /// Resource.AssignVMToPool privileges, it requires System.Read privilege
737 /// on the datastore that the existing virtual machine resides on. If the
738 /// virtual machine is encrypted Cryptographer.RegisterVM is required on the
739 /// folder, in which the virtual machine is registered. Otherwise, the VM is
740 /// registered successfully, but is left in the locked state.
741 ///
742 /// ***Required privileges:*** VirtualMachine.Inventory.Register
743 ///
744 /// ## Parameters:
745 ///
746 /// ### path
747 /// A datastore path to the virtual machine.
748 ///
749 /// ### name
750 /// The name to be assigned to the virtual machine. If this parameter is
751 /// not set, the displayName configuration parameter of the virtual machine is
752 /// used. An entity name must be a non-empty string of less than 80
753 /// characters. The slash (/), backslash (\\) and percent (%) will be
754 /// escaped using the URL syntax. For example, %2F.
755 ///
756 /// ### as_template
757 /// Flag to specify whether or not the virtual machine
758 /// should be marked as a template.
759 ///
760 /// ### pool
761 /// The resource pool to which the virtual machine should be attached.
762 /// If imported as a template, this parameter is not set.
763 ///
764 /// ***Required privileges:*** Resource.AssignVMToPool
765 ///
766 /// Refers instance of *ResourcePool*.
767 ///
768 /// ### host
769 /// The target host on which the virtual machine will run. This parameter
770 /// must specify a host that is a member of the ComputeResource indirectly
771 /// specified by the pool. For a stand-alone host or a cluster,
772 /// the parameter can be omitted, and the system selects a default.
773 ///
774 /// Refers instance of *HostSystem*.
775 ///
776 /// ## Returns:
777 ///
778 /// This method returns a *Task* object with which to monitor the
779 /// operation. The *info.result* property in the
780 /// *Task* contains the newly registered *VirtualMachine*
781 /// upon success.
782 ///
783 /// Refers instance of *Task*.
784 ///
785 /// ## Errors:
786 ///
787 /// ***NotSupported***: if the operation is not supported. For example,
788 /// templates are not supported directly on hosts. Also, if the operation
789 /// is invoked on a folder whose *Folder.childType* property is
790 /// not set to "VirtualMachine".
791 ///
792 /// ***OutOfBounds***: if the maximum number of VMs for this folder has been
793 /// exceeded. The maximum number is determined by
794 /// Host.capability.maxSupportedVMs.
795 ///
796 /// ***DuplicateName***: if another virtual machine in the same folder has
797 /// the target name.
798 ///
799 /// ***AlreadyExists***: if the virtual machine is already registered.
800 ///
801 /// ***InvalidDatastore***: if the operation cannot be performed on the
802 /// target datastores.
803 ///
804 /// ***NotFound***: if the configuration file is not found on the system.
805 ///
806 /// ***InvalidName***: if the entity name is invalid.
807 ///
808 /// ***InvalidArgument***: if any of the arguments such as host or resource pool
809 /// are not set to valid values.
810 ///
811 /// ***VmConfigFault***: if the format / configuration of the virtual machine
812 /// is invalid. Typically, a more specific fault is thrown such as
813 /// InvalidFormat if the configuration file cannot be read, or
814 /// InvalidDiskFormat if the disks cannot be read.
815 ///
816 /// ***FileFault***: if there is an error accessing the files on disk.
817 ///
818 /// ***InsufficientResourcesFault***: if this operation would violate a resource
819 /// usage policy.
820 ///
821 /// ***InvalidState***: if the operation is not allowed in current state of
822 /// the entities involved.
823 pub async fn register_vm_task(&self, path: &str, name: Option<&str>, as_template: bool, pool: Option<&crate::types::structs::ManagedObjectReference>, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
824 let input = RegisterVmRequestType {path, name, as_template, pool, host, };
825 let path = format!("/Folder/{moId}/RegisterVM_Task", moId = &self.mo_id);
826 let req = self.client.post_request(&path, &input);
827 self.client.execute(req).await
828 }
829 /// Reload the entity state.
830 ///
831 /// Clients only need to call this method
832 /// if they changed some external state that affects the service
833 /// without using the Web service interface to perform the change.
834 /// For example, hand-editing a virtual machine configuration file
835 /// affects the configuration of the associated virtual machine but
836 /// the service managing the virtual machine might not monitor the
837 /// file for changes. In this case, after such an edit, a client
838 /// would call "reload" on the associated virtual machine to ensure
839 /// the service and its clients have current data for the
840 /// virtual machine.
841 ///
842 /// ***Required privileges:*** System.Read
843 pub async fn reload(&self) -> Result<()> {
844 let path = format!("/Folder/{moId}/Reload", moId = &self.mo_id);
845 let req = self.client.post_bare(&path);
846 self.client.execute_void(req).await
847 }
848 /// Renames this managed entity.
849 ///
850 /// Any % (percent) character used in this name parameter
851 /// must be escaped, unless it is used to start an escape
852 /// sequence. Clients may also escape any other characters in
853 /// this name parameter.
854 ///
855 /// See also *ManagedEntity.name*.
856 ///
857 /// ***Required privileges:*** Folder.Rename
858 ///
859 /// ## Parameters:
860 ///
861 /// ### new_name
862 /// -
863 ///
864 /// ## Returns:
865 ///
866 /// This method returns a *Task* object with which to monitor the
867 /// operation.
868 ///
869 /// Refers instance of *Task*.
870 ///
871 /// ## Errors:
872 ///
873 /// ***DuplicateName***: If another object in the same folder has the target name.
874 ///
875 /// ***InvalidName***: If the new name is not a valid entity name.
876 pub async fn rename_task(&self, new_name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
877 let input = RenameRequestType {new_name, };
878 let path = format!("/Folder/{moId}/Rename_Task", moId = &self.mo_id);
879 let req = self.client.post_request(&path, &input);
880 self.client.execute(req).await
881 }
882 /// Assigns a value to a custom field.
883 ///
884 /// The setCustomValue method requires
885 /// whichever updatePrivilege is defined as one of the
886 /// *CustomFieldDef.fieldInstancePrivileges*
887 /// for the CustomFieldDef whose value is being changed.
888 ///
889 /// ## Parameters:
890 ///
891 /// ### key
892 /// The name of the field whose value is to be updated.
893 ///
894 /// ### value
895 /// Value to be assigned to the custom field.
896 pub async fn set_custom_value(&self, key: &str, value: &str) -> Result<()> {
897 let input = SetCustomValueRequestType {key, value, };
898 let path = format!("/Folder/{moId}/setCustomValue", moId = &self.mo_id);
899 let req = self.client.post_request(&path, &input);
900 self.client.execute_void(req).await
901 }
902 /// Recursively unregisters all virtual machines and vApps, and destroys
903 /// all child virtual machine folders.
904 ///
905 /// This is similar to the Destroy\_Task method,
906 /// but this method calls UnregisterAndDestroy\_Task on each virtual machine
907 /// object instead of calling Destroy\_Task.
908 /// This operation applies only to VirtualMachine folders.
909 ///
910 /// UnregisterAndDestroy\_Task is a recursive operation that destroys the specified
911 /// virtual machine folder, unregisters all child virtual machine objects, and destroys
912 /// all child virtual machine folders. When you call UnregisterAndDestroy\_Task
913 /// to destroy a virtual machine folder, the system uses the specified folder
914 /// as a root and traverses its descendant hierarchy, calling UnregisterAndDestroy\_Task
915 /// on each virtual machine object and Destroy\_Task on each virtual machine folder.
916 /// UnregisterAndDestroy\_Task is a single operation that treats each recursive call
917 /// as a single transaction, committing each call to remove an object individually.
918 /// If a failure occurs, the method terminates at that point with an exception, leaving
919 /// some or all objects unaffected.
920 ///
921 /// If you are removing virtual machines, you must hold the VirtualMachine.Delete
922 /// privilege on all of the virtual machines to be unregistered, and on their parent folders.
923 /// If you are removing virtual applications, you must hold the VApp.Delete
924 /// privilege on all of the virtual applications to be unregistered, and on their
925 /// parent folders.
926 ///
927 /// ***Required privileges:*** Folder.Delete
928 ///
929 /// ## Returns:
930 ///
931 /// This method returns a *Task* object with which to monitor the
932 /// operation.
933 ///
934 /// Refers instance of *Task*.
935 ///
936 /// ## Errors:
937 ///
938 /// ***InvalidState***: if a virtual machine is not powered off or suspended.
939 ///
940 /// ***ConcurrentAccess***: if another client modifies the folder contents
941 /// before this operation completes.
942 ///
943 /// ***NotSupported***: if the *Folder.childType* property of the
944 /// folder is not set to "VirtualMachine".
945 pub async fn unregister_and_destroy_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
946 let path = format!("/Folder/{moId}/UnregisterAndDestroy_Task", moId = &self.mo_id);
947 let req = self.client.post_bare(&path);
948 self.client.execute(req).await
949 }
950 /// Whether alarm actions are enabled for this entity.
951 ///
952 /// True if enabled; false otherwise.
953 ///
954 /// ***Required privileges:*** System.Read
955 pub async fn alarm_actions_enabled(&self) -> Result<Option<bool>> {
956 let path = format!("/Folder/{moId}/alarmActionsEnabled", moId = &self.mo_id);
957 let req = self.client.get_request(&path);
958 self.client.execute_option(req).await
959 }
960 /// List of custom field definitions that are valid for the object's type.
961 ///
962 /// The fields are sorted by *CustomFieldDef.name*.
963 ///
964 /// ***Required privileges:*** System.View
965 pub async fn available_field(&self) -> Result<Option<Vec<crate::types::structs::CustomFieldDef>>> {
966 let path = format!("/Folder/{moId}/availableField", moId = &self.mo_id);
967 let req = self.client.get_request(&path);
968 self.client.execute_option(req).await
969 }
970 /// An array of managed object references.
971 ///
972 /// Each entry is a reference to a child entity.
973 ///
974 /// ***Required privileges:*** System.View
975 ///
976 /// ## Returns:
977 ///
978 /// Refers instances of *ManagedEntity*.
979 pub async fn child_entity(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
980 let path = format!("/Folder/{moId}/childEntity", moId = &self.mo_id);
981 let req = self.client.get_request(&path);
982 self.client.execute_option(req).await
983 }
984 /// Specifies the object types a folder may contain.
985 ///
986 /// When you create a folder, it inherits its childType from the parent folder
987 /// in which it is created. childType is an array of strings. Each array entry
988 /// identifies a set of object types - Folder and one or more managed object
989 /// types. The following list shows childType values for the different folders:
990 /// - { "vim.Folder", "vim.Datacenter" } - Identifies the root folder
991 /// and its descendant folders. Data center folders can contain
992 /// child data center folders and Datacenter managed objects.
993 /// Datacenter objects contain virtual machine, compute resource,
994 /// network entity, and datastore folders.
995 /// - { "vim.Folder", "vim.Virtualmachine", "vim.VirtualApp" } - Identifies
996 /// a virtual machine folder. A virtual machine folder may contain child
997 /// virtual machine folders. It also can contain VirtualMachine managed objects,
998 /// templates, and VirtualApp managed objects.
999 /// - { "vim.Folder", "vim.ComputeResource" } - Identifies a
1000 /// compute resource folder, which contains child compute resource folders
1001 /// and ComputeResource hierarchies.
1002 /// - { "vim.Folder", "vim.Network" } - Identifies a network entity folder.
1003 /// Network entity folders on a vCenter Server can contain Network,
1004 /// DistributedVirtualSwitch, and DistributedVirtualPortgroup managed
1005 /// objects. Network entity folders on an ESXi host can contain only
1006 /// Network objects.
1007 /// - { "vim.Folder", "vim.Datastore" } - Identifies a datastore folder.
1008 /// Datastore folders can contain child datastore folders and Datastore
1009 /// managed objects.
1010 ///
1011 /// ***Required privileges:*** System.View
1012 pub async fn child_type(&self) -> Result<Option<Vec<String>>> {
1013 let path = format!("/Folder/{moId}/childType", moId = &self.mo_id);
1014 let req = self.client.get_request(&path);
1015 self.client.execute_option(req).await
1016 }
1017 /// Current configuration issues that have been detected for this entity.
1018 ///
1019 /// Typically,
1020 /// these issues have already been logged as events. The entity stores these
1021 /// events as long as they are still current. The
1022 /// *configStatus* property provides an overall status
1023 /// based on these events.
1024 pub async fn config_issue(&self) -> Result<Option<Vec<crate::types::structs::Event>>> {
1025 let path = format!("/Folder/{moId}/configIssue", moId = &self.mo_id);
1026 let req = self.client.get_request(&path);
1027 self.client.execute_option(req).await
1028 }
1029 /// The configStatus indicates whether or not the system has detected a configuration
1030 /// issue involving this entity.
1031 ///
1032 /// For example, it might have detected a
1033 /// duplicate IP address or MAC address, or a host in a cluster
1034 /// might be out of compliance. The meanings of the configStatus values are:
1035 /// - red: A problem has been detected involving the entity.
1036 /// - yellow: A problem is about to occur or a transient condition
1037 /// has occurred (For example, reconfigure fail-over policy).
1038 /// - green: No configuration issues have been detected.
1039 /// - gray: The configuration status of the entity is not being monitored.
1040 ///
1041 /// A green status indicates only that a problem has not been detected;
1042 /// it is not a guarantee that the entity is problem-free.
1043 ///
1044 /// The *configIssue* property contains a list of the
1045 /// problems that have been detected.
1046 /// In releases after vSphere API 5.0, vSphere Servers might not
1047 /// generate property collector update notifications for this property.
1048 /// To obtain the latest value of the property, you can use
1049 /// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
1050 /// If you use the PropertyCollector.WaitForUpdatesEx method, specify
1051 /// an empty string for the version parameter. Any other version value will not
1052 /// produce any property values as no updates are generated.
1053 pub async fn config_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
1054 let path = format!("/Folder/{moId}/configStatus", moId = &self.mo_id);
1055 let req = self.client.get_request(&path);
1056 self.client.execute(req).await
1057 }
1058 /// Custom field values.
1059 ///
1060 /// ***Required privileges:*** System.View
1061 pub async fn custom_value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
1062 let path = format!("/Folder/{moId}/customValue", moId = &self.mo_id);
1063 let req = self.client.get_request(&path);
1064 self.client.execute_option(req).await
1065 }
1066 /// A set of alarm states for alarms that apply to this managed entity.
1067 ///
1068 /// The set includes alarms defined on this entity
1069 /// and alarms inherited from the parent entity,
1070 /// or from any ancestors in the inventory hierarchy.
1071 ///
1072 /// Alarms are inherited if they can be triggered by this entity or its descendants.
1073 /// This set does not include alarms that are defined on descendants of this entity.
1074 ///
1075 /// ***Required privileges:*** System.View
1076 pub async fn declared_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
1077 let path = format!("/Folder/{moId}/declaredAlarmState", moId = &self.mo_id);
1078 let req = self.client.get_request(&path);
1079 self.client.execute_option(req).await
1080 }
1081 /// List of operations that are disabled, given the current runtime
1082 /// state of the entity.
1083 ///
1084 /// For example, a power-on operation always fails if a
1085 /// virtual machine is already powered on. This list can be used by clients to
1086 /// enable or disable operations in a graphical user interface.
1087 ///
1088 /// Note: This list is determined by the current runtime state of an entity,
1089 /// not by its permissions.
1090 ///
1091 /// This list may include the following operations for a HostSystem:
1092 /// - *HostSystem.EnterMaintenanceMode_Task*
1093 /// - *HostSystem.ExitMaintenanceMode_Task*
1094 /// - *HostSystem.RebootHost_Task*
1095 /// - *HostSystem.ShutdownHost_Task*
1096 /// - *HostSystem.ReconnectHost_Task*
1097 /// - *HostSystem.DisconnectHost_Task*
1098 ///
1099 /// This list may include the following operations for a VirtualMachine:
1100 /// - *VirtualMachine.AnswerVM*
1101 /// - *ManagedEntity.Rename_Task*
1102 /// - *VirtualMachine.CloneVM_Task*
1103 /// - *VirtualMachine.PowerOffVM_Task*
1104 /// - *VirtualMachine.PowerOnVM_Task*
1105 /// - *VirtualMachine.SuspendVM_Task*
1106 /// - *VirtualMachine.ResetVM_Task*
1107 /// - *VirtualMachine.ReconfigVM_Task*
1108 /// - *VirtualMachine.RelocateVM_Task*
1109 /// - *VirtualMachine.MigrateVM_Task*
1110 /// - *VirtualMachine.CustomizeVM_Task*
1111 /// - *VirtualMachine.ShutdownGuest*
1112 /// - *VirtualMachine.StandbyGuest*
1113 /// - *VirtualMachine.RebootGuest*
1114 /// - *VirtualMachine.CreateSnapshot_Task*
1115 /// - *VirtualMachine.RemoveAllSnapshots_Task*
1116 /// - *VirtualMachine.RevertToCurrentSnapshot_Task*
1117 /// - *VirtualMachine.MarkAsTemplate*
1118 /// - *VirtualMachine.MarkAsVirtualMachine*
1119 /// - *VirtualMachine.ResetGuestInformation*
1120 /// - *VirtualMachine.MountToolsInstaller*
1121 /// - *VirtualMachine.UnmountToolsInstaller*
1122 /// - *ManagedEntity.Destroy_Task*
1123 /// - *VirtualMachine.UpgradeVM_Task*
1124 /// - *VirtualMachine.ExportVm*
1125 ///
1126 /// This list may include the following operations for a ResourcePool:
1127 /// - *ResourcePool.ImportVApp*
1128 /// - *ResourcePool.CreateChildVM_Task*
1129 /// - *ResourcePool.UpdateConfig*
1130 /// - *Folder.CreateVM_Task*
1131 /// - *ManagedEntity.Destroy_Task*
1132 /// - *ManagedEntity.Rename_Task*
1133 ///
1134 /// This list may include the following operations for a VirtualApp:
1135 /// - *ManagedEntity.Destroy_Task*
1136 /// - *VirtualApp.CloneVApp_Task*
1137 /// - *VirtualApp.unregisterVApp_Task*
1138 /// - *VirtualApp.ExportVApp*
1139 /// - *VirtualApp.PowerOnVApp_Task*
1140 /// - *VirtualApp.PowerOffVApp_Task*
1141 /// - *VirtualApp.UpdateVAppConfig*
1142 ///
1143 /// In releases after vSphere API 5.0, vSphere Servers might not
1144 /// generate property collector update notifications for this property.
1145 /// To obtain the latest value of the property, you can use
1146 /// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
1147 /// If you use the PropertyCollector.WaitForUpdatesEx method, specify
1148 /// an empty string for the version parameter. Any other version value will not
1149 /// produce any property values as no updates are generated.
1150 pub async fn disabled_method(&self) -> Result<Option<Vec<String>>> {
1151 let path = format!("/Folder/{moId}/disabledMethod", moId = &self.mo_id);
1152 let req = self.client.get_request(&path);
1153 self.client.execute_option(req).await
1154 }
1155 /// Access rights the current session has to this entity.
1156 ///
1157 /// ***Required privileges:*** System.View
1158 pub async fn effective_role(&self) -> Result<Option<Vec<i32>>> {
1159 let path = format!("/Folder/{moId}/effectiveRole", moId = &self.mo_id);
1160 let req = self.client.get_request(&path);
1161 self.client.execute_option(req).await
1162 }
1163 /// Name of this entity, unique relative to its parent.
1164 ///
1165 /// Any / (slash), \\ (backslash), character used in this
1166 /// name element will be escaped. Similarly, any % (percent) character used in
1167 /// this name element will be escaped, unless it is used to start an escape
1168 /// sequence. A slash is escaped as %2F or %2f. A backslash is escaped as %5C or
1169 /// %5c, and a percent is escaped as %25.
1170 ///
1171 /// ***Required privileges:*** System.View
1172 pub async fn name(&self) -> Result<String> {
1173 let path = format!("/Folder/{moId}/name", moId = &self.mo_id);
1174 let req = self.client.get_request(&path);
1175 self.client.execute(req).await
1176 }
1177 /// The namespace with which the Folder is associated.
1178 ///
1179 /// Namespace is a vAPI
1180 /// resource which divides cluster resources and allows administrators to
1181 /// give Kubernetes environments to their development teams.
1182 /// This property is set only at the time of creation and cannot change.
1183 ///
1184 /// ***Required privileges:*** System.View
1185 pub async fn namespace(&self) -> Result<Option<String>> {
1186 let path = format!("/Folder/{moId}/namespace", moId = &self.mo_id);
1187 let req = self.client.get_request(&path);
1188 self.client.execute_option(req).await
1189 }
1190 /// General health of this managed entity.
1191 ///
1192 /// The overall status of the managed entity is computed as the worst status
1193 /// among its alarms and the configuration issues detected on the entity.
1194 /// The status is reported as one of the following values:
1195 /// - red: The entity has alarms or configuration issues with a red status.
1196 /// - yellow: The entity does not have alarms or configuration issues with a
1197 /// red status, and has at least one with a yellow status.
1198 /// - green: The entity does not have alarms or configuration issues with a
1199 /// red or yellow status, and has at least one with a green status.
1200 /// - gray: All of the entity's alarms have a gray status and the
1201 /// configuration status of the entity is not being monitored.
1202 ///
1203 /// In releases after vSphere API 5.0, vSphere Servers might not
1204 /// generate property collector update notifications for this property.
1205 /// To obtain the latest value of the property, you can use
1206 /// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
1207 /// If you use the PropertyCollector.WaitForUpdatesEx method, specify
1208 /// an empty string for the version parameter. Any other version value will not
1209 /// produce any property values as no updates are generated.
1210 pub async fn overall_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
1211 let path = format!("/Folder/{moId}/overallStatus", moId = &self.mo_id);
1212 let req = self.client.get_request(&path);
1213 self.client.execute(req).await
1214 }
1215 /// Parent of this entity.
1216 ///
1217 /// This value is null for the root object and for
1218 /// *VirtualMachine* objects that are part of
1219 /// a *VirtualApp*.
1220 ///
1221 /// ***Required privileges:*** System.View
1222 ///
1223 /// ## Returns:
1224 ///
1225 /// Refers instance of *ManagedEntity*.
1226 pub async fn parent(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
1227 let path = format!("/Folder/{moId}/parent", moId = &self.mo_id);
1228 let req = self.client.get_request(&path);
1229 self.client.execute_option(req).await
1230 }
1231 /// List of permissions defined for this entity.
1232 pub async fn permission(&self) -> Result<Option<Vec<crate::types::structs::Permission>>> {
1233 let path = format!("/Folder/{moId}/permission", moId = &self.mo_id);
1234 let req = self.client.get_request(&path);
1235 self.client.execute_option(req).await
1236 }
1237 /// The set of recent tasks operating on this managed entity.
1238 ///
1239 /// This is a subset
1240 /// of *TaskManager.recentTask* belong to this entity. A task in this
1241 /// list could be in one of the four states: pending, running, success or error.
1242 ///
1243 /// This property can be used to deduce intermediate power states for
1244 /// a virtual machine entity. For example, if the current powerState is "poweredOn"
1245 /// and there is a running task performing the "suspend" operation, then the virtual
1246 /// machine's intermediate state might be described as "suspending."
1247 ///
1248 /// Most tasks (such as power operations) obtain exclusive access to the virtual
1249 /// machine, so it is unusual for this list to contain more than one running task.
1250 /// One exception, however, is the task of cloning a virtual machine.
1251 /// In releases after vSphere API 5.0, vSphere Servers might not
1252 /// generate property collector update notifications for this property.
1253 /// To obtain the latest value of the property, you can use
1254 /// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
1255 /// If you use the PropertyCollector.WaitForUpdatesEx method, specify
1256 /// an empty string for the version parameter. Any other version value will not
1257 /// produce any property values as no updates are generated.
1258 ///
1259 /// ## Returns:
1260 ///
1261 /// Refers instances of *Task*.
1262 pub async fn recent_task(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
1263 let path = format!("/Folder/{moId}/recentTask", moId = &self.mo_id);
1264 let req = self.client.get_request(&path);
1265 self.client.execute_option(req).await
1266 }
1267 /// The set of tags associated with this managed entity.
1268 ///
1269 /// Experimental. Subject to change.
1270 ///
1271 /// ***Required privileges:*** System.View
1272 pub async fn tag(&self) -> Result<Option<Vec<crate::types::structs::Tag>>> {
1273 let path = format!("/Folder/{moId}/tag", moId = &self.mo_id);
1274 let req = self.client.get_request(&path);
1275 self.client.execute_option(req).await
1276 }
1277 /// A set of alarm states for alarms triggered by this entity
1278 /// or by its descendants.
1279 ///
1280 /// Triggered alarms are propagated up the inventory hierarchy
1281 /// so that a user can readily tell when a descendant has triggered an alarm.
1282 /// In releases after vSphere API 5.0, vSphere Servers might not
1283 /// generate property collector update notifications for this property.
1284 /// To obtain the latest value of the property, you can use
1285 /// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
1286 /// If you use the PropertyCollector.WaitForUpdatesEx method, specify
1287 /// an empty string for the version parameter. Any other version value will not
1288 /// produce any property values as no updates are generated.
1289 ///
1290 /// ***Required privileges:*** System.View
1291 pub async fn triggered_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
1292 let path = format!("/Folder/{moId}/triggeredAlarmState", moId = &self.mo_id);
1293 let req = self.client.get_request(&path);
1294 self.client.execute_option(req).await
1295 }
1296 /// List of custom field values.
1297 ///
1298 /// Each value uses a key to associate
1299 /// an instance of a *CustomFieldStringValue* with
1300 /// a custom field definition.
1301 ///
1302 /// ***Required privileges:*** System.View
1303 pub async fn value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
1304 let path = format!("/Folder/{moId}/value", moId = &self.mo_id);
1305 let req = self.client.get_request(&path);
1306 self.client.execute_option(req).await
1307 }
1308}
1309#[derive(serde::Serialize)]
1310#[serde(tag="_typeName")]
1311struct AddStandaloneHostRequestType<'a> {
1312 spec: &'a crate::types::structs::HostConnectSpec,
1313 #[serde(default, skip_serializing_if = "Option::is_none")]
1314 #[serde(rename = "compResSpec")]
1315 comp_res_spec: Option<&'a dyn crate::types::traits::ComputeResourceConfigSpecTrait>,
1316 #[serde(rename = "addConnected")]
1317 add_connected: bool,
1318 #[serde(default, skip_serializing_if = "Option::is_none")]
1319 license: Option<&'a str>,
1320}
1321#[derive(serde::Serialize)]
1322#[serde(tag="_typeName")]
1323struct BatchAddHostsToClusterRequestType<'a> {
1324 cluster: &'a crate::types::structs::ManagedObjectReference,
1325 #[serde(default, skip_serializing_if = "Option::is_none")]
1326 #[serde(rename = "newHosts")]
1327 new_hosts: Option<&'a [crate::types::structs::FolderNewHostSpec]>,
1328 #[serde(default, skip_serializing_if = "Option::is_none")]
1329 #[serde(rename = "existingHosts")]
1330 existing_hosts: Option<&'a [crate::types::structs::ManagedObjectReference]>,
1331 #[serde(default, skip_serializing_if = "Option::is_none")]
1332 #[serde(rename = "compResSpec")]
1333 comp_res_spec: Option<&'a dyn crate::types::traits::ComputeResourceConfigSpecTrait>,
1334 #[serde(default, skip_serializing_if = "Option::is_none")]
1335 #[serde(rename = "desiredState")]
1336 desired_state: Option<&'a str>,
1337}
1338#[derive(serde::Serialize)]
1339#[serde(tag="_typeName")]
1340struct BatchAddStandaloneHostsRequestType<'a> {
1341 #[serde(default, skip_serializing_if = "Option::is_none")]
1342 #[serde(rename = "newHosts")]
1343 new_hosts: Option<&'a [crate::types::structs::FolderNewHostSpec]>,
1344 #[serde(default, skip_serializing_if = "Option::is_none")]
1345 #[serde(rename = "compResSpec")]
1346 comp_res_spec: Option<&'a dyn crate::types::traits::ComputeResourceConfigSpecTrait>,
1347 #[serde(rename = "addConnected")]
1348 add_connected: bool,
1349}
1350#[derive(serde::Serialize)]
1351#[serde(tag="_typeName")]
1352struct CreateClusterRequestType<'a> {
1353 name: &'a str,
1354 spec: &'a crate::types::structs::ClusterConfigSpec,
1355}
1356#[derive(serde::Serialize)]
1357#[serde(tag="_typeName")]
1358struct CreateClusterExRequestType<'a> {
1359 name: &'a str,
1360 spec: &'a crate::types::structs::ClusterConfigSpecEx,
1361}
1362#[derive(serde::Serialize)]
1363#[serde(tag="_typeName")]
1364struct CreateDatacenterRequestType<'a> {
1365 name: &'a str,
1366}
1367#[derive(serde::Serialize)]
1368#[serde(rename = "CreateDVSRequestType", tag = "_typeName")]
1369struct CreateDvsRequestType<'a> {
1370 spec: &'a crate::types::structs::DvsCreateSpec,
1371}
1372#[derive(serde::Serialize)]
1373#[serde(tag="_typeName")]
1374struct CreateFolderRequestType<'a> {
1375 name: &'a str,
1376}
1377#[derive(serde::Serialize)]
1378#[serde(tag="_typeName")]
1379struct CreateStoragePodRequestType<'a> {
1380 name: &'a str,
1381}
1382#[derive(serde::Serialize)]
1383#[serde(rename = "CreateVMRequestType", tag = "_typeName")]
1384struct CreateVmRequestType<'a> {
1385 config: &'a crate::types::structs::VirtualMachineConfigSpec,
1386 pool: &'a crate::types::structs::ManagedObjectReference,
1387 #[serde(default, skip_serializing_if = "Option::is_none")]
1388 host: Option<&'a crate::types::structs::ManagedObjectReference>,
1389}
1390#[derive(serde::Serialize)]
1391#[serde(tag="_typeName")]
1392struct MoveIntoFolderRequestType<'a> {
1393 list: &'a [crate::types::structs::ManagedObjectReference],
1394}
1395#[derive(serde::Serialize)]
1396#[serde(rename = "RegisterVMRequestType", tag = "_typeName")]
1397struct RegisterVmRequestType<'a> {
1398 path: &'a str,
1399 #[serde(default, skip_serializing_if = "Option::is_none")]
1400 name: Option<&'a str>,
1401 #[serde(rename = "asTemplate")]
1402 as_template: bool,
1403 #[serde(default, skip_serializing_if = "Option::is_none")]
1404 pool: Option<&'a crate::types::structs::ManagedObjectReference>,
1405 #[serde(default, skip_serializing_if = "Option::is_none")]
1406 host: Option<&'a crate::types::structs::ManagedObjectReference>,
1407}
1408#[derive(serde::Serialize)]
1409#[serde(tag="_typeName")]
1410struct RenameRequestType<'a> {
1411 #[serde(rename = "newName")]
1412 new_name: &'a str,
1413}
1414#[derive(serde::Serialize)]
1415#[serde(rename = "setCustomValueRequestType", tag = "_typeName")]
1416struct SetCustomValueRequestType<'a> {
1417 key: &'a str,
1418 value: &'a str,
1419}