Compare commits
4 Commits
13d01d9eb1
...
63bfd2bc40
Author | SHA1 | Date | |
---|---|---|---|
63bfd2bc40 | |||
3511d98e62 | |||
252125184e | |||
9f7ce2c8b0 |
@ -35,7 +35,8 @@ function ConvertFrom-GraylogSession {
|
||||
# MaximumRetryCount = $InputObject.MaximumRetryCount
|
||||
# RetryIntervalInSeconds = $InputObject.RetryIntervalInSeconds
|
||||
# }
|
||||
$Output = $InputObject
|
||||
$Output = $InputObject | Select-Object -ExcludeProperty Cookies
|
||||
$Output | Add-Member -MemberType NoteProperty -Name Cookies -Value ([Collections.Generic.List[PSCustomObject]]@())
|
||||
if ($InputObject.Cookies.Count) {
|
||||
# GetAllCookies is only available in PowerShell Core :c
|
||||
$InputObject.Cookies.GetCookies($local:Graylog_BaseURI) | ForEach-Object {
|
||||
|
@ -30,7 +30,6 @@ function Connect-GraylogService {
|
||||
[PSCredential]
|
||||
$Credential
|
||||
)
|
||||
if ((Test-GraylogSession -SkipSecretCheck)) { return } # If the session is still valid, don't create a new one
|
||||
if (-NOT $Credential) {
|
||||
try {
|
||||
$Credential = Get-Secret Graylog_Credential -Vault Graylog -ErrorAction Stop
|
||||
@ -61,6 +60,7 @@ function Connect-GraylogService {
|
||||
try { $null = Invoke-RestMethod @Request }
|
||||
catch { throw $_.Exception.Message }
|
||||
|
||||
Import-Module "$PSScriptRoot\..\Private\ConvertFrom-GraylogSession.ps1"
|
||||
$GraylogSession | ConvertFrom-GraylogSession | Set-Secret Graylog_Session
|
||||
}
|
||||
# Export-ModuleMember -Function Connect-Graylog
|
@ -1,24 +0,0 @@
|
||||
function Get-GraylogStreams {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the streams available in Graylog.
|
||||
.DESCRIPTION
|
||||
Gets a list of the streams available in Graylog.
|
||||
.OUTPUTS
|
||||
The streams available in Graylog.
|
||||
.EXAMPLE
|
||||
Get-GraylogStreams
|
||||
Gets a list of the streams available in Graylog.
|
||||
#>
|
||||
param ()
|
||||
|
||||
try { $null = Get-Secret Graylog_BaseURI -Vault Graylog -AsPlainText -ErrorAction Stop }
|
||||
catch {
|
||||
try { $Response = Invoke-GraylogRequest GET "/streams" }
|
||||
catch { throw $_.Exception.Message }
|
||||
ConvertTo-Json $Response.Streams | Set-Secret Graylog_Streams -Vault Graylog -AsPlainText
|
||||
}
|
||||
|
||||
$Streams = Get-Secret Graylog_Streams -Vault Graylog -AsPlainText -ErrorAction Stop
|
||||
return ConvertFrom-Json $Streams
|
||||
}
|
26
Functions/Public/Get-GraylogStreams.ps1
Normal file
26
Functions/Public/Get-GraylogStreams.ps1
Normal file
@ -0,0 +1,26 @@
|
||||
function Get-GraylogStreams {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the streams available in Graylog.
|
||||
.DESCRIPTION
|
||||
Gets a list of the streams available in Graylog.
|
||||
.OUTPUTS
|
||||
The streams available in Graylog.
|
||||
.EXAMPLE
|
||||
Get-GraylogStreams
|
||||
Gets a list of the streams available in Graylog.
|
||||
#>
|
||||
param ()
|
||||
|
||||
try {
|
||||
return Get-Secret Graylog_Streams -Vault Graylog -AsPlainText -ErrorAction Stop | ConvertFrom-Json
|
||||
} catch {
|
||||
try {
|
||||
$Response = Invoke-GraylogRequest GET "/streams"
|
||||
ConvertTo-Json $Response.Streams | Set-Secret Graylog_Streams -Vault Graylog
|
||||
return $Response.Streams
|
||||
} catch {
|
||||
throw $_.Exception.Message
|
||||
}
|
||||
}
|
||||
}
|
@ -1,2 +1,6 @@
|
||||
Import-Module "$PSScriptRoot/Functions/Public/Initialize-GraylogServiceVault.ps1"
|
||||
$null = Initialize-GraylogServiceVault
|
||||
$null = Initialize-GraylogServiceVault
|
||||
|
||||
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
||||
Get-ChildItem "$PSScriptRoot/Functions" -Filter "*.ps1" -Recurse | ForEach-Object { Import-Module $_.FullName }
|
||||
}
|
Loading…
Reference in New Issue
Block a user