-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d09268d
commit 4e81ef1
Showing
8 changed files
with
202 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Function Get-LMNormalizedProperties { | ||
|
||
[CmdletBinding()] | ||
Param () | ||
|
||
#Check if we are logged in and have valid api creds | ||
Begin {} | ||
Process { | ||
If ($Script:LMAuth.Valid) { | ||
|
||
#Build header and uri | ||
$ResourcePath = "/normalizedProperties/filter" | ||
|
||
$Body = [PSCustomObject]@{ | ||
meta = @{ | ||
filters = @{ | ||
filterType = "FILTER_CATEGORICAL_MODEL_TYPE" | ||
normalizedProperties = @{ | ||
dynamic = @( | ||
@{ | ||
field = "alias" | ||
expressions = @( | ||
@{ | ||
operator = "REGEX" | ||
value = ".*" | ||
} | ||
) | ||
} | ||
) | ||
} | ||
} | ||
paging = @{ | ||
perPageCount = 100 | ||
pageOffsetCount = 0 | ||
} | ||
sort = "alias, hostPropertyPriority" | ||
} | ||
} | ConvertTo-Json -Depth 10 | ||
|
||
Try { | ||
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "POST" -ResourcePath $ResourcePath -Version 4 | ||
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath | ||
|
||
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation | ||
|
||
#Issue request | ||
$Response = Invoke-RestMethod -Uri $Uri -Method "POST" -Headers $Headers[0] -WebSession $Headers[1] -Body $Body | ||
} | ||
Catch [Exception] { | ||
$Proceed = Resolve-LMException -LMException $PSItem | ||
If (!$Proceed) { | ||
Return | ||
} | ||
} | ||
Return $Response | ||
} | ||
Else { | ||
Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." | ||
} | ||
} | ||
End {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Function New-LMNormalizedProperties { | ||
|
||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[String]$Alias, | ||
[Parameter(Mandatory = $true)] | ||
[Array]$Properties | ||
) | ||
|
||
#Check if we are logged in and have valid api creds | ||
Begin {} | ||
Process { | ||
If ($Script:LMAuth.Valid) { | ||
|
||
#Build header and uri | ||
$ResourcePath = "/normalizedProperties/bulk" | ||
|
||
#Loop through each property and build the body | ||
$Body = [PSCustomObject]@{ | ||
data = [PSCustomObject]@{ | ||
items = @() | ||
} | ||
} | ||
$Index = 1 | ||
ForEach ($Property in $Properties) { | ||
$Body.data.items += [PSCustomObject]@{ | ||
alias = $Alias | ||
hostProperty = $Property | ||
hostPropertyPriority = $Index | ||
model = "normalizedProperties" | ||
} | ||
$Index++ | ||
} | ||
|
||
$Body = $Body | ConvertTo-Json -Depth 10 | ||
|
||
Try { | ||
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Version 4 | ||
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath | ||
|
||
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation | ||
|
||
#Issue request | ||
$Response = Invoke-RestMethod -Uri $Uri -Method "PATCH" -Headers $Headers[0] -WebSession $Headers[1] -Body $Body | ||
} | ||
Catch [Exception] { | ||
$Proceed = Resolve-LMException -LMException $PSItem | ||
If (!$Proceed) { | ||
Return | ||
} | ||
} | ||
Return $Response | ||
} | ||
Else { | ||
Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." | ||
} | ||
} | ||
End {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Function Remove-LMNormalizedProperties { | ||
|
||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[String]$Alias | ||
) | ||
|
||
#Check if we are logged in and have valid api creds | ||
Begin {} | ||
Process { | ||
If ($Script:LMAuth.Valid) { | ||
|
||
#Build header and uri | ||
$ResourcePath = "/normalizedProperties/alias" | ||
|
||
#Loop through each property and build the body | ||
$Body = [PSCustomObject]@{ | ||
data = [PSCustomObject]@{ | ||
items = @() | ||
} | ||
} | ||
|
||
$Body.data.items += [PSCustomObject]@{ | ||
alias = $Alias | ||
model = "normalizedProperties" | ||
} | ||
|
||
$Body = $Body | ConvertTo-Json -Depth 10 | ||
|
||
Try { | ||
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "DELETE" -ResourcePath $ResourcePath -Version 4 | ||
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath | ||
|
||
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation | ||
|
||
#Issue request | ||
$Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1] -Body $Body | ||
} | ||
Catch [Exception] { | ||
$Proceed = Resolve-LMException -LMException $PSItem | ||
If (!$Proceed) { | ||
Return | ||
} | ||
} | ||
Return $Response | ||
} | ||
Else { | ||
Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again." | ||
} | ||
} | ||
End {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters