Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #3
- Loading branch information
Showing
9 changed files
with
352 additions
and
2 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,30 @@ | ||
--- | ||
title: "TssReportLookup" | ||
--- | ||
|
||
# TOPIC | ||
This help topic describes the TssReportLookup class in the Thycotic.SecretServer module | ||
|
||
# CLASS | ||
TssReportLookup | ||
|
||
# INHERITANCE | ||
None | ||
|
||
# DESCRIPTION | ||
The TssReportLookup class represents the ReportLookup object returned by Secret Server endpoint GET /reports/lookup. | ||
|
||
# CONSTRUCTORS | ||
new() | ||
|
||
# PROPERTIES | ||
Id: integer (int32) | ||
Report ID | ||
|
||
Value: string | ||
Report name | ||
|
||
# METHODS | ||
|
||
# RELATED LINKS: | ||
Find-TssReport |
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,127 @@ | ||
# Find-TssReport | ||
|
||
## SYNOPSIS | ||
Find a report. | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Find-TssReport [-TssSession] <TssSession> [-CategoryId <Int32>] [-IncludeInactive] [-Name <String>] | ||
[-SearchText <String>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Find a report. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Find-TssReport -TssSession $session -CategoryId 1234 | ||
``` | ||
|
||
Return a list of Reports found in Category ID 1234. | ||
|
||
### EXAMPLE 2 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Find-TssReport -TssSession $session -SearchText secret | ||
``` | ||
|
||
Return a list of Reports found with "secret" in the name. | ||
|
||
## PARAMETERS | ||
|
||
### -TssSession | ||
TssSession object created by New-TssSession for auth | ||
|
||
```yaml | ||
Type: TssSession | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -CategoryId | ||
Category ID tp search | ||
|
||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: 0 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -IncludeInactive | ||
Include Inactive Reports | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Name | ||
Name of Report | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -SearchText | ||
Search text | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
### TssReportLookup | ||
## NOTES | ||
Requires TssSession object returned by New-TssSession | ||
|
||
## RELATED LINKS | ||
|
||
[https://thycotic-ps.github.io/thycotic.secretserver/commands/Find-TssReport](https://thycotic-ps.github.io/thycotic.secretserver/commands/Find-TssReport) | ||
|
||
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/reports/Find-Report.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/reports/Find-Report.ps1) | ||
|
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,7 @@ | ||
class TssReportLookup { | ||
[int] | ||
$Id | ||
|
||
[string] | ||
$Value | ||
} |
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,26 @@ | ||
TOPIC | ||
This help topic describes the TssReportLookup class in the Thycotic.SecretServer module | ||
|
||
CLASS | ||
TssReportLookup | ||
|
||
INHERITANCE | ||
None | ||
|
||
DESCRIPTION | ||
The TssReportLookup class represents the ReportLookup object returned by Secret Server endpoint GET /reports/lookup. | ||
|
||
CONSTRUCTORS | ||
new() | ||
|
||
PROPERTIES | ||
Id: integer (int32) | ||
Report ID | ||
|
||
Value: string | ||
Report name | ||
|
||
METHODS | ||
|
||
RELATED LINKS: | ||
Find-TssReport |
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,102 @@ | ||
function Find-Report { | ||
<# | ||
.SYNOPSIS | ||
Find a report. | ||
.DESCRIPTION | ||
Find a report. | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Find-TssReport -TssSession $session -CategoryId 1234 | ||
Return a list of Reports found in Category ID 1234. | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Find-TssReport -TssSession $session -SearchText secret | ||
Return a list of Reports found with "secret" in the name. | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/Find-TssReport | ||
.LINK | ||
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/reports/Find-Report.ps1 | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('TssReportLookup')] | ||
param ( | ||
# TssSession object created by New-TssSession for auth | ||
[Parameter(Mandatory, ValueFromPipeline, Position = 0)] | ||
[TssSession] | ||
$TssSession, | ||
|
||
# Category ID tp search | ||
[int] | ||
$CategoryId, | ||
|
||
# Include Inactive Reports | ||
[switch] | ||
$IncludeInactive, | ||
|
||
# Name of Report | ||
[string] | ||
$Name, | ||
|
||
# Search text | ||
[string] | ||
$SearchText | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeTssParams $TssSession | ||
} | ||
process { | ||
Write-Verbose "Provided command parameters: $(. $GetInvocation $PSCmdlet.MyInvocation)" | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
. $CheckVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation | ||
$uri = $TssSession.ApiUrl, 'reports', 'lookup' -join '/' | ||
$uri = $uri, "&take=$($TssSession.Take)" -join '?' | ||
$invokeParams.Method = 'GET' | ||
|
||
$filters = @() | ||
switch ($tssParams.Keys) { | ||
'CategoryId' { | ||
$filters += "filter.categoryId=$CategoryId" | ||
} | ||
'IncludeInactive' { | ||
$filters += "filter.includeInactive=$([boolean]$IncludeInactive)" | ||
} | ||
'Name' { | ||
$filters += "filter.reportName=$Name" | ||
} | ||
'SearchText' { | ||
$filters += "filter.searchText=$SearchText" | ||
} | ||
} | ||
$uriFilter = $filters -join '&' | ||
Write-Verbose "Filters: $uriFilter" | ||
$uri = $uri, $uriFilter -join '&' | ||
|
||
$invokeParams.Uri = $uri | ||
Write-Verbose "$($invokeParams.Method) $uri" | ||
try { | ||
$restResponse = . $InvokeApi @invokeParams | ||
} catch { | ||
Write-Warning 'Issue on search request' | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse.records) { | ||
[TssReportLookup[]]$restResponse.records | ||
} | ||
} else { | ||
Write-Warning 'No valid session found' | ||
} | ||
} | ||
} |
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,24 @@ | ||
BeforeDiscovery { | ||
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf | ||
} | ||
Describe "$commandName verify parameters" { | ||
BeforeDiscovery { | ||
[object[]]$knownParameters = 'TssSession', 'CategoryId', 'IncludeInactive', 'Name', 'SearchText', 'SortBy' | ||
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')).Parameters.Keys | ||
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function') | ||
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru | ||
} | ||
Context "Verify parameters" -Foreach @{currentParams = $currentParams } { | ||
It "$commandName should contain <_> parameter" -TestCases $knownParameters { | ||
$_ -in $currentParams | Should -Be $true | ||
} | ||
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters { | ||
$_ | Should -BeNullOrEmpty | ||
} | ||
} | ||
Context "Command specific details" { | ||
It "$commandName should set OutputType to TssReportLookup" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'TssReportLookup' | ||
} | ||
} | ||
} |