Skip to main content

vim_rs/mo/
host_profile.rs

1use std::sync::Arc;
2use crate::core::client::{VimClient, Result};
3/// A host profile describes ESX Server configuration.
4/// 
5/// The *HostProfile* managed object provides access to profile data and
6/// it defines methods to manipulate the profile.
7/// A host profile is a combination of subprofiles, each of which contains
8/// configuration data for a specific capability. Some examples of host capabilities are
9/// authentication, memory, networking, and security. For access to individual subprofiles,
10/// see the *HostApplyProfile* data object
11/// (*HostProfile*.*Profile.config*.*HostProfileConfigInfo.applyProfile*).
12/// 
13/// Host profiles are part of the stateless configuration architecture.
14/// In the stateless environment, a Profile Engine runs on each ESX host,
15/// but an ESX host does not store its own configuration state. Instead,
16/// host configuration data is stored on vCenter Servers. Every time a host
17/// boots or reboots, it obtains its profile from the vCenter Server.
18/// - To create a base host profile use the
19///   *HostProfileManager*.*ProfileManager.CreateProfile*
20///   method. To create a profile from an ESX host, specify a
21///   *HostProfileHostBasedConfigSpec*. To create a profile from a file,
22///   specify a *HostProfileSerializedHostProfileSpec*.
23/// - To create a subprofile for a particular host capability, use the
24///   *HostProfileManager*.*HostProfileManager.CreateDefaultProfile*
25///   method. After you create the default profile you can modify it and save it in the base profile.
26/// - To update an existing profile, use the
27///   *HostProfile*.*HostProfile.UpdateHostProfile* method.
28/// - To apply a host profile to an ESX host, use the *HostProfile.ExecuteHostProfile* method
29///   to generate configuration changes, then call the
30///   *HostProfileManager*.*HostProfileManager.ApplyHostConfig_Task*
31///   method to apply them.
32///   
33/// <u>Host-Specific Configuration</u>
34/// 
35/// An individual host or a set of hosts may have some configuration settings
36/// that are different from the settings specified in the host profile.
37/// For example, the IP configuration for the host's virtual network adapters
38/// must be unique.
39/// - To verify host-specific data, use the <code>deferredParam</code> parameter
40///   to the *HostProfile.ExecuteHostProfile* method.
41///   The Profile Engine will determine if you have specified all of the required
42///   parameters for the host configuration. If additional data is required,
43///   call the *HostProfile.ExecuteHostProfile* method again as many times as necessary
44///   to verify a complete set of parameters.
45/// - To apply host-specific data, use the <code>userInput</code> parameter to the
46///   *HostProfileManager*.*HostProfileManager.ApplyHostConfig_Task*
47///   method.
48///   
49///   
50/// The Profile Engine saves host-specific data in an *AnswerFile*
51/// that is stored on the vCenter Server.
52/// The *HostProfileManager* provides several methods to manipulate
53/// answer files.
54/// 
55/// <u>Profile Compliance</u>
56/// 
57/// You can create associations between hosts and profiles to support compliance checking.
58/// When you perform compliance checking, you can determine if a host configuration
59/// conforms to a host profile.
60/// - To create an association between a host and a profile, use the
61///   *Profile.AssociateProfile* method.
62///   The method adds the host to the
63///   *HostProfile*.*Profile.entity*\[\] list.
64/// - To retrieve the list of profiles associated with a host, use the
65///   *HostProfileManager*.*ProfileManager.FindAssociatedProfile*
66///   method.
67/// - To check host compliance, use the
68///   *Profile.CheckProfileCompliance_Task* method.
69///   If you do not specify any hosts, the method will check the compliance of all hosts
70///   that are associated with the profile.
71///   
72///   
73/// You can also use the Profile Compliance Manager to check compliance by specifying
74/// profiles, entities (hosts), or both. See
75/// *ProfileComplianceManager*.*ProfileComplianceManager.CheckCompliance_Task*.
76/// 
77/// <u>Profile Plug-Ins</u>
78/// 
79/// The vSphere architecture uses VMware profile plug-ins to define profile extensions.
80/// For information about using a plug-in to extend a host profile, see the VMware Technical Note
81/// _Developing a Host Profile Extension Plug-in_.
82/// 
83/// For access to host configuration data that is defined by plug-ins, use the
84/// *ApplyProfile*.*ApplyProfile.policy*\[\] and
85/// *ApplyProfile*.*ApplyProfile.property*\[\] lists.
86/// The *HostApplyProfile* and its subprofiles, which collectively
87/// define host configuration data, are derived from the *ApplyProfile*.
88/// - Policies store ESX configuration data in *PolicyOption* objects.
89/// - Profile property lists contain subprofiles defined by plug-ins. Subprofiles can be nested.
90///   - Subprofile lists are available as an extension to the base host profile
91///     (*HostProfile*.*Profile.config*.*HostProfileConfigInfo.applyProfile*.*ApplyProfile.property*\[\]).
92///   - Subprofile lists are available as extensions to the host subprofiles - for example,
93///     the network subprofile
94///     (*HostApplyProfile*.*HostApplyProfile.network*.*ApplyProfile.property*\[\]).
95///     
96///   
97/// If you make changes to host profile data, later versions of profile plug-ins may not support
98/// the host configuration implied by the changes that you make. When a subsequent vSphere
99/// version becomes available, you must verify that the new version supports any previous
100/// configuration changes that you have made.
101#[derive(Clone)]
102pub struct HostProfile {
103    client: Arc<dyn VimClient>,
104    mo_id: String,
105}
106impl HostProfile {
107    pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
108        Self {
109            client,
110            mo_id: mo_id.to_string(),
111        }
112    }
113    /// This API will update the validationState to Ready
114    /// from Failed, invalidate the validationFailureInfo
115    /// and reset the validationStateUpdateTime.
116    /// 
117    /// This API will return error if the validationState
118    /// is Running.
119    /// 
120    /// ***Required privileges:*** Profile.Edit
121    pub async fn host_profile_reset_validation_state(&self) -> Result<()> {
122        let path = format!("/HostProfile/{moId}/HostProfileResetValidationState", moId = &self.mo_id);
123        let req = self.client.post_bare(&path);
124        self.client.execute_void(req).await
125    }
126    /// Associate a profile with a managed entity.
127    /// 
128    /// You can check the compliance of
129    /// entities associated with a profile by calling the
130    /// *Profile.CheckProfileCompliance_Task* method.
131    /// 
132    /// ***Required privileges:*** Profile.Edit
133    ///
134    /// ## Parameters:
135    ///
136    /// ### entity
137    /// The entity(s) to associate with the profile.
138    /// If an entity is already associated with the profile, the association is
139    /// maintained and the vCenter Server does not perform any action.
140    /// 
141    /// Refers instances of *ManagedEntity*.
142    pub async fn associate_profile(&self, entity: &[crate::types::structs::ManagedObjectReference]) -> Result<()> {
143        let input = AssociateProfileRequestType {entity, };
144        let path = format!("/HostProfile/{moId}/AssociateProfile", moId = &self.mo_id);
145        let req = self.client.post_json(&path, &input);
146        self.client.execute_void(req).await
147    }
148    /// Check compliance of an entity against a Profile.
149    /// 
150    /// ***Required privileges:*** System.View
151    ///
152    /// ## Parameters:
153    ///
154    /// ### entity
155    /// If specified, the compliance check is performed on this entity.
156    /// If the entity is not specified, the vCenter Server runs a compliance check on all the
157    /// entities associated with the profile. The entity does not have to be associated with the
158    /// profile.
159    /// 
160    /// Refers instances of *ManagedEntity*.
161    ///
162    /// ## Returns:
163    ///
164    /// This method returns a *Task* object with which to monitor the
165    /// operation.
166    /// 
167    /// Refers instance of *Task*.
168    pub async fn check_profile_compliance_task(&self, entity: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<crate::types::structs::ManagedObjectReference> {
169        let input = CheckProfileComplianceRequestType {entity, };
170        let path = format!("/HostProfile/{moId}/CheckProfileCompliance_Task", moId = &self.mo_id);
171        let req = self.client.post_json(&path, &input);
172        let bytes = self.client.execute_bytes(req).await?;
173        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
174        let result: crate::types::structs::ManagedObjectReference = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
175        Ok(result)
176    }
177    /// Destroy the profile.
178    /// 
179    /// ***Required privileges:*** Profile.Delete
180    pub async fn destroy_profile(&self) -> Result<()> {
181        let path = format!("/HostProfile/{moId}/DestroyProfile", moId = &self.mo_id);
182        let req = self.client.post_bare(&path);
183        self.client.execute_void(req).await
184    }
185    /// Remove the association between a profile and a managed entity.
186    /// 
187    /// ***Required privileges:*** Profile.Edit
188    ///
189    /// ## Parameters:
190    ///
191    /// ### entity
192    /// List of entities. The vCenter Server will remove the associations
193    /// that the profile has with the entities in the list. If unset,
194    /// the Server removes all the associations that the profile has with any
195    /// managed entities in the inventory.
196    /// If the specified entity is not associated with the profile,
197    /// the Server does not perform any action.
198    /// 
199    /// Refers instances of *ManagedEntity*.
200    pub async fn dissociate_profile(&self, entity: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<()> {
201        let input = DissociateProfileRequestType {entity, };
202        let path = format!("/HostProfile/{moId}/DissociateProfile", moId = &self.mo_id);
203        let req = self.client.post_json(&path, &input);
204        self.client.execute_void(req).await
205    }
206    /// Run the Profile Engine to determine the list of configuration changes
207    /// needed for the specified host.
208    /// 
209    /// The method generates configuration changes
210    /// based on the host profile.
211    /// 
212    /// You can also specify deferred parameters to verify additional host-specific data.
213    /// The Profile Engine uses the policy options
214    /// (*HostProfile*.*Profile.config*.*HostProfileConfigInfo.applyProfile*.*ApplyProfile.policy*\[\])
215    /// to determine the required parameters
216    /// (*PolicyOption*.*PolicyOption.parameter*\[\])
217    /// for host configuration. If you do not provide all of the required parameters,
218    /// you must call the method again to provide the complete list to the Profile Engine.
219    /// After successful profile execution, when you apply the profile,
220    /// the Profile Engine will save the host-specific data in an *AnswerFile*.
221    /// 
222    /// ***Required privileges:*** System.View
223    ///
224    /// ## Parameters:
225    ///
226    /// ### host
227    /// Host on which to execute the profile.
228    /// The host does not have to be associated with the profile.
229    /// 
230    /// Refers instance of *HostSystem*.
231    ///
232    /// ### deferred_param
233    /// Additional configuration data to be applied to the host.
234    /// This should contain all of the host-specific data, including data from from
235    /// previous calls to the method.
236    ///
237    /// ## Returns:
238    ///
239    /// Result of the execution. If the operation is successful
240    /// (*ProfileExecuteResult*.*ProfileExecuteResult.status*<code>=success</code>),
241    /// the result object includes a valid host configuration specification that you can pass to the
242    /// *HostProfileManager*.*HostProfileManager.ApplyHostConfig_Task*
243    /// method.
244    /// 
245    /// If the operation is not successful, the object contains error information
246    /// or information about additional data required for the host configuration.
247    /// If additional data is required, the required input list
248    /// (*ProfileExecuteResult*.*ProfileExecuteResult.requireInput*\[\])
249    /// contains both the <code>deferredParam</code> data and paths to missing parameters.
250    /// After you fill in the missing parameters, pass the complete required input
251    /// list via the <code>deferredParam</code> parameter in another call to the execute method
252    /// to finish input verification. After successful profile execution, you can pass
253    /// the verified required input list to the *HostProfileManager.ApplyHostConfig_Task*
254    /// method.
255    pub async fn execute_host_profile(&self, host: &crate::types::structs::ManagedObjectReference, deferred_param: Option<&[crate::types::structs::ProfileDeferredPolicyOptionParameter]>) -> Result<Box<dyn crate::types::traits::ProfileExecuteResultTrait>> {
256        let input = ExecuteHostProfileRequestType {host, deferred_param, };
257        let path = format!("/HostProfile/{moId}/ExecuteHostProfile", moId = &self.mo_id);
258        let req = self.client.post_json(&path, &input);
259        let bytes = self.client.execute_bytes(req).await?;
260        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
261        let result: Box<dyn crate::types::traits::ProfileExecuteResultTrait> = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
262        Ok(result)
263    }
264    /// Export the profile in a serialized form.
265    /// 
266    /// To use the serialized string to create a profile,
267    /// specify a *ProfileSerializedCreateSpec* when you call the
268    /// *HostProfileManager*.*ProfileManager.CreateProfile*
269    /// method.
270    /// 
271    /// ***Required privileges:*** Profile.Export
272    ///
273    /// ## Returns:
274    ///
275    /// Serialized form of the profile.
276    pub async fn export_profile(&self) -> Result<String> {
277        let path = format!("/HostProfile/{moId}/ExportProfile", moId = &self.mo_id);
278        let req = self.client.post_bare(&path);
279        let bytes = self.client.execute_bytes(req).await?;
280        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
281        let result: String = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
282        Ok(result)
283    }
284    /// Returns the localizable description for the profile.
285    /// 
286    /// ***Required privileges:*** System.View
287    ///
288    /// ## Returns:
289    ///
290    /// Profile divided into sections containing element descriptions and messages.
291    pub async fn retrieve_description(&self) -> Result<Option<crate::types::structs::ProfileDescription>> {
292        let path = format!("/HostProfile/{moId}/RetrieveDescription", moId = &self.mo_id);
293        let req = self.client.post_bare(&path);
294        let bytes_opt = self.client.execute_option_bytes(req).await?;
295        match bytes_opt {
296            Some(bytes) => {
297                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
298                Ok(Some(miniserde::json::from_str::<crate::types::structs::ProfileDescription>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
299            }
300            None => Ok(None),
301        }
302    }
303    /// Update the <code>HostProfile</code> with the specified configuration data.
304    /// 
305    /// ***Required privileges:*** Profile.Edit
306    ///
307    /// ## Parameters:
308    ///
309    /// ### config
310    /// Specification containing the new data.
311    ///
312    /// ## Errors:
313    ///
314    /// ***DuplicateName***: If the profile with the new name already exists.
315    /// 
316    /// ***ProfileUpdateFailed***: if errors were encountered when updating
317    /// the profile.
318    pub async fn update_host_profile(&self, config: &dyn crate::types::traits::HostProfileConfigSpecTrait) -> Result<()> {
319        let input = UpdateHostProfileRequestType {config, };
320        let path = format!("/HostProfile/{moId}/UpdateHostProfile", moId = &self.mo_id);
321        let req = self.client.post_json(&path, &input);
322        self.client.execute_void(req).await
323    }
324    /// Sets the *HostProfile*.*HostProfile.referenceHost* property.
325    /// 
326    /// ***Required privileges:*** Profile.Edit
327    ///
328    /// ## Parameters:
329    ///
330    /// ### host
331    /// Reference host to use. If unset, the *HostProfile.referenceHost*
332    /// property is cleared.
333    /// 
334    /// Refers instance of *HostSystem*.
335    pub async fn update_reference_host(&self, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<()> {
336        let input = UpdateReferenceHostRequestType {host, };
337        let path = format!("/HostProfile/{moId}/UpdateReferenceHost", moId = &self.mo_id);
338        let req = self.client.post_json(&path, &input);
339        self.client.execute_void(req).await
340    }
341    /// The latest compliance check time.
342    /// 
343    /// ***Since:*** vSphere API Release 8.0.1.0
344    pub async fn compliance_check_time(&self) -> Result<Option<String>> {
345        let path = format!("/HostProfile/{moId}/complianceCheckTime", moId = &self.mo_id);
346        let req = self.client.get_request(&path);
347        let bytes_opt = self.client.execute_option_bytes(req).await?;
348        match bytes_opt {
349            Some(bytes) => {
350                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
351                Ok(Some(miniserde::json::from_str::<String>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
352            }
353            None => Ok(None),
354        }
355    }
356    /// Overall compliance of entities associated with this profile.
357    /// 
358    /// If one of the entities is out of compliance, the profile is <code>nonCompliant</code>.
359    /// If all entities are in compliance, the profile is <code>compliant</code>.
360    /// If the compliance status of one of the entities is not known, compliance status
361    /// of the profile is <code>unknown</code>.
362    /// See *ComplianceResultStatus_enum*.
363    pub async fn compliance_status(&self) -> Result<String> {
364        let path = format!("/HostProfile/{moId}/complianceStatus", moId = &self.mo_id);
365        let req = self.client.get_request(&path);
366        let bytes = self.client.execute_bytes(req).await?;
367        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
368        let result: String = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
369        Ok(result)
370    }
371    /// Configuration data for the profile.
372    /// 
373    /// ***Required privileges:*** Profile.Edit
374    pub async fn config(&self) -> Result<Box<dyn crate::types::traits::ProfileConfigInfoTrait>> {
375        let path = format!("/HostProfile/{moId}/config", moId = &self.mo_id);
376        let req = self.client.get_request(&path);
377        let bytes = self.client.execute_bytes(req).await?;
378        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
379        let result: Box<dyn crate::types::traits::ProfileConfigInfoTrait> = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
380        Ok(result)
381    }
382    /// Time at which the profile was created.
383    pub async fn created_time(&self) -> Result<String> {
384        let path = format!("/HostProfile/{moId}/createdTime", moId = &self.mo_id);
385        let req = self.client.get_request(&path);
386        let bytes = self.client.execute_bytes(req).await?;
387        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
388        let result: String = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
389        Ok(result)
390    }
391    /// Deprecated as of vSphere API 5.0. use *Profile.RetrieveDescription* instead.
392    /// 
393    /// Localizable description of the profile
394    pub async fn description(&self) -> Result<Option<crate::types::structs::ProfileDescription>> {
395        let path = format!("/HostProfile/{moId}/description", moId = &self.mo_id);
396        let req = self.client.get_request(&path);
397        let bytes_opt = self.client.execute_option_bytes(req).await?;
398        match bytes_opt {
399            Some(bytes) => {
400                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
401                Ok(Some(miniserde::json::from_str::<crate::types::structs::ProfileDescription>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
402            }
403            None => Ok(None),
404        }
405    }
406    /// List of managed entities associated with the profile.
407    ///
408    /// ## Returns:
409    ///
410    /// Refers instances of *ManagedEntity*.
411    pub async fn entity(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
412        let path = format!("/HostProfile/{moId}/entity", moId = &self.mo_id);
413        let req = self.client.get_request(&path);
414        let bytes_opt = self.client.execute_option_bytes(req).await?;
415        match bytes_opt {
416            Some(bytes) => {
417                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
418                Ok(Some(miniserde::json::from_str::<Vec<crate::types::structs::ManagedObjectReference>>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
419            }
420            None => Ok(None),
421        }
422    }
423    /// Time at which the profile was last modified.
424    pub async fn modified_time(&self) -> Result<String> {
425        let path = format!("/HostProfile/{moId}/modifiedTime", moId = &self.mo_id);
426        let req = self.client.get_request(&path);
427        let bytes = self.client.execute_bytes(req).await?;
428        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
429        let result: String = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
430        Ok(result)
431    }
432    /// Name of the profile.
433    pub async fn name(&self) -> Result<String> {
434        let path = format!("/HostProfile/{moId}/name", moId = &self.mo_id);
435        let req = self.client.get_request(&path);
436        let bytes = self.client.execute_bytes(req).await?;
437        let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
438        let result: String = miniserde::json::from_str(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?;
439        Ok(result)
440    }
441    /// Reference host in use for this host profile.
442    /// 
443    /// To set this property,
444    /// use the *HostProfile.UpdateReferenceHost*
445    /// method. If you do not specify a host for validation
446    /// (*HostProfileCompleteConfigSpec*.*HostProfileCompleteConfigSpec.validatorHost*),
447    /// the Profile Engine uses the reference host to validate the profile.
448    ///
449    /// ## Returns:
450    ///
451    /// Refers instance of *HostSystem*.
452    pub async fn reference_host(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
453        let path = format!("/HostProfile/{moId}/referenceHost", moId = &self.mo_id);
454        let req = self.client.get_request(&path);
455        let bytes_opt = self.client.execute_option_bytes(req).await?;
456        match bytes_opt {
457            Some(bytes) => {
458                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
459                Ok(Some(miniserde::json::from_str::<crate::types::structs::ManagedObjectReference>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
460            }
461            None => Ok(None),
462        }
463    }
464    /// This object is created or updated if the *HostProfileValidationState_enum*
465    /// is Failed.
466    /// 
467    /// This object captures the most recent validation
468    /// result for the host profile object in case of failure.
469    pub async fn validation_failure_info(&self) -> Result<Option<crate::types::structs::HostProfileValidationFailureInfo>> {
470        let path = format!("/HostProfile/{moId}/validationFailureInfo", moId = &self.mo_id);
471        let req = self.client.get_request(&path);
472        let bytes_opt = self.client.execute_option_bytes(req).await?;
473        match bytes_opt {
474            Some(bytes) => {
475                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
476                Ok(Some(miniserde::json::from_str::<crate::types::structs::HostProfileValidationFailureInfo>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
477            }
478            None => Ok(None),
479        }
480    }
481    /// State of the host profile validation operation.
482    /// 
483    /// The values
484    /// of the state will be one of *HostProfileValidationState_enum* enumerations.
485    pub async fn validation_state(&self) -> Result<Option<String>> {
486        let path = format!("/HostProfile/{moId}/validationState", moId = &self.mo_id);
487        let req = self.client.get_request(&path);
488        let bytes_opt = self.client.execute_option_bytes(req).await?;
489        match bytes_opt {
490            Some(bytes) => {
491                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
492                Ok(Some(miniserde::json::from_str::<String>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
493            }
494            None => Ok(None),
495        }
496    }
497    /// Update time of the validation operation.
498    pub async fn validation_state_update_time(&self) -> Result<Option<String>> {
499        let path = format!("/HostProfile/{moId}/validationStateUpdateTime", moId = &self.mo_id);
500        let req = self.client.get_request(&path);
501        let bytes_opt = self.client.execute_option_bytes(req).await?;
502        match bytes_opt {
503            Some(bytes) => {
504                let text = std::str::from_utf8(bytes.as_ref()).map_err(|e| crate::core::client::VimError::ParseError(e.to_string()))?;
505                Ok(Some(miniserde::json::from_str::<String>(text).map_err(|_| crate::core::client::VimError::ParseError("miniserde deserialization failed".to_string()))?))
506            }
507            None => Ok(None),
508        }
509    }
510}
511struct AssociateProfileRequestType<'a> {
512    entity: &'a [crate::types::structs::ManagedObjectReference],
513}
514
515impl<'a> miniserde::Serialize for AssociateProfileRequestType<'a> {
516    fn begin(&self) -> miniserde::ser::Fragment<'_> {
517        miniserde::ser::Fragment::Map(Box::new(AssociateProfileRequestTypeSer { data: self, seq: 0 }))
518    }
519}
520
521struct AssociateProfileRequestTypeSer<'b, 'a> {
522    data: &'b AssociateProfileRequestType<'a>,
523    seq: usize,
524}
525
526impl<'b, 'a> miniserde::ser::Map for AssociateProfileRequestTypeSer<'b, 'a> {
527    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
528        let seq = self.seq;
529        self.seq += 1;
530        match seq {
531            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"AssociateProfileRequestType")),
532            1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
533            _ => return None,
534        }
535    }
536}
537struct CheckProfileComplianceRequestType<'a> {
538    entity: Option<&'a [crate::types::structs::ManagedObjectReference]>,
539}
540
541impl<'a> miniserde::Serialize for CheckProfileComplianceRequestType<'a> {
542    fn begin(&self) -> miniserde::ser::Fragment<'_> {
543        miniserde::ser::Fragment::Map(Box::new(CheckProfileComplianceRequestTypeSer { data: self, seq: 0 }))
544    }
545}
546
547struct CheckProfileComplianceRequestTypeSer<'b, 'a> {
548    data: &'b CheckProfileComplianceRequestType<'a>,
549    seq: usize,
550}
551
552impl<'b, 'a> miniserde::ser::Map for CheckProfileComplianceRequestTypeSer<'b, 'a> {
553    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
554        loop {
555            let seq = self.seq;
556            self.seq += 1;
557            match seq {
558                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CheckProfileComplianceRequestType")),
559                1 => {
560                    let Some(ref val) = self.data.entity else { continue; };
561                    return Some((std::borrow::Cow::Borrowed("entity"), val as &dyn miniserde::Serialize));
562                }
563                _ => return None,
564            }
565        }
566    }
567}
568struct DissociateProfileRequestType<'a> {
569    entity: Option<&'a [crate::types::structs::ManagedObjectReference]>,
570}
571
572impl<'a> miniserde::Serialize for DissociateProfileRequestType<'a> {
573    fn begin(&self) -> miniserde::ser::Fragment<'_> {
574        miniserde::ser::Fragment::Map(Box::new(DissociateProfileRequestTypeSer { data: self, seq: 0 }))
575    }
576}
577
578struct DissociateProfileRequestTypeSer<'b, 'a> {
579    data: &'b DissociateProfileRequestType<'a>,
580    seq: usize,
581}
582
583impl<'b, 'a> miniserde::ser::Map for DissociateProfileRequestTypeSer<'b, 'a> {
584    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
585        loop {
586            let seq = self.seq;
587            self.seq += 1;
588            match seq {
589                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"DissociateProfileRequestType")),
590                1 => {
591                    let Some(ref val) = self.data.entity else { continue; };
592                    return Some((std::borrow::Cow::Borrowed("entity"), val as &dyn miniserde::Serialize));
593                }
594                _ => return None,
595            }
596        }
597    }
598}
599struct ExecuteHostProfileRequestType<'a> {
600    host: &'a crate::types::structs::ManagedObjectReference,
601    deferred_param: Option<&'a [crate::types::structs::ProfileDeferredPolicyOptionParameter]>,
602}
603
604impl<'a> miniserde::Serialize for ExecuteHostProfileRequestType<'a> {
605    fn begin(&self) -> miniserde::ser::Fragment<'_> {
606        miniserde::ser::Fragment::Map(Box::new(ExecuteHostProfileRequestTypeSer { data: self, seq: 0 }))
607    }
608}
609
610struct ExecuteHostProfileRequestTypeSer<'b, 'a> {
611    data: &'b ExecuteHostProfileRequestType<'a>,
612    seq: usize,
613}
614
615impl<'b, 'a> miniserde::ser::Map for ExecuteHostProfileRequestTypeSer<'b, 'a> {
616    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
617        loop {
618            let seq = self.seq;
619            self.seq += 1;
620            match seq {
621                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ExecuteHostProfileRequestType")),
622                1 => return Some((std::borrow::Cow::Borrowed("host"), &self.data.host as &dyn miniserde::Serialize)),
623                2 => {
624                    let Some(ref val) = self.data.deferred_param else { continue; };
625                    return Some((std::borrow::Cow::Borrowed("deferredParam"), val as &dyn miniserde::Serialize));
626                }
627                _ => return None,
628            }
629        }
630    }
631}
632struct UpdateHostProfileRequestType<'a> {
633    config: &'a dyn crate::types::traits::HostProfileConfigSpecTrait,
634}
635
636impl<'a> miniserde::Serialize for UpdateHostProfileRequestType<'a> {
637    fn begin(&self) -> miniserde::ser::Fragment<'_> {
638        miniserde::ser::Fragment::Map(Box::new(UpdateHostProfileRequestTypeSer { data: self, seq: 0 }))
639    }
640}
641
642struct UpdateHostProfileRequestTypeSer<'b, 'a> {
643    data: &'b UpdateHostProfileRequestType<'a>,
644    seq: usize,
645}
646
647impl<'b, 'a> miniserde::ser::Map for UpdateHostProfileRequestTypeSer<'b, 'a> {
648    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
649        let seq = self.seq;
650        self.seq += 1;
651        match seq {
652            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateHostProfileRequestType")),
653            1 => return Some((std::borrow::Cow::Borrowed("config"), &self.data.config as &dyn miniserde::Serialize)),
654            _ => return None,
655        }
656    }
657}
658struct UpdateReferenceHostRequestType<'a> {
659    host: Option<&'a crate::types::structs::ManagedObjectReference>,
660}
661
662impl<'a> miniserde::Serialize for UpdateReferenceHostRequestType<'a> {
663    fn begin(&self) -> miniserde::ser::Fragment<'_> {
664        miniserde::ser::Fragment::Map(Box::new(UpdateReferenceHostRequestTypeSer { data: self, seq: 0 }))
665    }
666}
667
668struct UpdateReferenceHostRequestTypeSer<'b, 'a> {
669    data: &'b UpdateReferenceHostRequestType<'a>,
670    seq: usize,
671}
672
673impl<'b, 'a> miniserde::ser::Map for UpdateReferenceHostRequestTypeSer<'b, 'a> {
674    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
675        loop {
676            let seq = self.seq;
677            self.seq += 1;
678            match seq {
679                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateReferenceHostRequestType")),
680                1 => {
681                    let Some(ref val) = self.data.host else { continue; };
682                    return Some((std::borrow::Cow::Borrowed("host"), val as &dyn miniserde::Serialize));
683                }
684                _ => return None,
685            }
686        }
687    }
688}