Skip to content

Commit

Permalink
-Fixed a bug wherein Edit-NotificationTriggerProperty could not set v…
Browse files Browse the repository at this point in the history
…alues to $null

-Fixed a bug wherein New-NotificationTriggerParameter did not process NotificationTrigger objects properly in the EditFrom parameter set
-Removed mandatory import of PrtgAPI in PowerShell Profile when GoPrtg is installed
-Removed Get-GoPrtg alias for Get-GoPrtgServer due to conflict with "GoPrtg" alias cmdlet resolution
  • Loading branch information
lordmilko committed Apr 23, 2017
1 parent e2f6d8c commit 768237f
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 40 deletions.
44 changes: 22 additions & 22 deletions PrtgAPI.Tests.UnitTests/PowerShell/GoPrtg.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function InstallMultipleInProfile

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",,```"username2```",```"*```"`"`r`n"
Expand Down Expand Up @@ -84,7 +84,7 @@ function InstallMultipleWithAlias

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"prod```",```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",```"dev```",```"username2```",```"*```"`"`r`n"
Expand Down Expand Up @@ -155,7 +155,7 @@ function GoPrtgAfterEach

Describe "Install-GoPrtgServer" {

$baseExpected = ("########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n" +
$baseExpected = ("########################### Start GoPrtg Servers ###########################`r`n`r`n" +
"function __goPrtgGetServers {@(`r`n `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n)}`r`n`r`n" +
"############################ End GoPrtg Servers ############################`r`n").Replace("``","````")

Expand Down Expand Up @@ -224,7 +224,7 @@ Describe "Install-GoPrtgServer" {
$content = gc $Profile -Raw

$expected = "Write-Host `"hello`"`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",,```"username2```",```"*```"`"`r`n"
Expand Down Expand Up @@ -260,7 +260,7 @@ Describe "Install-GoPrtgServer" {
$content = gc $Profile -Raw

$expected = "Write-Host `"hello`"`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",,```"username2```",```"*```"`"`r`n"
Expand All @@ -278,7 +278,7 @@ Describe "Install-GoPrtgServer" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"prod```",```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -294,7 +294,7 @@ Describe "Install-GoPrtgServer" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -310,7 +310,7 @@ Describe "Install-GoPrtgServer" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand Down Expand Up @@ -341,7 +341,7 @@ Describe "Install-GoPrtgServer" {

$contents = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"prod```",```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example.com```",```"dev```",```"username2```",```"*```"`"`r`n"
Expand Down Expand Up @@ -468,7 +468,7 @@ Describe "Install-GoPrtgServer" {

Describe "Uninstall-GoPrtgServer" {

$baseExpected = ("########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n" +
$baseExpected = ("########################### Start GoPrtg Servers ###########################`r`n`r`n" +
"function __goPrtgGetServers {@(`r`n `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n)}`r`n" +
"`r`n############################ End GoPrtg Servers ############################`r`n").Replace("``", "````")

Expand Down Expand Up @@ -526,7 +526,7 @@ Describe "Uninstall-GoPrtgServer" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example2.com```",,```"username2```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand Down Expand Up @@ -558,7 +558,7 @@ Describe "Uninstall-GoPrtgServer" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg3.example.com```",,```"username3```",```"*```"`",`r`n"
Expand All @@ -574,7 +574,7 @@ Describe "Uninstall-GoPrtgServer" {

$finalContent = gc $Profile -Raw

$finalExpected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$finalExpected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$finalExpected += "function __goPrtgGetServers {@(`r`n"
$finalExpected += " `"```"prtg3.example.com```",,```"username3```",```"*```"`"`r`n"
$finalExpected += ")}`r`n`r`n"
Expand Down Expand Up @@ -602,7 +602,7 @@ Describe "Uninstall-GoPrtgServer" {

$contents = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example2.com```",```"dev```",```"username2```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand Down Expand Up @@ -940,7 +940,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"test```",```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -958,7 +958,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"dev```",```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand Down Expand Up @@ -991,7 +991,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"test```",```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",```"dev```",```"username2```",```"*```"`"`r`n"
Expand Down Expand Up @@ -1025,7 +1025,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"prod```",```"username```",```"*```"`",`r`n"
$expected += " `"```"prtg.example2.com```",```"test```",```"username2```",```"*```"`"`r`n"
Expand All @@ -1047,7 +1047,7 @@ Describe "Set-GoPrtgAlias" {
$content = gc $Profile -Raw

$expected = "Write-Host `"hello`"`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"test```",```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -1070,7 +1070,7 @@ Describe "Set-GoPrtgAlias" {
$content = gc $Profile -Raw

$expected = "Write-Host `"hello`"`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected += "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",```"test```",```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -1089,7 +1089,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand All @@ -1107,7 +1107,7 @@ Describe "Set-GoPrtgAlias" {

$content = gc $Profile -Raw

$expected = "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n"
$expected = "########################### Start GoPrtg Servers ###########################`r`n`r`n"
$expected += "function __goPrtgGetServers {@(`r`n"
$expected += " `"```"prtg.example.com```",,```"username```",```"*```"`"`r`n"
$expected += ")}`r`n`r`n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EditNotificationTriggerProperty : PrtgCmdlet
/// <summary>
/// <para type="description">Value to set the property to.</para>
/// </summary>
[Parameter(Mandatory = true, Position = 1)]
[Parameter(Mandatory = false, Position = 1)]
public object Value { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ protected override void ProcessRecord()
private T CreateParameters<T>(ModifyAction action)
{
if (Source != null)
return (T) Activator.CreateInstance(typeof (T), Id, Source, action); //Use an existing notification trigger
{
if (Id != null)
return (T) Activator.CreateInstance(typeof (T), Id, Source, action); //Add from an existing notification trigger
else
return (T) Activator.CreateInstance(typeof (T), Source.ObjectId, Source.SubId); //Edit from an existing notification trigger
}

if (TriggerId != null)
return (T) Activator.CreateInstance(typeof (T), Id, TriggerId); //Edit a notification trigger
else
Expand Down
2 changes: 1 addition & 1 deletion PrtgAPI/PowerShell/Resources/PrtgAPI.GoPrtg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ function GetProfileContents($newContents)
# before detecting GoPrtg is in fact a valid alias all by itself. By forcing the module to import, PowerShell will correctly
# identify that GoPrtg is the intended command.

$funcBody += "########################### Start GoPrtg Servers ###########################`r`nImport-Module PrtgAPI`r`n" +
$funcBody += "########################### Start GoPrtg Servers ###########################`r`n`r`n" +
[string]::Join("`r`n", $newContents.Func) +
"`r`n`r`n############################ End GoPrtg Servers ############################"

Expand Down
2 changes: 1 addition & 1 deletion PrtgAPI/PowerShell/Resources/PrtgAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PrtgAPI.dll'

# Version number of this module.
ModuleVersion = '0.6.7'
ModuleVersion = '0.6.8'

# ID used to uniquely identify this module
GUID = '81d4380f-31ff-42c7-9d64-1678dc5cd978'
Expand Down
1 change: 0 additions & 1 deletion PrtgAPI/PowerShell/Resources/PrtgAPI.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ New-Alias Sort-PrtgObject Start-SortPrtgObject
New-Alias Connect-GoPrtg Connect-GoPrtgServer
New-Alias Install-GoPrtg Install-GoPrtgServer
New-Alias Uninstall-GoPrtg Uninstall-GoPrtgServer
New-Alias Get-GoPrtg Get-GoPrtgServer

New-Alias GoPrtg Connect-GoPrtgServer

Expand Down
4 changes: 2 additions & 2 deletions PrtgAPI/Properties/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//0
//6
//7
//8
//0
//
// This code was generated by a tool. Any changes made manually will be lost
Expand All @@ -9,4 +9,4 @@

using System.Reflection;

[assembly: AssemblyFileVersion("0.6.7.0")]
[assembly: AssemblyFileVersion("0.6.8.0")]

0 comments on commit 768237f

Please sign in to comment.