Skip to content

Commit 806105f

Browse files
authored
Refactor SPOTenant class: remove unused using directive and add new properties for security group management and sensitivity labels (#5110)
1 parent cda45fd commit 806105f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/Commands/Model/SPOTenant.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System;
99
using System.Collections.Generic;
1010
using System.Linq;
11-
using System.Management.Automation;
1211
using System.Reflection;
1312

1413
namespace PnP.PowerShell.Commands.Model
@@ -316,25 +315,39 @@ public class SPOTenant
316315

317316
public bool? ContentSecurityPolicyEnforcement { private set; get; }
318317

318+
public List<string> AllowSelectSecurityGroupsInSPSitesList { private set; get; }
319+
320+
public List<string> DenySelectSecurityGroupsInSPSitesList { private set; get; }
321+
322+
public List<string> AllowSelectSGsInODBListInTenant { private set; get; }
323+
324+
public List<string> DenySelectSGsInODBListInTenant { private set; get; }
325+
326+
public List<string> WhoCanShareAnonymousAllowList { private set; get; }
327+
328+
public List<string> WhoCanShareAuthenticatedGuestAllowList { private set; get; }
329+
public bool? EnableSensitivityLabelForOneNote { private set; get; }
330+
public bool? EnableSensitivityLabelForVideoFiles { private set; get; }
331+
319332
#endregion
320333

321334
public SPOTenant(Tenant tenant, ClientContext clientContext, BasePSCmdlet cmdlet)
322335
{
323336
// Loop through all properties defined in this class and load the corresponding property from the Tenant object
324337
var properties = GetType().GetProperties();
325338
var failedProperties = 0;
326-
foreach(var property in properties)
339+
foreach (var property in properties)
327340
{
328341
var propertyName = property.Name;
329342

330343
try
331344
{
332345
// Check if the property has a CsomToModelConverter attribute, if so use the PropertyName defined in the attribute instead of looking for a property with the same name on the Tenant object
333-
if(property.IsDefined(typeof(CsomToModelConverter)))
346+
if (property.IsDefined(typeof(CsomToModelConverter)))
334347
{
335348
var converter = property.GetCustomAttribute<CsomToModelConverter>();
336349

337-
if(converter.Skip) continue;
350+
if (converter.Skip) continue;
338351
propertyName = converter.PropertyName;
339352
}
340353
var tenantProperty = tenant.GetType().GetProperty(propertyName);
@@ -343,7 +356,7 @@ public SPOTenant(Tenant tenant, ClientContext clientContext, BasePSCmdlet cmdlet
343356
property.SetValue(this, tenantProperty.GetValue(tenant));
344357
}
345358
}
346-
catch(Exception e)
359+
catch (Exception e)
347360
{
348361
failedProperties++;
349362
cmdlet.LogDebug($"Property {propertyName} not loaded due to error '{e.Message}'");
@@ -360,7 +373,7 @@ public SPOTenant(Tenant tenant, ClientContext clientContext, BasePSCmdlet cmdlet
360373
AllowFilesWithKeepLabelToBeDeletedSPO = getAllowFilesWithKeepLabelToBeDeletedSPO.Value;
361374
AllowFilesWithKeepLabelToBeDeletedODB = getAllowFilesWithKeepLabelToBeDeletedODB.Value;
362375
}
363-
catch(Exception e)
376+
catch (Exception e)
364377
{
365378
failedProperties++;
366379
cmdlet.LogDebug($"Property AllowFilesWithKeepLabelToBeDeletedSPO and/or AllowFilesWithKeepLabelToBeDeletedODB not loaded due to error '{e.Message}'");
@@ -371,14 +384,14 @@ public SPOTenant(Tenant tenant, ClientContext clientContext, BasePSCmdlet cmdlet
371384
{
372385
DefaultOneDriveInformationBarrierMode = Enum.Parse<Enums.InformationBarriersMode>(tenant.DefaultODBMode);
373386
}
374-
catch(Exception e)
387+
catch (Exception e)
375388
{
376389
failedProperties++;
377390
cmdlet.LogDebug($"Property DefaultOneDriveInformationBarrierMode not loaded due to error '{e.Message}'");
378391
}
379392

380393
// If one or more properties failed to load, show a warning
381-
if(failedProperties > 0)
394+
if (failedProperties > 0)
382395
{
383396
cmdlet.LogWarning($"Failed to load {(failedProperties != 1 ? $"{failedProperties} properties" : "one property")}. Use -Verbose to see the details.");
384397
}

0 commit comments

Comments
 (0)