vim_rs 0.4.4

Rust Bindings for the VMware by Broadcom vCenter VI JSON API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// This managed object provides operations to query and update
/// roles and permissions.
/// 
/// **Privileges** are the basic individual rights required to
/// perform operations. They are statically defined and
/// never change for a single version of a product. Examples
/// of privileges are "Power on a virtual machine"
/// or "Configure a host."
/// 
/// **Roles** are aggregations of privileges, used for convenience.
/// For user-defined roles, the system-defined privileges, "System.Anonymous",
/// "System.View", and "System.Read" are always present.
/// 
/// **Permissions** are the actual access-control rules. A
/// permission is defined on a ManagedEntity and
/// specifies the user or group ("principal") to which
/// the rule applies. The role specifies the
/// privileges to apply, and the propagate flag
/// specifies whether or not the rule applies to sub-objects
/// of the managed entity.
/// 
/// A ManagedEntity may have multiple permissions,
/// but may have only one permission per user or group. If, when logging
/// in, a user has both a user permission and a group permission
/// (as a group member) for the same entity, then the
/// user-specific permission takes precedent. If there is no
/// user-specific permission, but two or more group permissions
/// are present, and the user is a member of the groups, then the
/// privileges are the union of the specified roles.
/// 
/// Managed entities may be collected together into a "complex entity" for
/// the purpose of applying permissions consistently. Complex entities may have a
/// Datacenter, ComputeResource, or ClusterComputeResource as a parent, with other
/// child managed objects as additional parts of the complex entity:
/// - A Datacenter's child objects are the root virtual machine and host Folders.
/// - A ComputeResource's child objects are the root ResourcePool and HostSystem.
/// - A ClusterComputeResource has only the root ResourcePool as a child object.
///   
/// Child objects in a complex entity are forced to inherit permissions from the
/// parent object. When query operations are used to discover permissions on child
/// objects of complex entities, different results may be returned for the owner of the
/// permission. In some cases, the child object of the complex entity is returned as
/// the object that defines the permission, and in other cases, the parent from which
/// the permission is propagated is returned as the object that defines the permission.
/// In both cases, the information about the owner of the permission is correct, since
/// the entities within a complex entity are considered equivalent. Permissions
/// defined on complex entities are always applicable on the child entities,
/// regardless of the propagation flag, but may only be defined or modified on the
/// parent object.
/// 
/// In a group of fault-tolerance (FT) protected VirtualMachines, the secondary
/// VirtualMachines are forced to inherit permissions from the primary VirtualMachine.
/// Queries to discover permissions on FT secondary VMs always return the primary VM
/// as the object that defines the permissions. Permissions defined on an FT primary
/// VM are always applicable on its secondary VMs, but can only be defined or modified
/// on the primary VM.
#[derive(Clone)]
pub struct AuthorizationManager {
    client: Arc<dyn VimClient>,
    mo_id: String,
}
impl AuthorizationManager {
    pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
        Self {
            client,
            mo_id: mo_id.to_string(),
        }
    }
    /// Adds a new role.
    /// 
    /// This method will add a user-defined role with given list of privileges
    /// and three system-defined privileges, "System.Anonymous", "System.View",
    /// and "System.Read".
    /// 
    /// ***Required privileges:*** Authorization.ModifyRoles
    ///
    /// ## Parameters:
    ///
    /// ### name
    /// Name of the new role.
    ///
    /// ### priv_ids
    /// List of privileges to assign to the role.
    ///
    /// ## Returns:
    ///
    /// The roleId assigned to the new role.
    ///
    /// ## Errors:
    ///
    /// ***AlreadyExists***: if a role with the given name already exists.
    /// 
    /// ***InvalidName***: if the role name is empty.
    /// 
    /// ***InvalidArgument***: if privIds contains an unknown privilege.
    pub async fn add_authorization_role(&self, name: &str, priv_ids: Option<&[String]>) -> Result<i32> {
        let input = AddAuthorizationRoleRequestType {name, priv_ids, };
        let bytes = self.client.invoke("", "AuthorizationManager", &self.mo_id, "AddAuthorizationRole", Some(&input)).await?;
        let result: i32 = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Get the list of effective privileges for a user,
    /// either granted explicitly, or through group membership.
    /// 
    /// This API is implemented only by vCenter Server.
    ///
    /// ## Parameters:
    ///
    /// ### entities
    /// are the entities to retrieve privileges on
    /// 
    /// ***Required privileges:*** System.View
    /// 
    /// Refers instances of *ManagedEntity*.
    ///
    /// ### user_name
    /// is the user to retrieve privileges for
    ///
    /// ## Returns:
    ///
    /// the privilege check result for each entity
    pub async fn fetch_user_privilege_on_entities(&self, entities: &[crate::types::structs::ManagedObjectReference], user_name: &str) -> Result<Option<Vec<crate::types::structs::UserPrivilegeResult>>> {
        let input = FetchUserPrivilegeOnEntitiesRequestType {entities, user_name, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "FetchUserPrivilegeOnEntities", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Check whether a session holds a set of privileges on a set of managed entities.
    /// 
    /// If the session does not exist, false is returned for all privileges of
    /// all the entities.
    /// 
    /// This API is implemented only by vCenter Server.
    /// 
    /// ***Required privileges:*** System.View
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// The set of entities on which the privileges are checked.
    /// 
    /// ***Required privileges:*** System.Read
    /// 
    /// Refers instances of *ManagedEntity*.
    ///
    /// ### session_id
    /// The session ID to check privileges for. A sesssion ID can be
    /// obtained from *UserSession.key*.
    ///
    /// ### priv_id
    /// The array of privilege IDs to check.
    ///
    /// ## Returns:
    ///
    /// The privilege check result.
    pub async fn has_privilege_on_entities(&self, entity: &[crate::types::structs::ManagedObjectReference], session_id: &str, priv_id: Option<&[String]>) -> Result<Option<Vec<crate::types::structs::EntityPrivilege>>> {
        let input = HasPrivilegeOnEntitiesRequestType {entity, session_id, priv_id, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "HasPrivilegeOnEntities", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Check whether a session holds a set of privileges on a managed entity.
    /// 
    /// If the session does not exist, false is returned for all privileges.
    /// 
    /// This API is implemented only by vCenter Server.
    /// 
    /// ***Required privileges:*** System.View
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// The entity on which the privileges are checked.
    /// 
    /// ***Required privileges:*** System.Read
    /// 
    /// Refers instance of *ManagedEntity*.
    ///
    /// ### session_id
    /// The session ID to check privileges for. A sesssion ID can be
    /// obtained from *UserSession.key*.
    ///
    /// ### priv_id
    /// The array of privilege IDs to check.
    ///
    /// ## Returns:
    ///
    /// a boolean value for each privilege indicating whether the session holds the
    /// privilege.
    pub async fn has_privilege_on_entity(&self, entity: &crate::types::structs::ManagedObjectReference, session_id: &str, priv_id: Option<&[String]>) -> Result<Option<Vec<bool>>> {
        let input = HasPrivilegeOnEntityRequestType {entity, session_id, priv_id, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "HasPrivilegeOnEntity", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Checks if a user holds a certain set of privileges on a number of
    /// managed entities.
    /// 
    /// Privileges may be granted to users through their
    /// respective group membership. If a privilege is granted to a group it is
    /// implicitly granted to its members.
    /// 
    /// This API is implemented only by vCenter Server.
    ///
    /// ## Parameters:
    ///
    /// ### entities
    /// are the managed objects to check privileges on. If they
    /// refer to managed objects that are not managed entities
    /// the privilege check will be done on the root folder.
    /// 
    /// ***Required privileges:*** System.View
    ///
    /// ### user_name
    /// is the name of the user to check privileges for. Both
    /// UPN and PreWindows2000LogonName user name formats
    /// are supported.
    ///
    /// ### priv_id
    /// is the set of privileges to check for
    ///
    /// ## Returns:
    ///
    /// the privilege check result
    pub async fn has_user_privilege_on_entities(&self, entities: &[crate::types::structs::ManagedObjectReference], user_name: &str, priv_id: Option<&[String]>) -> Result<Option<Vec<crate::types::structs::EntityPrivilege>>> {
        let input = HasUserPrivilegeOnEntitiesRequestType {entities, user_name, priv_id, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "HasUserPrivilegeOnEntities", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Reassigns all permissions of a role to another role.
    /// 
    /// ***Required privileges:*** Authorization.ReassignRolePermissions
    ///
    /// ## Parameters:
    ///
    /// ### src_role_id
    /// The ID of the source role providing the permissions
    /// which are changing.
    ///
    /// ### dst_role_id
    /// The ID of the destination role to which the
    /// permissions are reassigned.
    ///
    /// ## Errors:
    ///
    /// ***NotFound***: if either the source or destination role does not exist.
    /// 
    /// ***InvalidArgument***: if dstRoleId is the View or Anonymous role or if
    /// both role IDs are the same.
    /// 
    /// ***AuthMinimumAdminPermission***: if srcRoleId is the Administrator role, meaning
    /// that applying the change would leave the system with
    /// no Administrator permission on the root node.
    /// 
    /// ***NoPermission***: if current session does not have any privilege
    /// in the source or destination role or
    /// "Authorization.ReassignRolePermissions"
    /// privilege on the root folder.
    pub async fn merge_permissions(&self, src_role_id: i32, dst_role_id: i32) -> Result<()> {
        let input = MergePermissionsRequestType {src_role_id, dst_role_id, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "MergePermissions", Some(&input)).await
    }
    /// Removes a permission rule from an entity.
    /// 
    /// This will fail with an InvalidArgument fault if called on: the direct child
    /// folders of a datacenter managed object, the root resource pool of a
    /// ComputeResource or ClusterComputeResource, or a HostSystem that is part of
    /// a ComputeResource (Stand-alone Host). These objects always have the same
    /// permissions as their parent.
    /// 
    /// This will fail with an InvalidArgument fault if called on a fault-tolerance (FT)
    /// secondary VirtualMachine. Such a VirtualMachine always has the same permissions
    /// as its FT primary VirtualMachine.
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// Entity on which a permission is removed.
    /// 
    /// ***Required privileges:*** Authorization.ModifyPermissions
    /// 
    /// Refers instance of *ManagedEntity*.
    ///
    /// ### user
    /// User or group for which the permission is defined.
    ///
    /// ### is_group
    /// True, if user refers to a group name; false, for a user name.
    ///
    /// ## Errors:
    ///
    /// ***NotFound***: if a permission for this entity and user or group
    /// does not exist.
    /// 
    /// ***AuthMinimumAdminPermission***: if this change would leave the system with
    /// no Administrator permission on the root node.
    /// 
    /// ***InvalidArgument***: if one of the new role IDs is the View or
    /// Anonymous role, or the entity does not support
    /// removing permissions.
    /// 
    /// ***NoPermission***: if current session does not have any privilege
    /// in the permission to be removed or
    /// "Authorization.ModifyPermissions" privilege
    /// on the entity.
    pub async fn remove_entity_permission(&self, entity: &crate::types::structs::ManagedObjectReference, user: &str, is_group: bool) -> Result<()> {
        let input = RemoveEntityPermissionRequestType {entity, user, is_group, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "RemoveEntityPermission", Some(&input)).await
    }
    /// Removes a role.
    /// 
    /// ***Required privileges:*** Authorization.ModifyRoles
    ///
    /// ## Parameters:
    ///
    /// ### role_id
    /// -
    ///
    /// ### fail_if_used
    /// If true, prevents the role from being
    /// removed if any permissions are using it.
    ///
    /// ## Errors:
    ///
    /// ***NotFound***: if the role does not exist.
    /// 
    /// ***InvalidArgument***: if the role is a system role, meaning it cannot be
    /// changed.
    /// 
    /// ***RemoveFailed***: if failIfUsed is true and the role has permissions.
    pub async fn remove_authorization_role(&self, role_id: i32, fail_if_used: bool) -> Result<()> {
        let input = RemoveAuthorizationRoleRequestType {role_id, fail_if_used, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "RemoveAuthorizationRole", Some(&input)).await
    }
    /// Update the entire set of permissions defined on an entity.
    /// 
    /// Any
    /// existing permissions on the entity are removed and replaced with the
    /// provided set.
    /// 
    /// If a permission is specified multiple times for the same user or group, the
    /// last permission specified takes effect.
    /// 
    /// The operation is transactional per permission and could partially fail. The
    /// updates are performed in the order of the permission array argument. The first
    /// failed update will abort the operation and throw the appropriate exception. When
    /// the operation aborts, any permissions that have not yet been removed are left in
    /// their original state.
    /// 
    /// After updates are applied, original permissions that are not in the new set
    /// are removed. A failure to remove a permission, such as a violation of
    /// the minimum administrator permission rule, will abort the operation and could
    /// leave remaining original permissions still effective on the entity.
    /// 
    /// This will fail with an InvalidArgument fault if called on: the direct child
    /// folders of a datacenter managed object, the root resource pool of a
    /// ComputeResource or ClusterComputeResource, or a HostSystem that is part of
    /// a ComputeResource (Stand-alone Host). These objects always have the same
    /// permissions as their parent.
    /// 
    /// This will fail with an InvalidArgument fault if called on a fault-tolerance (FT)
    /// secondary VirtualMachine. Such a VirtualMachine always has the same permissions
    /// as its FT primary VirtualMachine.
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// The entity on which permissions are updated.
    /// 
    /// ***Required privileges:*** Authorization.ModifyPermissions
    /// 
    /// Refers instance of *ManagedEntity*.
    ///
    /// ### permission
    /// The list of Permission objects that define
    /// the new rules for access to the entity and
    /// potentially entities below it. If the list
    /// is empty, all permissions on the entity are removed.
    ///
    /// ## Errors:
    ///
    /// ***ManagedObjectNotFound***: if the given entity does not exist.
    /// 
    /// ***UserNotFound***: if one of the given users or groups does not exist.
    /// 
    /// ***NotFound***: if a permission for this entity and user or group
    /// does not exist.
    /// 
    /// ***AuthMinimumAdminPermission***: if this change would leave the system with
    /// no Administrator permission on the root node, or it
    /// would grant further permission to a user or group who
    /// already has Administrator permission on the root node.
    /// 
    /// ***InvalidArgument***: if one of the new role IDs is the View or
    /// Anonymous role, or the entity does not support
    /// assigning permissions.
    /// 
    /// ***NoPermission***: if current session does not have any privilege
    /// in the updated permission or
    /// "Authorization.ModifyPermissions" privilege on
    /// the entity.
    pub async fn reset_entity_permissions(&self, entity: &crate::types::structs::ManagedObjectReference, permission: Option<&[crate::types::structs::Permission]>) -> Result<()> {
        let input = ResetEntityPermissionsRequestType {entity, permission, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "ResetEntityPermissions", Some(&input)).await
    }
    /// Finds all permissions defined in the system.
    /// 
    /// The result is restricted to the managed entities visible to the
    /// user making the call.
    /// 
    /// ***Required privileges:*** System.View
    pub async fn retrieve_all_permissions(&self) -> Result<Option<Vec<crate::types::structs::Permission>>> {
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "RetrieveAllPermissions", None).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Gets permissions defined on or effective on a managed entity.
    /// 
    /// This returns the actual permission objects defined in the system for all
    /// users and groups relative to the managed entity. The inherited
    /// flag specifies whether or not to include permissions defined by the
    /// parents of this entity that propagate to this entity.
    /// 
    /// For complex entities, the entity reported as defining the permission may
    /// be either the parent or a child entity belonging to the complex entity.
    /// 
    /// The purpose of this method is to discover permissions
    /// for administration purposes, not to determine the current
    /// permissions. The current user's permissions are found on the *ManagedEntity.effectiveRole* property of the user's ManagedEntity.
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// ***Required privileges:*** System.Read
    /// 
    /// Refers instance of *ManagedEntity*.
    ///
    /// ### inherited
    /// Whether or not to include propagating permissions
    /// defined by parent entities.
    pub async fn retrieve_entity_permissions(&self, entity: &crate::types::structs::ManagedObjectReference, inherited: bool) -> Result<Option<Vec<crate::types::structs::Permission>>> {
        let input = RetrieveEntityPermissionsRequestType {entity, inherited, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "RetrieveEntityPermissions", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Finds all the permissions that use a particular role.
    /// 
    /// The result is restricted to managed entities that are visible to the
    /// user making the call.
    /// 
    /// ***Required privileges:*** System.View
    ///
    /// ## Parameters:
    ///
    /// ### role_id
    /// -
    ///
    /// ## Errors:
    ///
    /// ***NotFound***: if the role does not exist.
    pub async fn retrieve_role_permissions(&self, role_id: i32) -> Result<Option<Vec<crate::types::structs::Permission>>> {
        let input = RetrieveRolePermissionsRequestType {role_id, };
        let bytes_opt = self.client.invoke_optional("", "AuthorizationManager", &self.mo_id, "RetrieveRolePermissions", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Defines one or more permission rules on an entity or updates rules if already
    /// present for the given user or group on the entity.
    /// 
    /// If a permission is specified multiple times for the same user or group, then the
    /// last permission specified takes effect.
    /// 
    /// The operation is applied transactionally per permission and is applied to the
    /// entity following the order of the elements in the permission array argument. This
    /// means that if a failure occurs, the method terminates at that point in the
    /// permission array with an exception, leaving at least one and as many as all
    /// permissions unapplied.
    /// 
    /// This will fail with an InvalidArgument fault if called on: the direct child
    /// folders of a datacenter managed object, the root resource pool of a
    /// ComputeResource or ClusterComputeResource, or a HostSystem that is part of
    /// a ComputeResource (Stand-alone Host). These objects always have the same
    /// permissions as their parent.
    /// 
    /// This will fail with an InvalidArgument fault if called on a fault-tolerance (FT)
    /// secondary VirtualMachine. Such a VirtualMachine always has the same permissions
    /// as its FT primary VirtualMachine.
    ///
    /// ## Parameters:
    ///
    /// ### entity
    /// The entity on which to set permissions.
    /// 
    /// ***Required privileges:*** Authorization.ModifyPermissions
    /// 
    /// Refers instance of *ManagedEntity*.
    ///
    /// ### permission
    /// An array of specifications for permissions on the entity.
    ///
    /// ## Errors:
    ///
    /// ***ManagedObjectNotFound***: if the given entity does not exist.
    /// 
    /// ***UserNotFound***: if a given user or group does not exist.
    /// 
    /// ***AuthMinimumAdminPermission***: if this change would leave the system with
    /// no Administrator permission on the root node, or it
    /// would grant further permission to a user or group who
    /// already has Administrator permission on the root node.
    /// 
    /// ***NotFound***: if a permission's roleId is not valid.
    /// 
    /// ***InvalidArgument***: if one of the new role IDs is the View or
    /// Anonymous role, or the entity does not support assigning
    /// permissions.
    /// 
    /// ***NoPermission***: if current session does not have any privilege
    /// in any permission that being set or
    /// "Authorization.ModifyPermissions" privilege on
    /// the entity.
    pub async fn set_entity_permissions(&self, entity: &crate::types::structs::ManagedObjectReference, permission: Option<&[crate::types::structs::Permission]>) -> Result<()> {
        let input = SetEntityPermissionsRequestType {entity, permission, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "SetEntityPermissions", Some(&input)).await
    }
    /// Updates a role's name or privileges.
    /// 
    /// If the new set of privileges are assigned to the role, the
    /// system-defined privileges, "System.Anonymous", "System.View",
    /// and "System.Read" will be assigned to the role too.
    /// This operation might return before the new privileges are effective.
    /// A timeout of 100 ms is possible, but it might vary depending on
    /// the configuration and the load of the system.
    /// 
    /// ***Required privileges:*** Authorization.ModifyRoles
    ///
    /// ## Parameters:
    ///
    /// ### role_id
    /// The ID of the role that is updated.
    ///
    /// ### new_name
    /// The new name for the role.
    ///
    /// ### priv_ids
    /// The new set of privileges to assign to the role.
    ///
    /// ## Errors:
    ///
    /// ***NotFound***: if the role does not exist, or if a privilege
    /// in the list cannot be found.
    /// 
    /// ***InvalidArgument***: if the role is a system role, meaning it cannot be
    /// changed.
    /// 
    /// ***InvalidName***: if the new role name is empty.
    /// 
    /// ***AlreadyExists***: if another role with the given name already exists.
    /// 
    /// ***NoPermission***: if current session does not have any privilege
    /// that being updated in the new role or
    /// "Authorization.ModifyRoles" privilege on the
    /// root folder.
    pub async fn update_authorization_role(&self, role_id: i32, new_name: &str, priv_ids: Option<&[String]>) -> Result<()> {
        let input = UpdateAuthorizationRoleRequestType {role_id, new_name, priv_ids, };
        self.client.invoke_void("", "AuthorizationManager", &self.mo_id, "UpdateAuthorizationRole", Some(&input)).await
    }
    /// Static, descriptive strings for system roles and privileges.
    /// 
    /// ***Required privileges:*** System.View
    pub async fn description(&self) -> Result<crate::types::structs::AuthorizationDescription> {
        let pv_opt = self.client.fetch_property_raw("", "AuthorizationManager", &self.mo_id, "description").await?;
        let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property description was empty".to_string()))?;
        let result: crate::types::structs::AuthorizationDescription = crate::core::client::extract_property(pv)?;
        Ok(result)
    }
    /// The list of system-defined privileges.
    /// 
    /// ***Required privileges:*** System.View
    pub async fn privilege_list(&self) -> Result<Option<Vec<crate::types::structs::AuthorizationPrivilege>>> {
        let pv_opt = self.client.fetch_property_raw("", "AuthorizationManager", &self.mo_id, "privilegeList").await?;
        match pv_opt {
            Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
            None => Ok(None),
        }
    }
    /// The currently defined roles in the system, including
    /// static system-defined roles.
    /// 
    /// ***Required privileges:*** System.View
    pub async fn role_list(&self) -> Result<Option<Vec<crate::types::structs::AuthorizationRole>>> {
        let pv_opt = self.client.fetch_property_raw("", "AuthorizationManager", &self.mo_id, "roleList").await?;
        match pv_opt {
            Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
            None => Ok(None),
        }
    }
}
struct AddAuthorizationRoleRequestType<'a> {
    name: &'a str,
    priv_ids: Option<&'a [String]>,
}

impl<'a> miniserde::Serialize for AddAuthorizationRoleRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(AddAuthorizationRoleRequestTypeSer { data: self, seq: 0 }))
    }
}

struct AddAuthorizationRoleRequestTypeSer<'b, 'a> {
    data: &'b AddAuthorizationRoleRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for AddAuthorizationRoleRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"AddAuthorizationRoleRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("name"), &self.data.name as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.priv_ids else { continue; };
                    return Some((std::borrow::Cow::Borrowed("privIds"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct FetchUserPrivilegeOnEntitiesRequestType<'a> {
    entities: &'a [crate::types::structs::ManagedObjectReference],
    user_name: &'a str,
}

impl<'a> miniserde::Serialize for FetchUserPrivilegeOnEntitiesRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(FetchUserPrivilegeOnEntitiesRequestTypeSer { data: self, seq: 0 }))
    }
}

struct FetchUserPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    data: &'b FetchUserPrivilegeOnEntitiesRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for FetchUserPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"FetchUserPrivilegeOnEntitiesRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("entities"), &self.data.entities as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("userName"), &self.data.user_name as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct HasPrivilegeOnEntitiesRequestType<'a> {
    entity: &'a [crate::types::structs::ManagedObjectReference],
    session_id: &'a str,
    priv_id: Option<&'a [String]>,
}

impl<'a> miniserde::Serialize for HasPrivilegeOnEntitiesRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(HasPrivilegeOnEntitiesRequestTypeSer { data: self, seq: 0 }))
    }
}

struct HasPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    data: &'b HasPrivilegeOnEntitiesRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for HasPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HasPrivilegeOnEntitiesRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
                2 => return Some((std::borrow::Cow::Borrowed("sessionId"), &self.data.session_id as &dyn miniserde::Serialize)),
                3 => {
                    let Some(ref val) = self.data.priv_id else { continue; };
                    return Some((std::borrow::Cow::Borrowed("privId"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct HasPrivilegeOnEntityRequestType<'a> {
    entity: &'a crate::types::structs::ManagedObjectReference,
    session_id: &'a str,
    priv_id: Option<&'a [String]>,
}

impl<'a> miniserde::Serialize for HasPrivilegeOnEntityRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(HasPrivilegeOnEntityRequestTypeSer { data: self, seq: 0 }))
    }
}

struct HasPrivilegeOnEntityRequestTypeSer<'b, 'a> {
    data: &'b HasPrivilegeOnEntityRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for HasPrivilegeOnEntityRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HasPrivilegeOnEntityRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
                2 => return Some((std::borrow::Cow::Borrowed("sessionId"), &self.data.session_id as &dyn miniserde::Serialize)),
                3 => {
                    let Some(ref val) = self.data.priv_id else { continue; };
                    return Some((std::borrow::Cow::Borrowed("privId"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct HasUserPrivilegeOnEntitiesRequestType<'a> {
    entities: &'a [crate::types::structs::ManagedObjectReference],
    user_name: &'a str,
    priv_id: Option<&'a [String]>,
}

impl<'a> miniserde::Serialize for HasUserPrivilegeOnEntitiesRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(HasUserPrivilegeOnEntitiesRequestTypeSer { data: self, seq: 0 }))
    }
}

struct HasUserPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    data: &'b HasUserPrivilegeOnEntitiesRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for HasUserPrivilegeOnEntitiesRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"HasUserPrivilegeOnEntitiesRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("entities"), &self.data.entities as &dyn miniserde::Serialize)),
                2 => return Some((std::borrow::Cow::Borrowed("userName"), &self.data.user_name as &dyn miniserde::Serialize)),
                3 => {
                    let Some(ref val) = self.data.priv_id else { continue; };
                    return Some((std::borrow::Cow::Borrowed("privId"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct MergePermissionsRequestType {
    src_role_id: i32,
    dst_role_id: i32,
}

impl miniserde::Serialize for MergePermissionsRequestType {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(MergePermissionsRequestTypeSer { data: self, seq: 0 }))
    }
}

struct MergePermissionsRequestTypeSer<'b> {
    data: &'b MergePermissionsRequestType,
    seq: usize,
}

impl<'b> miniserde::ser::Map for MergePermissionsRequestTypeSer<'b> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"MergePermissionsRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("srcRoleId"), &self.data.src_role_id as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("dstRoleId"), &self.data.dst_role_id as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RemoveEntityPermissionRequestType<'a> {
    entity: &'a crate::types::structs::ManagedObjectReference,
    user: &'a str,
    is_group: bool,
}

impl<'a> miniserde::Serialize for RemoveEntityPermissionRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RemoveEntityPermissionRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RemoveEntityPermissionRequestTypeSer<'b, 'a> {
    data: &'b RemoveEntityPermissionRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for RemoveEntityPermissionRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveEntityPermissionRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("user"), &self.data.user as &dyn miniserde::Serialize)),
            3 => return Some((std::borrow::Cow::Borrowed("isGroup"), &self.data.is_group as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RemoveAuthorizationRoleRequestType {
    role_id: i32,
    fail_if_used: bool,
}

impl miniserde::Serialize for RemoveAuthorizationRoleRequestType {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RemoveAuthorizationRoleRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RemoveAuthorizationRoleRequestTypeSer<'b> {
    data: &'b RemoveAuthorizationRoleRequestType,
    seq: usize,
}

impl<'b> miniserde::ser::Map for RemoveAuthorizationRoleRequestTypeSer<'b> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RemoveAuthorizationRoleRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("roleId"), &self.data.role_id as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("failIfUsed"), &self.data.fail_if_used as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct ResetEntityPermissionsRequestType<'a> {
    entity: &'a crate::types::structs::ManagedObjectReference,
    permission: Option<&'a [crate::types::structs::Permission]>,
}

impl<'a> miniserde::Serialize for ResetEntityPermissionsRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(ResetEntityPermissionsRequestTypeSer { data: self, seq: 0 }))
    }
}

struct ResetEntityPermissionsRequestTypeSer<'b, 'a> {
    data: &'b ResetEntityPermissionsRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for ResetEntityPermissionsRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ResetEntityPermissionsRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.permission else { continue; };
                    return Some((std::borrow::Cow::Borrowed("permission"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct RetrieveEntityPermissionsRequestType<'a> {
    entity: &'a crate::types::structs::ManagedObjectReference,
    inherited: bool,
}

impl<'a> miniserde::Serialize for RetrieveEntityPermissionsRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RetrieveEntityPermissionsRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RetrieveEntityPermissionsRequestTypeSer<'b, 'a> {
    data: &'b RetrieveEntityPermissionsRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for RetrieveEntityPermissionsRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RetrieveEntityPermissionsRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("inherited"), &self.data.inherited as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RetrieveRolePermissionsRequestType {
    role_id: i32,
}

impl miniserde::Serialize for RetrieveRolePermissionsRequestType {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RetrieveRolePermissionsRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RetrieveRolePermissionsRequestTypeSer<'b> {
    data: &'b RetrieveRolePermissionsRequestType,
    seq: usize,
}

impl<'b> miniserde::ser::Map for RetrieveRolePermissionsRequestTypeSer<'b> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        let seq = self.seq;
        self.seq += 1;
        match seq {
            0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RetrieveRolePermissionsRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("roleId"), &self.data.role_id as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct SetEntityPermissionsRequestType<'a> {
    entity: &'a crate::types::structs::ManagedObjectReference,
    permission: Option<&'a [crate::types::structs::Permission]>,
}

impl<'a> miniserde::Serialize for SetEntityPermissionsRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(SetEntityPermissionsRequestTypeSer { data: self, seq: 0 }))
    }
}

struct SetEntityPermissionsRequestTypeSer<'b, 'a> {
    data: &'b SetEntityPermissionsRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for SetEntityPermissionsRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"SetEntityPermissionsRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("entity"), &self.data.entity as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.permission else { continue; };
                    return Some((std::borrow::Cow::Borrowed("permission"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct UpdateAuthorizationRoleRequestType<'a> {
    role_id: i32,
    new_name: &'a str,
    priv_ids: Option<&'a [String]>,
}

impl<'a> miniserde::Serialize for UpdateAuthorizationRoleRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(UpdateAuthorizationRoleRequestTypeSer { data: self, seq: 0 }))
    }
}

struct UpdateAuthorizationRoleRequestTypeSer<'b, 'a> {
    data: &'b UpdateAuthorizationRoleRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for UpdateAuthorizationRoleRequestTypeSer<'b, 'a> {
    fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
        loop {
            let seq = self.seq;
            self.seq += 1;
            match seq {
                0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateAuthorizationRoleRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("roleId"), &self.data.role_id as &dyn miniserde::Serialize)),
                2 => return Some((std::borrow::Cow::Borrowed("newName"), &self.data.new_name as &dyn miniserde::Serialize)),
                3 => {
                    let Some(ref val) = self.data.priv_ids else { continue; };
                    return Some((std::borrow::Cow::Borrowed("privIds"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}