Skip to content

Commit

Permalink
Get-TssDistributedEngineSiteConnector - new command to get Site Conne…
Browse files Browse the repository at this point in the history
…ctor details
  • Loading branch information
wsmelton committed Oct 8, 2021
1 parent 8e77a5a commit 282b503
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 4 deletions.
@@ -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)

46 changes: 46 additions & 0 deletions src/Thycotic.SecretServer.Format.ps1xml
Expand Up @@ -3760,5 +3760,51 @@
</TableControl>
</View>

<!-- Thycotic.PowerShell.DistributedEngines.SiteConnector -->
<View>
<Name>Thycotic.PowerShell.DistributedEngines.SiteConnector</Name>
<ViewSelectedBy>
<TypeName>Thycotic.PowerShell.DistributedEngines.SiteConnector</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader />
<TableColumnHeader />
<TableColumnHeader />
<TableColumnHeader />
<TableColumnHeader />
<TableColumnHeader />
<TableColumnHeader />
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>SiteConnectorId</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>SiteConnectorName</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Hostname</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Port</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>QueueType</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Validated</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Active</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>

</ViewDefinitions>
</Configuration>
@@ -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; }
}
}
@@ -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
}
}
@@ -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"
}
}
}
Expand Up @@ -73,10 +73,6 @@ function Search-TssDistributedEngine {
'ConnectionStatus' { filters += "filter.connectionStatus = $([string]$ConnectionStatus)" }
'SearchText' { $filters += "filter.friendlyName = $SearchText" }
'RequireActivation' { $filters += "filter.onlyIncludeRequiringAction=$([boolean]$RequireActivation)" }
default {
Write-Error "[-SiteId] or [-RequiredActivation] parameter must be provided!"
return
}
}
if ($filters) {
$uriFilter = $filters -join '&'
Expand Down
18 changes: 18 additions & 0 deletions src/parts/GetSiteConnector.ps1
@@ -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
}
@@ -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'
}
}
}

0 comments on commit 282b503

Please sign in to comment.