File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,17 @@ function New-LMAlertRule {
118118
119119 # Add optional properties to Data
120120 if ($EscalationInterval ) { $Data.Add (" escalationInterval" , $EscalationInterval ) }
121- if ($ResourceProperties ) { $Data.Add (" resourceProperties" , $ResourceProperties ) }
121+ if ($ResourceProperties ) {
122+ # Convert hashtable to array of name/value objects as required by the API
123+ $ResourcePropertiesArray = @ ()
124+ foreach ($key in $ResourceProperties.Keys ) {
125+ $ResourcePropertiesArray += @ {
126+ name = $key
127+ value = $ResourceProperties [$key ]
128+ }
129+ }
130+ $Data.Add (" resourceProperties" , $ResourcePropertiesArray )
131+ }
122132 if ($Devices ) { $Data.Add (" devices" , $Devices ) }
123133 if ($DeviceGroups ) { $Data.Add (" deviceGroups" , $DeviceGroups ) }
124134 if ($DataSource ) { $Data.Add (" datasource" , $DataSource ) }
Original file line number Diff line number Diff line change @@ -135,7 +135,17 @@ function Set-LMAlertRule {
135135 if ($Priority ) { $Data.Add (" priority" , $Priority ) }
136136 if ($EscalationInterval ) { $Data.Add (" escalationInterval" , $EscalationInterval ) }
137137 if ($EscalatingChainId ) { $Data.Add (" escalatingChainId" , $EscalatingChainId ) }
138- if ($ResourceProperties ) { $Data.Add (" resourceProperties" , $ResourceProperties ) }
138+ if ($ResourceProperties ) {
139+ # Convert hashtable to array of name/value objects as required by the API
140+ $ResourcePropertiesArray = @ ()
141+ foreach ($key in $ResourceProperties.Keys ) {
142+ $ResourcePropertiesArray += @ {
143+ name = $key
144+ value = $ResourceProperties [$key ]
145+ }
146+ }
147+ $Data.Add (" resourceProperties" , $ResourcePropertiesArray )
148+ }
139149 if ($Devices ) { $Data.Add (" devices" , $Devices ) }
140150 if ($DeviceGroups ) { $Data.Add (" deviceGroups" , $DeviceGroups ) }
141151 if ($DataSource ) { $Data.Add (" datasource" , $DataSource ) }
You can’t perform that action at this time.
0 commit comments