Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get-TssDistributedEngineSiteConnector - new command to get Site Conne…
…ctor details
- Loading branch information
Showing
8 changed files
with
268 additions
and
4 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
docs/commands/distributed-engines/Get-TssDistributedEngineSiteConnector.md
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,73 @@ | ||
# Get-TssDistributedEngineSiteConnector | ||
|
||
## SYNOPSIS | ||
Get Site Connector by ID | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Get-TssDistributedEngineSiteConnector [-TssSession] <Session> -Id <Int32[]> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Get Site Connector by ID | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Get-TssDistributedEngineSiteConnector -TssSession $session -Id 2 | ||
``` | ||
|
||
Get Site Connector ID 2 | ||
|
||
## PARAMETERS | ||
|
||
### -TssSession | ||
TssSession object created by New-TssSession for authentication | ||
|
||
```yaml | ||
Type: Session | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Id | ||
Site Connector ID | ||
|
||
```yaml | ||
Type: Int32[] | ||
Parameter Sets: (All) | ||
Aliases: SiteConnectorId | ||
|
||
Required: True | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: True (ByPropertyName) | ||
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 | ||
|
||
### Thycotic.PowerShell.DistributedEngines.SiteConnector | ||
## NOTES | ||
Requires TssSession object returned by New-TssSession | ||
|
||
## RELATED LINKS | ||
|
||
[https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineSiteConnector](https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineSiteConnector) | ||
|
||
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineSiteConnector.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineSiteConnector.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
23 changes: 23 additions & 0 deletions
23
src/Thycotic.SecretServer/classes/distributed-engines/SiteConnector.cs
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,23 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Management.Automation; | ||
using System.Management.Automation.Runspaces; | ||
using Thycotic.PowerShell.Enums; | ||
|
||
namespace Thycotic.PowerShell.DistributedEngines | ||
{ | ||
public class SiteConnector | ||
{ | ||
public bool Active { get; set; } | ||
public string Hostname { get; set; } | ||
public int Port { get; set; } | ||
public SiteConnectorQueueType QueueType { get; set; } | ||
public string SharedAccessKeyName { get; set; } | ||
public string SharedAccessKeyValue { get; set; } | ||
public int SiteConnectorId { get; set; } | ||
public string SiteConnectorName { get; set; } | ||
public string SslCertificateThumbprint { get; set; } | ||
public bool UseSsl { get; set; } | ||
public bool Validated { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Thycotic.SecretServer/enums/distributed-engines/SiteConnectorQueueType.cs
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,14 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using System.Management.Automation; | ||
using System.Management.Automation.Runspaces; | ||
|
||
namespace Thycotic.PowerShell.Enums | ||
{ | ||
public enum SiteConnectorQueueType | ||
{ | ||
MemoryMq, | ||
RabbitMq, | ||
AzureServiceBus | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/functions/distributed-engines/Get-TssDistributedEngineSiteConnector.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
function Get-TssDistributedEngineSiteConnector { | ||
<# | ||
.SYNOPSIS | ||
Get Site Connector by ID | ||
.DESCRIPTION | ||
Get Site Connector by ID | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Get-TssDistributedEngineSiteConnector -TssSession $session -Id 2 | ||
Get Site Connector ID 2 | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineSiteConnector | ||
.LINK | ||
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineSiteConnector.ps1 | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[CmdletBinding()] | ||
[OutputType('Thycotic.PowerShell.DistributedEngines.SiteConnector')] | ||
param ( | ||
# TssSession object created by New-TssSession for authentication | ||
[Parameter(Mandatory,ValueFromPipeline,Position = 0)] | ||
[Thycotic.PowerShell.Authentication.Session] | ||
$TssSession, | ||
|
||
# Site Connector ID | ||
[Parameter(Mandatory,ValueFromPipelineByPropertyName)] | ||
[Alias("SiteConnectorId")] | ||
[int[]] | ||
$Id | ||
) | ||
begin { | ||
$tssParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeApiParams $TssSession | ||
} | ||
process { | ||
Get-TssInvocation $PSCmdlet.MyInvocation | ||
if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
Compare-TssVersion $TssSession '10.9.000064' $PSCmdlet.MyInvocation | ||
foreach ($connector in $Id) { | ||
$restResponse = $null | ||
$uri = $TssSession.ApiUrl, 'distributed-engine', 'site-connector', $connector -join '/' | ||
$invokeParams.Uri = $uri | ||
$invokeParams.Method = 'GET' | ||
|
||
Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri)" | ||
try { | ||
$apiResponse = Invoke-TssApi @invokeParams | ||
$restResponse = . $ProcessResponse $apiResponse | ||
} catch { | ||
Write-Warning "Issue getting reference name on [$connector]" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
|
||
if ($restResponse) { | ||
. $GetSiteConnector $restResponse | ||
} | ||
} | ||
} 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,18 @@ | ||
param( | ||
[Parameter(Position = 0)] | ||
[PSCustomObject]$Object | ||
) | ||
|
||
[Thycotic.PowerShell.DistributedEngines.SiteConnector]@{ | ||
Active = $Object.active.value | ||
Hostname = $Object.hostName.value | ||
Port = $Object.port.value | ||
QueueType = $Object.queueType.value | ||
SharedAccessKeyName = $Object.sharedAccessKeyName.value | ||
SharedAccessKeyValue = $Object.sharedAccessKeyValue.value | ||
SiteConnectorId = $Object.siteConnectorId | ||
SiteConnectorName = $Object.siteConnectorName.value | ||
SslCertificateThumbprint = $Object.sslCertificateThumbprint.value | ||
UseSsl = $Object.useSsl.value | ||
Validated = $Object.validated.value | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/distributed-engines/Get-TssDistributedEngineSiteConnector.Tests.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
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', 'Id' | ||
[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 Thycotic.PowerShell.DistributedEngines.SiteConnector" -TestCases $commandDetails { | ||
$_.OutputType.Name | Should -Be 'Thycotic.PowerShell.DistributedEngines.SiteConnector' | ||
} | ||
} | ||
} |