Skip to content

Commit

Permalink
Vsat workers (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbarron authored Nov 22, 2024
1 parent 879d00c commit cdc262e
Show file tree
Hide file tree
Showing 16 changed files with 377 additions and 123 deletions.
7 changes: 5 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
- Add `Set-VcCertificate`. This replaces `Add-VcCertificateAssociation` to set the applications associated with a certificate. Certificate tagging is now supported, both add and replace.
- Add support for URL port during TLSPDC token operations, [#305](https://github.com/Venafi/VenafiPS/issues/305)
- Add `Get-VcSatelliteWorker`, either all, by id or all workers associated with a specific satellite
- Add `Remove-VcSatelliteWorker`, you guessed it...removes vsat workers
- Add `Get-VcSatellite -IncludeWorkers` to get vsats and their associated workers in one call.
- Add `Invoke-VcCertificateAction -Provision` to push a certificate to associated machine identities. You can also use `-Renew -Provision` together and it will renew and then provision the new certificate.
- Add `Set-VcApplication -IssuingTemplate` to add one or more issuing templates to an application. It will overwrite by default or use `-NoOverwrite` to append.
20 changes: 10 additions & 10 deletions VenafiPS/Public/Get-VcApplication.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.DESCRIPTION
Get 1 or more applications.
.PARAMETER ID
.PARAMETER Application
Application ID or name
.PARAMETER All
Expand All @@ -21,7 +21,7 @@
ID
.EXAMPLE
Get-VcApplication -ApplicationID 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
Get-VcApplication -Application 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
applicationId : 96fc9310-67ec-11eb-a8a7-794fe75a8e6f
certificateIssuingTemplate : @{Name=MyTemplate; id=7fb6af20-b22e-11ea-9a24-930fb5d2b247}
Expand All @@ -39,7 +39,7 @@
Get a single object by ID
.EXAMPLE
Get-VcApplication -ID 'My Awesome App'
Get-VcApplication -Application 'My Awesome App'
Get a single object by name. The name is case sensitive.
Expand All @@ -56,8 +56,8 @@
param (

[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
[Alias('applicationId')]
[string] $ID,
[Alias('applicationId', 'ID')]
[string] $Application,

[Parameter(Mandatory, ParameterSetName = 'All')]
[switch] $All,
Expand All @@ -77,13 +77,13 @@
UriLeaf = 'applications'
}

if ( $PSBoundParameters.ContainsKey('ID') ) {
if ( Test-IsGuid($ID) ) {
$params.UriLeaf += "/{0}" -f $ID
if ( $PSBoundParameters.ContainsKey('Application') ) {
if ( Test-IsGuid($Application) ) {
$params.UriLeaf += "/{0}" -f $Application
}
else {
# search by name
$params.UriLeaf += "/name/$ID"
$params.UriLeaf += "/name/$Application"
}
}

Expand Down Expand Up @@ -117,4 +117,4 @@
}, * -ExcludeProperty Id, certificateIssuingTemplateAliasIdMap
}
}
}
}
2 changes: 1 addition & 1 deletion VenafiPS/Public/Get-VcCertificate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
param (

[Parameter(ParameterSetName = 'Id', Mandatory, ValueFromPipelineByPropertyName, Position = 0)]
[Alias('certificateID')]
[Alias('certificateId')]
[string] $ID,

[Parameter(Mandatory, ParameterSetName = 'All')]
Expand Down
20 changes: 10 additions & 10 deletions VenafiPS/Public/Get-VcConnector.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.DESCRIPTION
Get details on 1 or all connectors
.PARAMETER ID
.PARAMETER Connector
Connector ID or name
.PARAMETER All
Expand All @@ -21,7 +21,7 @@
ID
.EXAMPLE
Get-VcConnector -ID 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2' | ConvertTo-Json
Get-VcConnector -Connector 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2' | ConvertTo-Json
{
"connectorId": "a7ddd210-0a39-11ee-8763-134b935c90aa",
Expand All @@ -45,7 +45,7 @@
Get a single object by ID
.EXAMPLE
Get-VcConnector -ID 'My Connector'
Get-VcConnector -Connector 'My Connector'
Get a single object by name. The name is case sensitive.
Expand All @@ -62,8 +62,8 @@
param (

[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipelineByPropertyName, Position = 0)]
[Alias('connectorId')]
[string] $ID,
[Alias('connectorId', 'ID')]
[string] $Connector,

[Parameter(Mandatory, ParameterSetName = 'All')]
[switch] $All,
Expand All @@ -82,13 +82,13 @@
UriLeaf = 'plugins'
}

if ( $PSBoundParameters.ContainsKey('ID') ) {
if ( Test-IsGuid($ID) ) {
$params.UriLeaf += "/{0}" -f $ID
if ( $PSBoundParameters.ContainsKey('Connector') ) {
if ( Test-IsGuid($Connector) ) {
$params.UriLeaf += "/{0}" -f $Connector
}
else {
# search by name
return Get-VcConnector -All | Where-Object { $_.name -eq $ID }
return Get-VcConnector -All | Where-Object { $_.name -eq $Connector }
}
}
else {
Expand All @@ -108,4 +108,4 @@
$connectors | Select-Object @{ 'n' = 'connectorId'; 'e' = { $_.Id } }, @{ 'n' = 'connectorType'; 'e' = { $_.pluginType } }, * -ExcludeProperty Id, pluginType
}
}
}
}
22 changes: 11 additions & 11 deletions VenafiPS/Public/Get-VcIssuingTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Get issuing template info
.DESCRIPTION
Get 1 or more issuing templates
Get 1 or more issuing template details
.PARAMETER ID
.PARAMETER IssuingTemplate
Issuing template ID or name
.PARAMETER All
Expand All @@ -21,7 +21,7 @@
ID
.EXAMPLE
Get-VcIssuingTemplate -ID 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
Get-VcIssuingTemplate -IssuingTemplate 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
issuingTemplateId : 0a19eaf2-b22b-11ea-a1eb-a37c69eabd4e
companyId : 09b24f81-b22b-11ea-91f3-ebd6dea5452f
Expand Down Expand Up @@ -57,7 +57,7 @@
Get a single object by ID
.EXAMPLE
Get-VcIssuingTemplate -ID 'MyTemplate'
Get-VcIssuingTemplate -IssuingTemplate 'MyTemplate'
Get a single object by name. The name is case sensitive.
Expand All @@ -74,8 +74,8 @@
param (

[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipelineByPropertyName, Position = 0)]
[Alias('issuingTemplateId')]
[string] $ID,
[Alias('issuingTemplateId', 'ID')]
[string] $IssuingTemplate,

[Parameter(Mandatory, ParameterSetName = 'All')]
[switch] $All,
Expand All @@ -94,13 +94,13 @@
UriLeaf = 'certificateissuingtemplates'
}

if ( $PSBoundParameters.ContainsKey('ID') ) {
if ( Test-IsGuid($ID) ) {
$params.UriLeaf += "/{0}" -f $ID
if ( $PSBoundParameters.ContainsKey('IssuingTemplate') ) {
if ( Test-IsGuid($IssuingTemplate) ) {
$params.UriLeaf += "/{0}" -f $IssuingTemplate
}
else {
# search by name
return Get-VcIssuingTemplate -All | Where-Object { $_.name -eq $ID }
return Get-VcIssuingTemplate -All | Where-Object { $_.name -eq $IssuingTemplate }
}
}

Expand Down Expand Up @@ -128,4 +128,4 @@
$templates | Select-Object -Property @{'n' = 'issuingTemplateId'; 'e' = { $_.id } }, * -ExcludeProperty id
}
}
}
}
18 changes: 9 additions & 9 deletions VenafiPS/Public/Get-VcMachine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.DESCRIPTION
Get machine details for 1 or all.
.PARAMETER ID
.PARAMETER Machine
Machine ID or name
.PARAMETER All
Expand All @@ -23,10 +23,10 @@
A TLSPC key can also provided.
.INPUTS
ID
Machine
.EXAMPLE
Get-VcMachine -ID 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
Get-VcMachine -Machine 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2'
machineId : cf7cfdc0-2b2a-11ee-9546-5136c4b21504
companyId : cf7cfdc0-2b2a-11ee-9546-5136c4b21504
Expand All @@ -47,7 +47,7 @@
Get a single machine by ID
.EXAMPLE
Get-VcMachine -ID 'MyCitrix'
Get-VcMachine -Machine 'MyCitrix'
Get a single machine by name. The name is case sensitive.
Expand Down Expand Up @@ -102,8 +102,8 @@
param (

[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipelineByPropertyName, Position = 0)]
[Alias('machineId')]
[string] $ID,
[Alias('machineId', 'ID')]
[string] $Machine,

[Parameter(Mandatory, ParameterSetName = 'All')]
[switch] $All,
Expand Down Expand Up @@ -137,9 +137,9 @@
}
}
else {
if ( Test-IsGuid($ID) ) {
if ( Test-IsGuid($Machine) ) {
try {
$response = Invoke-VenafiRestMethod -UriLeaf ('machines/{0}' -f $ID)
$response = Invoke-VenafiRestMethod -UriLeaf ('machines/{0}' -f $Machine)
}
catch {
if ( $_.Exception.Response.StatusCode.value__ -eq 404 ) {
Expand All @@ -153,7 +153,7 @@
}
else {
# no lookup by name directly. search for it and then get details
Find-VcObject -Type 'Machine' -Name $ID | Get-VcMachine
Find-VcObject -Type 'Machine' -Name $Machine | Get-VcMachine
}

if ( $response ) {
Expand Down
48 changes: 34 additions & 14 deletions VenafiPS/Public/Get-VcSatellite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
.DESCRIPTION
Get 1 or more VSatellites. Encyption key and algorithm will be included.
.PARAMETER ID
.PARAMETER VSatellite
VSatellite ID or name
.PARAMETER All
Get all VSatellites
.PARAMETER IncludeWorkers
Include VSatellite workers in the output
.PARAMETER VenafiSession
Authentication for the function.
The value defaults to the script session object $VenafiSession created by New-VenafiSession.
Expand Down Expand Up @@ -56,49 +59,54 @@
Get all VSatellites
.EXAMPLE
Get-VcSatellite -All -IncludeWorkers
Get all VSatellites and include workers
#>

[CmdletBinding()]
[Alias('Get-VaasSatellite')]

param (

[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipelineByPropertyName, Position = 0)]
[Alias('vsatelliteId')]
[string] $ID,
[Parameter(Mandatory, ParameterSetName = 'ID', ValueFromPipelineByPropertyName)]
[Alias('vsatelliteId', 'ID')]
[string] $VSatellite,

[Parameter(Mandatory, ParameterSetName = 'All')]
[switch] $All,

[Parameter()]
[switch] $IncludeWorkers,

[Parameter()]
[psobject] $VenafiSession
)

begin {
Test-VenafiSession -VenafiSession $VenafiSession -Platform 'VC'
$allKeys = Invoke-VenafiRestMethod -UriLeaf 'edgeencryptionkeys' | Select-Object -ExpandProperty encryptionKeys
}

process {

$allKeys = Invoke-VenafiRestMethod -UriLeaf 'edgeencryptionkeys' | Select-Object -ExpandProperty encryptionKeys

if ( $PSCmdlet.ParameterSetName -eq 'All' ) {
$response = Invoke-VenafiRestMethod -UriLeaf 'edgeinstances' | Select-Object -ExpandProperty edgeinstances
}
else {
if ( Test-IsGuid($ID) ) {
$guid = [guid] $ID
# if the value is a guid, we can look up the vsat directly otherwise get all and search by name
if ( Test-IsGuid($VSatellite) ) {
$guid = [guid] $VSatellite
$response = Invoke-VenafiRestMethod -UriLeaf ('edgeinstances/{0}' -f $guid.ToString())
}
else {
# get all and match by name since another method doesn't exist
return Get-VcSatellite -All | Where-Object { $_.name -eq $ID }
$response = Invoke-VenafiRestMethod -UriLeaf 'edgeinstances' | Select-Object -ExpandProperty edgeinstances | Where-Object { $_.name -eq $VSatellite }
}
}

if ( -not $response ) { continue }
if ( -not $response ) { return }

$response | Select-Object @{'n' = 'vsatelliteId'; 'e' = { $_.Id } },
$out = $response | Select-Object @{'n' = 'vsatelliteId'; 'e' = { $_.Id } },
@{
'n' = 'encryptionKey'
'e' = {
Expand All @@ -113,5 +121,17 @@
($allKeys | Where-Object { $_.id -eq $thisId }).KeyAlgorithm
}
}, * -ExcludeProperty Id

if ( $IncludeWorkers ) {
$out | Select-Object *, @{
'n' = 'workers'
'e' = {
Get-VcSatelliteWorker -VSatellite $_.vsatelliteId
}
}
}
else {
$out
}
}
}
}
Loading

0 comments on commit cdc262e

Please sign in to comment.