Skip to content

Commit

Permalink
fix for changing base URL for Get-Flow (#3677)
Browse files Browse the repository at this point in the history
* fix for changing base url for Get-Flow

* Update GetFlow.cs

---------

Co-authored-by: Gautam Sheth <gautamdsheth@outlook.com>
  • Loading branch information
siddharth-vaghasia and gautamdsheth authored Jan 9, 2024
1 parent f9cf2f4 commit 9246528
Showing 1 changed file with 6 additions and 5 deletions.
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);

}
}
}
}
}

0 comments on commit 9246528

Please sign in to comment.