Skip to content

Commit c74ccb1

Browse files
Merge pull request #19 from felixcho-msft/dev
New Graphical Runbook types
2 parents 75368db + 4301da7 commit c74ccb1

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationRunbook.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public class ImportAzureAutomationRunbook : AzureAutomationBaseCmdlet
6161
/// Gets or sets the runbook version type
6262
/// </summary>
6363
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
64-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
64+
[ValidateSet(Constants.RunbookType.Graph,
65+
Constants.RunbookType.GraphPowerShell,
66+
Constants.RunbookType.GraphPowerShellWorkflow,
67+
Constants.RunbookType.PowerShell,
68+
Constants.RunbookType.PowerShellWorkflow,
69+
IgnoreCase = true)]
6570
[ValidateNotNullOrEmpty]
6671
public string Type { get; set; }
6772

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationRunbook.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ public class NewAzureAutomationRunbook : AzureAutomationBaseCmdlet
5353
/// Gets or sets the runbook version type
5454
/// </summary>
5555
[Parameter(Mandatory = true, HelpMessage = "Runbook definition type.")]
56-
[ValidateSet(Constants.RunbookType.Graph, Constants.RunbookType.PowerShell, Constants.RunbookType.PowerShellWorkflow, IgnoreCase = true)]
56+
[ValidateSet(Constants.RunbookType.Graph,
57+
Constants.RunbookType.GraphPowerShell,
58+
Constants.RunbookType.GraphPowerShellWorkflow,
59+
Constants.RunbookType.PowerShell,
60+
Constants.RunbookType.PowerShellWorkflow,
61+
IgnoreCase = true)]
5762
[ValidateNotNullOrEmpty]
5863
public string Type { get; set; }
5964

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
454454
var rdcprop = new RunbookCreateOrUpdateDraftProperties()
455455
{
456456
Description = description,
457-
RunbookType = String.IsNullOrWhiteSpace(type) ? RunbookTypeEnum.Script : (0 == string.Compare(type, Constants.RunbookType.PowerShellWorkflow, StringComparison.OrdinalIgnoreCase)) ? RunbookTypeEnum.Script : type,
457+
RunbookType = String.IsNullOrWhiteSpace(type) ? RunbookTypeEnum.Script : type,
458458
LogProgress = logProgress.HasValue && logProgress.Value,
459459
LogVerbose = logVerbose.HasValue && logVerbose.Value,
460460
Draft = new RunbookDraft(),
@@ -476,7 +476,6 @@ public Runbook CreateRunbookByName(string resourceGroupName, string automationAc
476476

477477
public Runbook ImportRunbook(string resourceGroupName, string automationAccountName, string runbookPath, string description, IDictionary tags, string type, bool? logProgress, bool? logVerbose, bool published, bool overwrite, string name)
478478
{
479-
480479
var fileExtension = Path.GetExtension(runbookPath);
481480

482481
if (0 !=
@@ -492,14 +491,12 @@ public Runbook ImportRunbook(string resourceGroupName, string automationAccountN
492491

493492
// if graph runbook make sure type is not null and has right value
494493
if (0 == string.Compare(fileExtension, Constants.SupportedFileExtensions.Graph, StringComparison.OrdinalIgnoreCase)
495-
&& string.IsNullOrWhiteSpace(type)
496-
&& (0 != string.Compare(type, Constants.RunbookType.Graph,StringComparison.OrdinalIgnoreCase)))
494+
&& (string.IsNullOrWhiteSpace(type) || !IsGraphRunbook(type)))
497495
{
498496
throw new ResourceCommonException(typeof(Runbook),
499497
string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookTypeForExtension, fileExtension));
500498
}
501499

502-
503500
var runbookName = Path.GetFileNameWithoutExtension(runbookPath);
504501

505502
if (String.IsNullOrWhiteSpace(name) == false)
@@ -1786,7 +1783,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
17861783
outputFolderFullPath = this.ValidateAndGetFullPath(outputFolder);
17871784
}
17881785

1789-
var fileExtension = (0 == string.Compare(runbookType, Constants.RunbookType.Graph, StringComparison.OrdinalIgnoreCase)) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript;
1786+
var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript;
17901787

17911788
var outputFilePath = outputFolderFullPath + "\\" + runbookName + fileExtension;
17921789

@@ -1803,6 +1800,13 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
18031800
return new DirectoryInfo(runbookName + fileExtension);
18041801
}
18051802

1803+
private static bool IsGraphRunbook(string runbookType)
1804+
{
1805+
return (string.Equals(runbookType, Constants.RunbookType.Graph, StringComparison.OrdinalIgnoreCase) ||
1806+
string.Equals(runbookType, Constants.RunbookType.GraphPowerShell, StringComparison.OrdinalIgnoreCase) ||
1807+
string.Equals(runbookType, Constants.RunbookType.GraphPowerShellWorkflow, StringComparison.OrdinalIgnoreCase));
1808+
}
1809+
18061810
#endregion
18071811
}
18081812
}

src/ResourceManager/Automation/Commands.Automation/Common/Constants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public static class RunbookType
8181
public const string PowerShellWorkflow = "PowerShellWorkflow";
8282

8383
public const string Graph = "Graph";
84+
85+
public const string GraphPowerShell = "GraphPowerShell";
86+
87+
public const string GraphPowerShellWorkflow = "GraphPowerShellWorkflow";
8488
}
8589

8690
public static class SupportedFileExtensions

0 commit comments

Comments
 (0)