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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// A singleton managed object for managing vCenter tenants.
#[derive(Clone)]
pub struct TenantTenantManager {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl TenantTenantManager {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Define a set of ManagedEntity objects as used for tenant management.
///
/// Those entities are a starting point of an inventory hierarchy
/// (sub-tree) that functionally exists in the tenant's inventory but are
/// owned by the system user of the vCenter Server.
/// The operations which the tenant may perform on these objects depend
/// on the permissions granted to the tenant by the SaaS provisioning
/// layer.
/// Permissions that the tenant may create on the parent objects of the
/// management entities do not propagate to the hierarchies of
/// management entities and thus have no effect on them.
/// This operation will fail for all the entities if any of them does
/// not exist.
/// The method behaviour is transactional - either all entities are
/// marked or none if an error occurs while processing them.
/// The user calling this method should hold TenantManager.Update on the
/// root folder and TenantManager.Update on each entity currently
/// being marked as a service provider one. These are strict privilege
/// requirements allowing only administrators to call the method.
///
/// ***Required privileges:*** TenantManager.Update
///
/// ## Parameters:
///
/// ### entity
/// an array of management entities.
///
/// ***Required privileges:*** TenantManager.Update
///
/// Refers instances of *ManagedEntity*.
///
/// ## Errors:
///
/// ***ManagedObjectNotFound***: if any of the entities doesn't exist.
///
/// ***AuthMinimumAdminPermission***: if this change will leave the
/// system with no Administrator permission on the root folder
/// of the service provider inventory.
pub async fn mark_service_provider_entities(&self, entity: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<()> {
let input = MarkServiceProviderEntitiesRequestType {entity, };
self.client.invoke_void("", "TenantTenantManager", &self.mo_id, "MarkServiceProviderEntities", Some(&input)).await
}
/// Retrieves the list of tenant management entities.
///
/// ***Required privileges:*** TenantManager.Query
///
/// ## Returns:
///
/// the array of tenant management resources.
///
/// Refers instances of *ManagedEntity*.
pub async fn retrieve_service_provider_entities(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let bytes_opt = self.client.invoke_optional("", "TenantTenantManager", &self.mo_id, "RetrieveServiceProviderEntities", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// Resets the management type of an array of ManagedEntity objects.
///
/// This operation will fail if any of the entities does not exist.
/// The method behaviour is transactional - either all entities are
/// unmarked or none if an error occurs while processing them.
/// The user calling this method should hold TenantManager.Update on the
/// root folder and TenantManager.Update on each entity currently
/// being unmarked as a service provider one. These are strict privilege
/// requirements allowing only administrators to call the method.
///
/// ***Required privileges:*** TenantManager.Update
///
/// ## Parameters:
///
/// ### entity
/// an array of management entities.
///
/// ***Required privileges:*** TenantManager.Update
///
/// Refers instances of *ManagedEntity*.
///
/// ## Errors:
///
/// ***ManagedObjectNotFound***: if any of the entities doesn't exist.
pub async fn unmark_service_provider_entities(&self, entity: Option<&[crate::types::structs::ManagedObjectReference]>) -> Result<()> {
let input = UnmarkServiceProviderEntitiesRequestType {entity, };
self.client.invoke_void("", "TenantTenantManager", &self.mo_id, "UnmarkServiceProviderEntities", Some(&input)).await
}
}
struct MarkServiceProviderEntitiesRequestType<'a> {
entity: Option<&'a [crate::types::structs::ManagedObjectReference]>,
}
impl<'a> miniserde::Serialize for MarkServiceProviderEntitiesRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(MarkServiceProviderEntitiesRequestTypeSer { data: self, seq: 0 }))
}
}
struct MarkServiceProviderEntitiesRequestTypeSer<'b, 'a> {
data: &'b MarkServiceProviderEntitiesRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for MarkServiceProviderEntitiesRequestTypeSer<'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"), &"MarkServiceProviderEntitiesRequestType")),
1 => {
let Some(ref val) = self.data.entity else { continue; };
return Some((std::borrow::Cow::Borrowed("entity"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct UnmarkServiceProviderEntitiesRequestType<'a> {
entity: Option<&'a [crate::types::structs::ManagedObjectReference]>,
}
impl<'a> miniserde::Serialize for UnmarkServiceProviderEntitiesRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(UnmarkServiceProviderEntitiesRequestTypeSer { data: self, seq: 0 }))
}
}
struct UnmarkServiceProviderEntitiesRequestTypeSer<'b, 'a> {
data: &'b UnmarkServiceProviderEntitiesRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for UnmarkServiceProviderEntitiesRequestTypeSer<'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"), &"UnmarkServiceProviderEntitiesRequestType")),
1 => {
let Some(ref val) = self.data.entity else { continue; };
return Some((std::borrow::Cow::Borrowed("entity"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}