From beacc58a7958caa303857fde44eea4ef2b82f798 Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 17:06:16 +0000 Subject: [PATCH 1/7] Fix paging --- .../GetAzureLogicAppRunHistoryCommand.cs | 21 +++++++++++++++++-- .../Utilities/LogicAppClientRunOperations.cs | 11 ++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs index 8d5fa25b8419..c97f950faa06 100644 --- a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs +++ b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs @@ -45,6 +45,14 @@ public class AzureLogicAppRunHistoryCommand : LogicAppBaseCmdlet [ValidateNotNullOrEmpty] public string RunName { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow relation links.", + ParameterSetName = "FollowRelLink")] + public SwitchParameter FollowRelLink { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow relation links if FollowRelLink is used.", + ParameterSetName = "FollowRelLink")] + public int MaximumFollowRelLink { get; set; } = int.MaxValue; + #endregion Input Parameters /// @@ -55,8 +63,17 @@ public override void ExecuteCmdlet() base.ExecuteCmdlet(); if (string.IsNullOrEmpty(this.RunName)) { - var enumerator = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name).GetEnumerator(); - this.WriteObject(enumerator.ToIEnumerable(), true); + Page page = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name); + this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); + + if (FollowRelLink && !string.IsNullOrWhiteSpace(page.NextPageLink)) + { + for (int i = 0; i < MaximumFollowRelLink; i++) + { + page = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name, page.NextPageLink); + this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); + } + } } else { diff --git a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs index 63a7c5a23bab..649e5b81459e 100644 --- a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs +++ b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs @@ -40,9 +40,16 @@ public void CancelWorkflowRun(string resourceGroupName, string workflowName, /// Name of the resource group /// Name of the workflow /// List of workflow runs - public Page GetWorkflowRuns(string resourceGroupName, string workflowName) + public Page GetWorkflowRuns(string resourceGroupName, string workflowName, string nextPageLink = "") { - return (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName); + if (string.IsNullOrWhiteSpace(nextPageLink)) + { + return (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName); + } + else + { + return (Page)this.LogicManagementClient.WorkflowRuns.ListNext(nextPageLink); + } } /// From 2448dd0ccff6015f12738af92a4d433b8d496d4c Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 17:42:13 +0000 Subject: [PATCH 2/7] Update markdown help --- .../LogicApp/help/Get-AzLogicAppRunHistory.md | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index 54290f94b52e..f126f2f167fb 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -14,8 +14,8 @@ Gets the run history of a logic app. ## SYNTAX ``` -Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] - [-DefaultProfile ] [] +Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] [-FollowRelLink] + [-MaximumFollowRelLink ] [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -78,10 +78,30 @@ This command gets a specific logic app run for the logic app named LogicApp03. This command gets the run history of a logic app named LogicApp03. (autogenerated) -```powershell +```powershell + Get-AzLogicAppRunHistory -Name 'IntegrationAccount31' -ResourceGroupName MyResourceGroup ``` +### Example 4 + +This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink + +```powershell + +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink +``` + +### Example 5 + +This command gets the first two pages of run history of a logic app named LogicApp03 by following the NextPageLink and limiting the result size to two pages. +Each page contains thirty results. + +```powershell + +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink +``` + ## PARAMETERS ### -DefaultProfile @@ -99,6 +119,36 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -FollowRelLink +Indicates the cmdlet should follow relation links. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MaximumFollowRelLink +Specifies how many times to follow relation links if FollowRelLink is used. + +```yaml +Type: System.Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Name Specifies the name of the logic app for which this cmdlet gets run history. @@ -146,7 +196,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS From a5d14e8cc97304ae77bc06f8805df66bae819e94 Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 18:42:09 +0000 Subject: [PATCH 3/7] Update ChangeLog.md --- src/LogicApp/LogicApp/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LogicApp/LogicApp/ChangeLog.md b/src/LogicApp/LogicApp/ChangeLog.md index b77de82e169b..c51d6e8eca78 100644 --- a/src/LogicApp/LogicApp/ChangeLog.md +++ b/src/LogicApp/LogicApp/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Fix for Get-AzLogicAppRunHistory only retrieving the first page of results ## Version 1.3.2 * Update references in .psd1 to use relative path From f29de1986dd669b3cec3d1f09a8779f985ae8f13 Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 20:11:29 +0000 Subject: [PATCH 4/7] Removed redundant parameter set and added parameter aliases to match Invoke-RestMethod --- .../LogicApp/GetAzureLogicAppRunHistoryCommand.cs | 10 ++++++---- src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs index c97f950faa06..d0205a292c75 100644 --- a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs +++ b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs @@ -18,6 +18,7 @@ namespace Microsoft.Azure.Commands.LogicApp.Cmdlets { using Microsoft.Azure.Commands.LogicApp.Utilities; using ResourceManager.Common.ArgumentCompleters; + using System; using System.Management.Automation; /// @@ -45,12 +46,13 @@ public class AzureLogicAppRunHistoryCommand : LogicAppBaseCmdlet [ValidateNotNullOrEmpty] public string RunName { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow relation links.", - ParameterSetName = "FollowRelLink")] + [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow relation links.")] + [Alias("FL")] public SwitchParameter FollowRelLink { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow relation links if FollowRelLink is used.", - ParameterSetName = "FollowRelLink")] + [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow relation links if FollowRelLink is used.")] + [Alias("ML")] + [ValidateRange(1, Int32.MaxValue)] public int MaximumFollowRelLink { get; set; } = int.MaxValue; #endregion Input Parameters diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index f126f2f167fb..2d436327b43a 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.PowerShell.Cmdlets.LogicApp.dll-Help.xml Module Name: Az.LogicApp ms.assetid: F271BCB1-6D43-48E5-BB51-00288F57BFFB @@ -125,7 +125,7 @@ Indicates the cmdlet should follow relation links. ```yaml Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: FL Required: False Position: Named @@ -140,7 +140,7 @@ Specifies how many times to follow relation links if FollowRelLink is used. ```yaml Type: System.Int32 Parameter Sets: (All) -Aliases: +Aliases: ML Required: False Position: Named From fb510eaf8aeb5952756a744c3e8206e24799dd5c Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 21:04:51 +0000 Subject: [PATCH 5/7] Remove mistakenly pasted comment --- src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index 2d436327b43a..eabe7102d67f 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -78,17 +78,15 @@ This command gets a specific logic app run for the logic app named LogicApp03. This command gets the run history of a logic app named LogicApp03. (autogenerated) -```powershell - +```powershell Get-AzLogicAppRunHistory -Name 'IntegrationAccount31' -ResourceGroupName MyResourceGroup ``` ### Example 4 -This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink +This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink. ```powershell - Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink ``` @@ -98,7 +96,6 @@ This command gets the first two pages of run history of a logic app named LogicA Each page contains thirty results. ```powershell - Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink ``` From bead4d55c61553b118d1170f97dce0401a75da1e Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Mon, 2 Nov 2020 21:08:15 +0000 Subject: [PATCH 6/7] Fix example --- src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index eabe7102d67f..75efef0abc50 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -96,7 +96,7 @@ This command gets the first two pages of run history of a logic app named LogicA Each page contains thirty results. ```powershell -Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink -MaximumFollowRelLink 1 ``` ## PARAMETERS From dc2f638d0178d567a46ad93ecd5256b8feb8f2c9 Mon Sep 17 00:00:00 2001 From: "Whatmuff, Michael" Date: Wed, 4 Nov 2020 08:44:54 +0000 Subject: [PATCH 7/7] Implemented suggested changes --- .../GetAzureLogicAppRunHistoryCommand.cs | 26 +++++++++---------- .../Utilities/LogicAppClientRunOperations.cs | 11 +++----- .../LogicApp/help/Get-AzLogicAppRunHistory.md | 16 ++++++------ 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs index d0205a292c75..3561de1541eb 100644 --- a/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs +++ b/src/LogicApp/LogicApp/Cmdlets/LogicApp/GetAzureLogicAppRunHistoryCommand.cs @@ -46,14 +46,14 @@ public class AzureLogicAppRunHistoryCommand : LogicAppBaseCmdlet [ValidateNotNullOrEmpty] public string RunName { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow relation links.")] + [Parameter(Mandatory = false, HelpMessage = "Indicates the cmdlet should follow next page links.")] [Alias("FL")] - public SwitchParameter FollowRelLink { get; set; } + public SwitchParameter FollowNextPageLink { get; set; } - [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow relation links if FollowRelLink is used.")] + [Parameter(Mandatory = false, HelpMessage = "Specifies how many times to follow next page links if FollowNextPageLink is used.")] [Alias("ML")] [ValidateRange(1, Int32.MaxValue)] - public int MaximumFollowRelLink { get; set; } = int.MaxValue; + public int MaximumFollowNextPageLink { get; set; } = int.MaxValue; #endregion Input Parameters @@ -65,21 +65,19 @@ public override void ExecuteCmdlet() base.ExecuteCmdlet(); if (string.IsNullOrEmpty(this.RunName)) { - Page page = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name); - this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); - - if (FollowRelLink && !string.IsNullOrWhiteSpace(page.NextPageLink)) + var page = new Page(); + int i = 0; + do { - for (int i = 0; i < MaximumFollowRelLink; i++) - { - page = LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name, page.NextPageLink); - this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); - } + page = this.LogicAppClient.GetWorkflowRuns(this.ResourceGroupName, this.Name, page.NextPageLink); + this.WriteObject(page.GetEnumerator().ToIEnumerable(), true); + i++; } + while (this.FollowNextPageLink && !string.IsNullOrWhiteSpace(page.NextPageLink) && i <= this.MaximumFollowNextPageLink); } else { - this.WriteObject(LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true); + this.WriteObject(this.LogicAppClient.GetWorkflowRun(this.ResourceGroupName, this.Name, this.RunName), true); } } } diff --git a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs index 649e5b81459e..9ce3512fd4c5 100644 --- a/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs +++ b/src/LogicApp/LogicApp/Utilities/LogicAppClientRunOperations.cs @@ -42,14 +42,9 @@ public void CancelWorkflowRun(string resourceGroupName, string workflowName, /// List of workflow runs public Page GetWorkflowRuns(string resourceGroupName, string workflowName, string nextPageLink = "") { - if (string.IsNullOrWhiteSpace(nextPageLink)) - { - return (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName); - } - else - { - return (Page)this.LogicManagementClient.WorkflowRuns.ListNext(nextPageLink); - } + return string.IsNullOrWhiteSpace(nextPageLink) ? + (Page)this.LogicManagementClient.WorkflowRuns.List(resourceGroupName, workflowName) : + (Page)this.LogicManagementClient.WorkflowRuns.ListNext(nextPageLink); } /// diff --git a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md index 75efef0abc50..e243b0f6acc9 100644 --- a/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md +++ b/src/LogicApp/LogicApp/help/Get-AzLogicAppRunHistory.md @@ -14,8 +14,8 @@ Gets the run history of a logic app. ## SYNTAX ``` -Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] [-FollowRelLink] - [-MaximumFollowRelLink ] [-DefaultProfile ] [] +Get-AzLogicAppRunHistory -ResourceGroupName -Name [-RunName ] [-FollowNextPageLink] + [-MaximumFollowNextPageLink ] [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -87,7 +87,7 @@ Get-AzLogicAppRunHistory -Name 'IntegrationAccount31' -ResourceGroupName MyResou This command gets the entire run history of a logic app named LogicApp03 by following the NextPageLink. ```powershell -Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink ``` ### Example 5 @@ -96,7 +96,7 @@ This command gets the first two pages of run history of a logic app named LogicA Each page contains thirty results. ```powershell -Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowRelLink -MaximumFollowRelLink 1 +Get-AzLogicAppRunHistory -Name 'LogicApp03' -ResourceGroupName MyResourceGroup -FollowNextPageLink -MaximumFollowNextPageLink 1 ``` ## PARAMETERS @@ -116,8 +116,8 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -FollowRelLink -Indicates the cmdlet should follow relation links. +### -FollowNextPageLink +Indicates the cmdlet should follow next page links. ```yaml Type: System.Management.Automation.SwitchParameter @@ -131,8 +131,8 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -MaximumFollowRelLink -Specifies how many times to follow relation links if FollowRelLink is used. +### -MaximumFollowNextPageLink +Specifies how many times to follow next page links if FollowNextPageLink is used. ```yaml Type: System.Int32