Skip to content

Commit

Permalink
Additional tenant settings from api/SPOInternalUseOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
reshmee011 committed Apr 21, 2024
1 parent 73d3ff3 commit 2bf633e
Showing 1 changed file with 149 additions and 1 deletion.
150 changes: 149 additions & 1 deletion src/Commands/Model/SPOTenant.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.Online.SharePoint.TenantManagement;
using Microsoft.SharePoint.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using InformationBarriersMode = PnP.PowerShell.Commands.Enums.InformationBarriersMode;

namespace PnP.PowerShell.Commands.Model
Expand Down Expand Up @@ -195,9 +197,32 @@ public class SPOTenant

public InformationBarriersMode? DefaultOneDriveInformationBarrierMode { private set; get; }

public bool SitePagesEnabled { private set; get; }
public bool DisableSelfServiceSiteCreation { private set; get; }
public bool EnableAutoNewsDigest { private set;get; }
public string CustomFormUrl { private set; get; }
public bool AutoQuotaEnabled { get; private set; }
public bool DisableGroupify { get; private set; }
public bool IncludeAtAGlanceInShareEmails { get; private set; }
public string MailFromAddress { get; private set; }
public bool MobileNotificationIsEnabledForSharepoint { get; private set; }
public string NewSiteManagedPath { get; private set; }
public bool NewSubsiteInModernOffForAll { get; private set; }
public bool NewSubsiteInModernOffForModernTemplates { get; private set; }
public string NewTeamSiteManagedPath { get; private set; }
public string ParentSiteUrl { get; private set; }
public string PolicyOption { get; private set; }
public bool RequireSecondaryContact { get; private set; }
public bool ShowSelfServiceSiteCreation { get; private set; }
public int SiteCreationDefaultStorageQuota { get; private set; }
public bool SiteCreationNewUX { get; private set; }
public string SmtpServer { get; private set; }
public bool SPListModernUXOff { get; private set; }
public int TenantDefaultTimeZoneId { get; private set; }
public string[] AvailableManagedPathsForSiteCreation { get; private set; }
#endregion

public SPOTenant(Tenant tenant, ClientContext clientContext)
public SPOTenant(Tenant tenant, ClientContext clientContext)
{
HideDefaultThemes = tenant.HideDefaultThemes;
StorageQuota = tenant.StorageQuota;
Expand Down Expand Up @@ -709,6 +734,129 @@ public SPOTenant(Tenant tenant, ClientContext clientContext)
catch
{
}

try
{
var httpClient = PnP.Framework.Http.PnPHttpClient.Instance.GetHttpClient(clientContext);
var tenantInternalSettings = Utilities.REST.RestHelper.GetAsync<SPOTenantInternalSettings>(httpClient, $"{clientContext.Url}_api/SPOInternalUseOnly.TenantAdminSettings", clientContext.GetAccessToken(),false).GetAwaiter().GetResult();

SitePagesEnabled = tenantInternalSettings.SitePagesEnabled.Value;
DisableSelfServiceSiteCreation = tenantInternalSettings.DisableSelfServiceSiteCreation.Value;
EnableAutoNewsDigest = tenantInternalSettings.EnableAutoNewsDigest.Value;
CustomFormUrl = tenantInternalSettings.CustomFormUrl.Value;
AutoQuotaEnabled = tenantInternalSettings.AutoQuotaEnabled.Value;
DisableGroupify = tenantInternalSettings.DisableGroupify.Value;
IncludeAtAGlanceInShareEmails = tenantInternalSettings.IncludeAtAGlanceInShareEmails.Value;
MailFromAddress = tenantInternalSettings.MailFromAddress.Value;
MobileNotificationIsEnabledForSharepoint = tenantInternalSettings.MobileNotificationIsEnabledForSharepoint.Value;
NewSiteManagedPath = tenantInternalSettings.NewSiteManagedPath.Value;
NewSubsiteInModernOffForAll = tenantInternalSettings.NewSubsiteInModernOffForAll.Value;
NewSubsiteInModernOffForModernTemplates = tenantInternalSettings.NewSubsiteInModernOffForModernTemplates.Value;
NewTeamSiteManagedPath = tenantInternalSettings.NewTeamSiteManagedPath.Value;
ParentSiteUrl = tenantInternalSettings.ParentSiteUrl.Value;
PolicyOption = tenantInternalSettings.PolicyOption.Value;
RequireSecondaryContact = tenantInternalSettings.RequireSecondaryContact.Value;
ShowSelfServiceSiteCreation = tenantInternalSettings.ShowSelfServiceSiteCreation.Value;
SiteCreationNewUX = tenantInternalSettings.SiteCreationNewUX.Value;
SmtpServer = tenantInternalSettings.SmtpServer.Value;
SPListModernUXOff = tenantInternalSettings.SPListModernUXOff.Value;
TenantDefaultTimeZoneId = tenantInternalSettings.TenantDefaultTimeZoneId.Value;
AvailableManagedPathsForSiteCreation = tenantInternalSettings.AvailableManagedPathsForSiteCreation;
}
catch
{
}
}
}

public class SPOTenantInternalSettings
{
[JsonProperty("AutoQuotaEnabled")]
public ReadOnlyBool AutoQuotaEnabled { get; set; }

[JsonProperty("AvailableManagedPathsForSiteCreation")]
public string[] AvailableManagedPathsForSiteCreation { get; set; }

[JsonProperty("IncludeAtAGlanceInShareEmails")]
public ReadOnlyBool IncludeAtAGlanceInShareEmails { get; set; }

[JsonProperty("MailFromAddress")]
public ReadOnlyString MailFromAddress { get; set; }

[JsonProperty("MobileNotificationIsEnabledForSharepoint")]
public ReadOnlyBool MobileNotificationIsEnabledForSharepoint { get; set; }

[JsonProperty("NewSiteManagedPath")]
public ReadOnlyString NewSiteManagedPath { get; set; }

[JsonProperty("ParentSiteUrl")]
public ReadOnlyString ParentSiteUrl { get; set; }

[JsonProperty("PolicyOption")]
public ReadOnlyString PolicyOption { get; set; }

[JsonProperty("RequireSecondaryContact")]
public ReadOnlyBool RequireSecondaryContact { get; set; }

[JsonProperty("ShowSelfServiceSiteCreation")]
public ReadOnlyBool ShowSelfServiceSiteCreation { get; set; }

[JsonProperty("SiteCreationNewUX")]
public ReadOnlyBool SiteCreationNewUX { get; set; }

[JsonProperty("SmtpServer")]
public ReadOnlyString SmtpServer { get; set; }

[JsonProperty("SPListModernUXOff")]
public ReadOnlyBool SPListModernUXOff { get; set; }

[JsonProperty("TenantDefaultTimeZoneId")]
public ReadOnlyInt TenantDefaultTimeZoneId { get; set; }

[JsonProperty("SitePagesEnabled")]
public ReadOnlyBool SitePagesEnabled { get; set; }

[JsonProperty("DisableGroupify")]
public ReadOnlyBool DisableGroupify { get; set; }

[JsonProperty("CustomFormUrl")]
public ReadOnlyString CustomFormUrl { get; set; }

[JsonProperty("EnableAutoNewsDigest")]
public ReadOnlyBool EnableAutoNewsDigest { get; set; }

[JsonProperty("DisableSelfServiceSiteCreation")]
public ReadOnlyBool DisableSelfServiceSiteCreation { get; set; }

[JsonProperty("NewSubsiteInModernOffForAll")]
public ReadOnlyBool NewSubsiteInModernOffForAll { get; set; }
[JsonProperty("NewSubsiteInModernOffForModernTemplates")]
public ReadOnlyBool NewSubsiteInModernOffForModernTemplates { get; set; }
[JsonProperty("NewTeamSiteManagedPath")]
public ReadOnlyString NewTeamSiteManagedPath { get; set; }
}
public class ReadOnlyBool
{
[JsonProperty("IsReadOnly")]
public bool IsReadOnly { get; set; }

[JsonProperty("Value")]
public bool Value { get; set; }
}
public class ReadOnlyInt
{
[JsonProperty("IsReadOnly")]
public bool IsReadOnly { get; set; }

[JsonProperty("Value")]
public int Value { get; set; }
}
public class ReadOnlyString
{
[JsonProperty("IsReadOnly")]
public bool IsReadOnly { get; set; }

[JsonProperty("Value")]
public string Value { get; set; }
}
}

0 comments on commit 2bf633e

Please sign in to comment.