Compare commits

...

4 Commits

5 changed files with 34 additions and 27 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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
}

View 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
}
}
}

View File

@ -1,2 +1,6 @@
Import-Module "$PSScriptRoot/Functions/Public/Initialize-GraylogServiceVault.ps1"
$null = Initialize-GraylogServiceVault
if ($PSVersionTable.PSVersion.Major -lt 7) {
Get-ChildItem "$PSScriptRoot/Functions" -Filter "*.ps1" -Recurse | ForEach-Object { Import-Module $_.FullName }
}