Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set-TssDistributedEngineSiteConnector - new command to update configu…
…ration of a Site Connector
- Loading branch information
Showing
3 changed files
with
367 additions
and
0 deletions.
There are no files selected for viewing
203 changes: 203 additions & 0 deletions
203
docs/commands/distributed-engines/Set-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,203 @@ | ||
# Set-TssDistributedEngineSiteConnector | ||
|
||
## SYNOPSIS | ||
Set configurations for a Site Connector | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Set-TssDistributedEngineSiteConnector [-TssSession] <Session> [-Id <Int32[]>] [-Enable] [-Name <String>] | ||
[-Hostname <String>] [-UseSsl] [-Port <Int32>] [-TransportType <String>] [-WhatIf] [-Confirm] | ||
[<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
Set configurations for a Site Connector | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Set-TssDistributedEngineSiteConnector -TssSession session -Id 5 -Enable:$false | ||
``` | ||
|
||
Disable Site Connector ID 5. | ||
|
||
### EXAMPLE 2 | ||
``` | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Set-TssDistributedEngineSiteConnector -TssSession session -Id 10 TransportType RabbitMq -Port 5671 -UseSsl | ||
``` | ||
|
||
Set Site Connector ID 10 queue type to RabbitMq, enable SSL and use port 5671 SSL port. | ||
|
||
## 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(s) | ||
|
||
```yaml | ||
Type: Int32[] | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Enable | ||
Enable or Disable | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Name | ||
Site Connector Name | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Hostname | ||
Hostname | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -UseSsl | ||
Use SSL | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: False | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Port | ||
Port number | ||
|
||
```yaml | ||
Type: Int32 | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: 0 | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -TransportType | ||
Service Bus Transport Type (allowed: MemoryMq, RabbitMq) | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -WhatIf | ||
Shows what would happen if the cmdlet runs. | ||
The cmdlet is not run. | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: wi | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
|
||
### -Confirm | ||
Prompts you for confirmation before running the cmdlet. | ||
|
||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
Aliases: cf | ||
|
||
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 | ||
|
||
## NOTES | ||
Requires TssSession object returned by New-TssSession | ||
|
||
## RELATED LINKS | ||
|
||
[https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Set-TssDistributedEngineSiteConnector](https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Set-TssDistributedEngineSiteConnector) | ||
|
||
[https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Set-TssDistributedEngineSiteConnector.ps1](https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Set-TssDistributedEngineSiteConnector.ps1) | ||
|
145 changes: 145 additions & 0 deletions
145
src/functions/distributed-engines/Set-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,145 @@ | ||
function Set-TssDistributedEngineSiteConnector { | ||
<# | ||
.SYNOPSIS | ||
Set configurations for a Site Connector | ||
.DESCRIPTION | ||
Set configurations for a Site Connector | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Set-TssDistributedEngineSiteConnector -TssSession session -Id 5 -Enable:$false | ||
Disable Site Connector ID 5. | ||
.EXAMPLE | ||
$session = New-TssSession -SecretServer https://alpha -Credential $ssCred | ||
Set-TssDistributedEngineSiteConnector -TssSession session -Id 10 TransportType RabbitMq -Port 5671 -UseSsl | ||
Set Site Connector ID 10 queue type to RabbitMq, enable SSL and use port 5671 SSL port. | ||
.LINK | ||
https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Set-TssDistributedEngineSiteConnector | ||
.LINK | ||
https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Set-TssDistributedEngineSiteConnector.ps1 | ||
.NOTES | ||
Requires TssSession object returned by New-TssSession | ||
#> | ||
[cmdletbinding(SupportsShouldProcess)] | ||
param( | ||
# TssSession object created by New-TssSession for authentication | ||
[Parameter(Mandatory,ValueFromPipeline,Position = 0)] | ||
[Thycotic.PowerShell.Authentication.Session] | ||
$TssSession, | ||
|
||
# Site Connector ID(s) | ||
[int[]] | ||
$Id, | ||
|
||
# Enable or Disable | ||
[switch] | ||
$Enable, | ||
|
||
# Site Connector Name | ||
[string] | ||
$Name, | ||
|
||
# Hostname | ||
[string] | ||
$Hostname, | ||
|
||
# Use SSL | ||
[switch] | ||
$UseSsl, | ||
|
||
# Port number | ||
[int] | ||
$Port, | ||
|
||
# Service Bus Transport Type (allowed: MemoryMq, RabbitMq) | ||
[ValidateSet('MemoryMq','RabbitMq')] | ||
[string] | ||
$TransportType | ||
) | ||
begin { | ||
$setParams = $PSBoundParameters | ||
$invokeParams = . $GetInvokeApiParams $TssSession | ||
} | ||
process { | ||
Get-TssInvocation $PSCmdlet.MyInvocation | ||
if ($setParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { | ||
Compare-TssVersion $TssSession '10.9.000064' $PSCmdlet.MyInvocation | ||
foreach ($connector in $Id) { | ||
$uri = $TssSession.ApiUrl, 'distributed-engine', 'site-connector', $connector -join '/' | ||
$invokeParams.Uri = $uri | ||
$invokeParams.Method = 'PATCH' | ||
|
||
$setBody = @{ data = @{ } } | ||
switch ($setParams.Keys) { | ||
'Enable' { | ||
$enableIt = @{ | ||
dirty = $true | ||
value = [boolean]$Enable | ||
} | ||
$setBody.data.Add('active',$enableIt) | ||
} | ||
'Name' { | ||
$nameIt = @{ | ||
dirty = $true | ||
value = $Name | ||
} | ||
$setBody.data.Add('name',$nameIt) | ||
} | ||
'Hostname' { | ||
$hostIt = @{ | ||
dirty = $true | ||
value = $Hostname | ||
} | ||
$setBody.data.Add('hostName',$hostIt) | ||
} | ||
'UseSsl' { | ||
$sslValue = @{ | ||
dirty = $true | ||
value = [boolean]$UseSsl | ||
} | ||
$setBody.data.Add('useSsl',$sslValue) | ||
} | ||
'Port' { | ||
$portValue = @{ | ||
dirty = $true | ||
value = $Port | ||
} | ||
$setBody.data.Add('port',$portValue) | ||
} | ||
'TransportType' { | ||
$transportValue = @{ | ||
dirty = $true | ||
value = $TransportType | ||
} | ||
$setBody.data.Add('queueType',$transportValue) | ||
} | ||
} | ||
$invokeParams.Body = $setBody | ConvertTo-Json -Depth 100 | ||
|
||
if ($PSCmdlet.ShouldProcess("Site Connector: $connector", "$($invokeParams.Method) $($invokeParams.Uri) with:`n$($invokeParams.Body)`n")) { | ||
Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri) with:`n$($invokeParams.Body)`n" | ||
try { | ||
$apiResponse = Invoke-TssApi @invokeParams | ||
$restResponse = . $ProcessResponse $apiResponse | ||
} catch { | ||
Write-Warning "Issue setting configuration for Site Connector [$connector]" | ||
$err = $_ | ||
. $ErrorHandling $err | ||
} | ||
} | ||
if ($restResponse) { | ||
Write-Verbose "Site Connector [$connector] updated successfully" | ||
} | ||
} | ||
} else { | ||
Write-Warning 'No valid session found' | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/distributed-engines/Set-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,19 @@ | ||
BeforeDiscovery { | ||
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf | ||
} | ||
Describe "$commandName verify parameters" { | ||
BeforeDiscovery { | ||
[object[]]$knownParameters = 'TssSession', | ||
[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 | ||
} | ||
} | ||
} |