Skip to content

Commit

Permalink
Merge branch 'dev' into add-information-barriers
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamdsheth authored Jan 19, 2024
2 parents 23477ed + f71a986 commit 3e4bd41
Show file tree
Hide file tree
Showing 23 changed files with 4,895 additions and 4,877 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed

- Fixed `Grant-PnPAzureADAppSitePermission` cmdlet which allows it to work in multi-geo environment. [#3658](https://github.com/pnp/powershell/pull/3658)
- Fixed `Get-PnPTeamsChannelMessageReply` cmdlet which didn't work correctly when `-IncludeDeleted` parameter was not specified. [#3676](https://github.com/pnp/powershell/pull/3676)
- Fixed `Add-PnPNavigationNode` cmdlet to also search for nodes in child navigation items. [#3625](https://github.com/pnp/powershell/pull/3625)
- Fixed `Get-PnPFlow` cmdlet to use the newer Flow URLs instead of the old ARM URLs. [#3677](https://github.com/pnp/powershell/pull/3677)
- Fixed `Get-PnPPowerPlatformConnector`, `Get-PnPPowerPlatformEnvironment`, `Get-PnPPowerApp`, `Add-PnPFlowOwner`, `Disable-PnPFlow`, `Enable-PnPFlow`, `Export-PnPFlow`, `Get-PnPFlowOwner`, `Get-PnPFlowRun`, `Remove-PnPFlow`, `Remove-PnPFlowOwner` , `Restart-PnPFlow` and `Stop-PnPFlowRun` cmdlets to use the new HTTP endpoints. [#3687](https://github.com/pnp/powershell/pull/3687)

### Contributors

- Kunj Balkrishna Sangani [kunj-sangani]
- Koen Zomers [koenzomers]
- Reshmee Auckloo [reshme011]
- Nishkalank Bezawada [NishkalankBezawada]
- Jørgen Wiik [joHKwi]
- Siddharth Vaghasia [siddharth-vaghasia]
- Jürgen Rosenthal-Buroh [JuergenRB]

## [2.3.0]

Expand Down
2 changes: 1 addition & 1 deletion pnppowershell_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21f6b9e0c35e96eb2e0822046d18bf88074423ce
ab0653e7afde0c98b396e659bfdbf1362b93b8cc
9,678 changes: 4,839 additions & 4,839 deletions resources/predictor/PnP.PowerShell.Suggestions.nightly.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Commands/Model/SharePoint/NavigationNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class NavigationNode
public bool IsHidden { get; set; }
public bool IsTitleForExistingLanguage { get; set; }
public string Key { get; set; }
public List<object> Nodes { get; set; }
public List<NavigationNode> Nodes { get; set; }
public int NodeType { get; set; }
public bool? OpenInNewWindow { get; set; }
public string SimpleUrl { get; set; }
Expand Down
14 changes: 13 additions & 1 deletion src/Commands/Navigation/AddNavigationNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ protected override void ExecuteCmdlet()
CurrentWeb.EnsureProperties(w => w.Url);
var menuState = Utilities.REST.RestHelper.GetAsync<Model.SharePoint.NavigationNodeCollection>(Connection.HttpClient, $"{CurrentWeb.Url}/_api/navigation/MenuState", ClientContext.GetAccessToken(), false).GetAwaiter().GetResult();

var currentItem = menuState?.Nodes?.Where(t => t.Key == addedNode.Id.ToString()).FirstOrDefault();
var currentItem = menuState?.Nodes?.Select(node => SearchNodeById(node, addedNode.Id))
.FirstOrDefault(result => result != null);
if (currentItem != null)
{
currentItem.OpenInNewWindow = OpenInNewTab.ToBool();
Expand All @@ -150,5 +151,16 @@ protected override void ExecuteCmdlet()
throw new Exception("Unable to define Navigation Node collection to add the node to");
}
}

private static Model.SharePoint.NavigationNode SearchNodeById(Model.SharePoint.NavigationNode root, int id)
{
if (root.Key == id.ToString())
{
return root;
}

return root.Nodes.Select(child => SearchNodeById(child, id)).FirstOrDefault(result => result != null);
}

}
}
4 changes: 2 additions & 2 deletions src/Commands/PnP.PowerShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<CopyRefAssembliesToPublishDirectory>true</CopyRefAssembliesToPublishDirectory>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<Authors>PnP.PowerShell</Authors>
<Copyright>PnP 2023</Copyright>
<Copyright>PnP 2024</Copyright>
<Configurations>Debug;Release</Configurations>
<PnPFrameworkPath Condition="'$(PnPFrameworkPath)' == ''"></PnPFrameworkPath>
<PnPCoreSdkPath Condition="'$(PnPCoreSdkPath)' == ''"></PnPCoreSdkPath>
Expand Down Expand Up @@ -58,7 +58,7 @@
<PackageReference Include="Microsoft.Graph" Version="3.33.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.50.0" />
<PackageReference Include="Microsoft.SharePointOnline.CSOM" Version="16.1.*" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.27.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
<PackageReference Include="PnP.Framework" Version="1.14.*-*" Condition="'$(PnPFrameworkPath)' == '' and '$(IsRelease)' != '1'" />
<PackageReference Include="PnP.Framework" Version="1.14.*-*" Condition="'$(IsRelease)' == '1'" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ public class GetPowerPlatformConnector : PnPAzureManagementApiCmdlet
protected override void ExecuteCmdlet()
{
string environmentName = null;
string baseUrl = "https://api.flow.microsoft.com/";
if (ParameterSpecified(nameof(Environment)))
{
environmentName = Environment.GetName();
WriteVerbose($"Using environment as provided '{environmentName}'");
}
else
{
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, baseUrl + "/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
environmentName = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Name;

if (string.IsNullOrEmpty(environmentName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class GetPowerPlatformEnvironment : PnPAzureManagementApiCmdlet

protected override void ExecuteCmdlet()
{
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
string baseUrl = "https://api.flow.microsoft.com/";
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, baseUrl + "/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();

if(ParameterSpecified(nameof(IsDefault)) && IsDefault.ToBool())
{
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/PowerPlatform/PowerApps/GetPowerApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected override void ExecuteCmdlet()
}
else
{
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
string baseUrl = "https://api.flow.microsoft.com/";
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, baseUrl + "/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
environmentName = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Name;

if(string.IsNullOrEmpty(environmentName))
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/PowerPlatform/PowerAutomate/AddFlowOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override void ExecuteCmdlet()
};

WriteVerbose($"Assigning user {Role} permissions to flow {flowName} in environment {environmentName}");
RestHelper.PostAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/modifyPermissions?api-version=2016-11-01", AccessToken, payload).GetAwaiter().GetResult();
RestHelper.PostAsync(Connection.HttpClient, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/modifyPermissions?api-version=2016-11-01", AccessToken, payload).GetAwaiter().GetResult();
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/PowerPlatform/PowerAutomate/DisableFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void ExecuteCmdlet()
{
var environmentName = Environment.GetName();
var flowName = Identity.GetName();
RestHelper.PostAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/stop?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
RestHelper.PostAsync(Connection.HttpClient, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/stop?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/PowerPlatform/PowerAutomate/EnableFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void ExecuteCmdlet()
{
var environmentName = Environment.GetName();
var flowName = Identity.GetName();
RestHelper.PostAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/start?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
RestHelper.PostAsync(Connection.HttpClient, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/start?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/PowerPlatform/PowerAutomate/ExportFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected override void ExecuteCmdlet()
}
else
{
var json = RestHelper.PostAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/exportToARMTemplate?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var json = RestHelper.PostAsync(Connection.HttpClient, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/exportToARMTemplate?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteObject(json);
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/Commands/PowerPlatform/PowerAutomate/GetFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ public class GetFlow : PnPAzureManagementApiCmdlet
protected override void ExecuteCmdlet()
{
string environmentName = null;
if(ParameterSpecified(nameof(Environment)))
string baseUrl = "https://api.flow.microsoft.com/";
if (ParameterSpecified(nameof(Environment)))
{
environmentName = Environment.GetName();

WriteVerbose($"Using environment as provided '{environmentName}'");
}
else
{
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var environments = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.Environment.Environment>(Connection, baseUrl + "/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
environmentName = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Name;

if(string.IsNullOrEmpty(environmentName))
Expand All @@ -56,7 +57,7 @@ protected override void ExecuteCmdlet()

WriteVerbose($"Retrieving specific Power Automate Flow with the provided name '{flowName}' within the environment '{environmentName}'");

var result = GraphHelper.GetAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var result = GraphHelper.GetAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, baseUrl + $"providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteObject(result, false);
}
else
Expand All @@ -79,10 +80,10 @@ protected override void ExecuteCmdlet()

WriteVerbose($"Retrieving all Power Automate Flows within environment '{environmentName}'{(filter != null ? $" with filter '{filter}'" : "")}");

var flows = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows?api-version=2016-11-01{(filter != null ? $"&$filter={filter}" : "")}", AccessToken).GetAwaiter().GetResult();
var flows = GraphHelper.GetResultCollectionAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, baseUrl + $"providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows?api-version=2016-11-01{(filter != null ? $"&$filter={filter}" : "")}", AccessToken).GetAwaiter().GetResult();
WriteObject(flows, true);

}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/PowerPlatform/PowerAutomate/GetFlowOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override void ExecuteCmdlet()
throw new PSArgumentException("Flow not found.", nameof(Identity));
}

var flowOwners = GraphHelper.GetResultCollectionAsync<FlowPermission>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/permissions?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var flowOwners = GraphHelper.GetResultCollectionAsync<FlowPermission>(Connection, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/permissions?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteObject(flowOwners, true);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Commands/PowerPlatform/PowerAutomate/GetFlowRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class GetFlowRun : PnPAzureManagementApiCmdlet

protected override void ExecuteCmdlet()
{
string baseUrl = "https://api.flow.microsoft.com/";
var environmentName = Environment.GetName();
if (string.IsNullOrEmpty(environmentName))
{
Expand All @@ -35,12 +36,12 @@ protected override void ExecuteCmdlet()
if (ParameterSpecified(nameof(Identity)))
{
var flowRunName = Identity.GetName();
var flowRun = GraphHelper.GetAsync<FlowRun>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/runs/{flowRunName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var flowRun = GraphHelper.GetAsync<FlowRun>(Connection, baseUrl + $"providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/runs/{flowRunName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteObject(flowRun, false);
}
else
{
var flowRuns = GraphHelper.GetResultCollectionAsync<FlowRun>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/runs?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var flowRuns = GraphHelper.GetResultCollectionAsync<FlowRun>(Connection, baseUrl + $"providers/Microsoft.ProcessSimple/environments/{environmentName}/flows/{flowName}/runs?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteObject(flowRuns, true);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/Commands/PowerPlatform/PowerAutomate/RemoveFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class RemoveFlow : PnPAzureManagementApiCmdlet

protected override void ExecuteCmdlet()
{
string baseUrl = "https://api.flow.microsoft.com/";
var environmentName = Environment.GetName();
var flowName = Identity.GetName();

Expand All @@ -38,10 +39,10 @@ protected override void ExecuteCmdlet()
{
// Had to add this because DELETE doesn't throw error if invalid Flow Id or Name is provided
WriteVerbose($"Retrieving Flow with name {flowName} in environment ${environmentName}");
var result = GraphHelper.GetAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
var result = GraphHelper.GetAsync<Model.PowerPlatform.PowerAutomate.Flow>(Connection, baseUrl + $"providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
if (result != null)
{
RestHelper.DeleteAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
RestHelper.DeleteAsync(Connection.HttpClient, baseUrl + $"providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteVerbose($"Flow with name {flowName} deleted");
}
}
Expand All @@ -52,7 +53,7 @@ protected override void ExecuteCmdlet()
}
else
{
RestHelper.DeleteAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
RestHelper.DeleteAsync(Connection.HttpClient, baseUrl + $"providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult();
WriteVerbose($"Flow with name {flowName} deleted");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected override void ExecuteCmdlet()
if(Force || ShouldContinue($"Remove flow owner with id '{user.Id.Value}' from flow '{flowName}'?", "Remove flow owner"))
{
WriteVerbose($"Removing user {user.Id.Value} permissions from flow {flowName} in environment {environmentName}");
RestHelper.PostAsync(Connection.HttpClient, $"https://management.azure.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/modifyPermissions?api-version=2016-11-01", AccessToken, payload).GetAwaiter().GetResult();
RestHelper.PostAsync(Connection.HttpClient, $"https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple{(AsAdmin ? "/scopes/admin" : "")}/environments/{environmentName}/flows/{flowName}/modifyPermissions?api-version=2016-11-01", AccessToken, payload).GetAwaiter().GetResult();
}
}
}
Expand Down
Loading

0 comments on commit 3e4bd41

Please sign in to comment.