Skip to content

Commit

Permalink
api deprecation (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbarron authored Nov 28, 2024
1 parent 0dc4111 commit d828a2d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 61 deletions.
7 changes: 2 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
- 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.
- Fix bogus error during `New-VcMachineCommonKeystore` [#304](https://github.com/Venafi/VenafiPS/issues/304)
- Update VC machine creation components due to API deprecation
24 changes: 12 additions & 12 deletions VenafiPS/Private/Get-VcData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ function Get-VcData {
[string] $InputObject,

[parameter(Mandatory)]
[ValidateSet('Application', 'MachineType', 'VSatellite', 'Certificate', 'IssuingTemplate', 'Team', 'Machine', 'Tag')]
[ValidateSet('Application', 'VSatellite', 'Certificate', 'IssuingTemplate', 'Team', 'Machine', 'Tag', 'MachinePlugin', 'CaPlugin', 'TppPlugin')]
[string] $Type,

# [parameter()]
# [ValidateSet('InputObject', 'Name', 'Object', 'First')]
# [string] $OutType = 'InputObject',

[parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'Name')]
[switch] $Name,

Expand All @@ -44,7 +40,7 @@ function Get-VcData {

process {

# if we already have a guid, just return it
# if we already have a guid and are just looking for the ID, return it
if ( $PSCmdlet.ParameterSetName -eq 'ID' -and (Test-IsGuid($InputObject)) ) {
return $InputObject
}
Expand Down Expand Up @@ -98,7 +94,9 @@ function Get-VcData {
$thisObject = $allObject | Where-Object { $InputObject -in $_.name, $_.teamId }
}

'MachineType' {
{ $_ -match 'Plugin$' } {
# for machine, ca, tpp, etc plugins

# if ( -not $script:vcMachineType ) {
# $script:vcMachineType = Invoke-VenafiRestMethod -UriLeaf 'machinetypes' |
# Select-Object -ExpandProperty machineTypes |
Expand All @@ -108,11 +106,13 @@ function Get-VcData {
# $allObject = $script:vcMachineType
# $thisObject = $script:vcMachineType | Where-Object { $InputObject -in $_.machineType, $_.machineTypeId }

$allObject = Invoke-VenafiRestMethod -UriLeaf 'machinetypes' |
Select-Object -ExpandProperty machineTypes |
Select-Object -Property @{'n' = 'machineTypeId'; 'e' = { $_.Id } }, * -ExcludeProperty id |
Sort-Object -Property machineType
$thisObject = $allObject | Where-Object { $InputObject -in $_.machineType, $_.machineTypeId }
$pluginType = $_.Replace('Plugin', '').ToUpper()

$allObject = Invoke-VenafiRestMethod -UriLeaf "plugins?pluginType=$pluginType" |
Select-Object -ExpandProperty plugins |
Select-Object -Property @{'n' = ('{0}Id' -f $Type); 'e' = { $_.Id } }, * -ExcludeProperty id

$thisObject = $allObject | Where-Object { $InputObject -in $_.name, $_.('{0}Id' -f $Type) }
}

'Certificate' {
Expand Down
29 changes: 3 additions & 26 deletions VenafiPS/Public/Get-VcConnector.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Get connector info
.DESCRIPTION
Get details on 1 or all connectors
Get details on 1 or all connectors associated with your tenant
.PARAMETER Connector
Connector ID or name
Expand All @@ -18,31 +18,7 @@
A TLSPC key can also provided.
.INPUTS
ID
.EXAMPLE
Get-VcConnector -Connector 'ca7ff555-88d2-4bfc-9efa-2630ac44c1f2' | ConvertTo-Json
{
"connectorId": "a7ddd210-0a39-11ee-8763-134b935c90aa",
"name": "ServiceNow-expiry,
"properties": {
"connectorKind": "WEBHOOK",
"filter": {
"filterType": "EXPIRATION",
"applicationIds": []
},
"target": {
"type": "generic",
"connection": {
"secret": "MySecret",
"url": "https://instance.service-now.com/api/company/endpoint"
}
}
}
}
Get a single object by ID
Connector
.EXAMPLE
Get-VcConnector -Connector 'My Connector'
Expand Down Expand Up @@ -92,6 +68,7 @@
}
}
else {
# getting all by default excludes disabled connectors so let's include them
$params.Body = @{'includeDisabled' = $true }
}

Expand Down
6 changes: 1 addition & 5 deletions VenafiPS/Public/Get-VcMachine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
if ( Test-IsGuid($Machine) ) {
try {
$response = Invoke-VenafiRestMethod -UriLeaf ('machines/{0}' -f $Machine)
$response | Select-Object @{ 'n' = 'machineId'; 'e' = { $_.Id } }, * -ExcludeProperty Id
}
catch {
if ( $_.Exception.Response.StatusCode.value__ -eq 404 ) {
Expand All @@ -155,11 +156,6 @@
# no lookup by name directly. search for it and then get details
Find-VcObject -Type 'Machine' -Name $Machine | Get-VcMachine
}

if ( $response ) {
$response | Select-Object @{ 'n' = 'machineId'; 'e' = { $_.Id } }, * -ExcludeProperty Id
}
}

}
}
20 changes: 10 additions & 10 deletions VenafiPS/Public/New-VcMachine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function New-VcMachine {
.PARAMETER MachineType
Machine type by either ID or name, eg. 'Citrix ADC'.
A list can be found by create a new session and executing $VenafiSession.MachineType.
Get a list of available types by running `Get-VcConnector -All` and looking for connectorType is MACHINE.
.PARAMETER VSatellite
ID or name of a vsatellite.
Expand Down Expand Up @@ -110,7 +110,7 @@ function New-VcMachine {
.NOTES
To see a full list of tab-completion options, be sure to set the Tab option, Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete.
This function requires the use of sodium encryption.
This function requires the use of sodium encryption via PSSodium, https://github.com/TylerLeonhardt/PSSodium, to be installed.
.net standard 2.0 or greater is required via PS Core (recommended) or supporting .net runtime.
On Windows, the latest Visual C++ redist must be installed. See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.
#>
Expand Down Expand Up @@ -176,23 +176,24 @@ function New-VcMachine {
Initialize-PSSodium

$allMachines = [System.Collections.Generic.List[hashtable]]::new()

if ( $Credential ) {
if ( $MachineType -in 'c1521d80-db7a-11ec-b79a-f3ded6c9808c', 'Microsoft IIS' ) { throw 'To create IIS machines, please use New-VcMachineIis' }
if ( $MachineType -in '575389b0-e6be-11ec-9172-d3c56ea8bcf6', 'Common Keystore (PEM, JKS, PKCS#12)' ) { throw 'To create Common Keystore machines, please use New-VcMachineCommonKeystore' }
}
}

process {

Write-Verbose $PSCmdlet.ParameterSetName

$thisMachineType = Get-VcData -InputObject $MachineType -Type 'MachineType' -Object
$thisMachineType = Get-VcData -InputObject $MachineType -Type 'MachinePlugin' -Object
if ( -not $thisMachineType ) {
Write-Error "'$MachineType' is not a valid machine type id or name"
return
}

if ( $PSCmdlet.ParameterSetName -eq 'BasicMachine' ) {
if ( $thisMachineType.name -in 'Microsoft IIS', 'Common Keystore (PEM, JKS, PKCS#12)' ) {
throw 'To create IIS or Common Keystore machines, please use the dedicated function.'
}
}

$ownerId = Get-VcData -InputObject $Owner -Type 'Team'
if ( -not $ownerId ) {
Write-Error "'$Owner' is not a valid team id or name"
Expand Down Expand Up @@ -242,8 +243,7 @@ function New-VcMachine {
name = $Name
edgeInstanceId = $thisEdgeInstanceId
dekId = $thisDekId
machineTypeId = $thisMachineType.machineTypeId
pluginId = $thisMachineType.pluginId
pluginId = $thisMachineType.machinePluginId
owningTeamId = $ownerId
connectionDetails = $thisConnectionDetail
}
Expand Down
2 changes: 1 addition & 1 deletion VenafiPS/Public/New-VcMachineCommonKeystore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function New-VcMachineCommonKeystore {
Test-VenafiSession -VenafiSession $VenafiSession -Platform 'VC'

$allMachines = [System.Collections.Generic.List[pscustomobject]]::new()
$machineTypeId = '575389b0-e6be-11ec-9172-d3c56ea8bcf6'
$machineTypeId = Get-VcData -InputObject 'Common KeyStore (PEM, JKS, PKCS#12)' -Type 'MachinePlugin'

Initialize-PSSodium
}
Expand Down
2 changes: 1 addition & 1 deletion VenafiPS/Public/New-VcMachineIis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function New-VcMachineIis {
Test-VenafiSession -VenafiSession $VenafiSession -Platform 'VC'

$allMachines = [System.Collections.Generic.List[pscustomobject]]::new()
$machineTypeId = 'c1521d80-db7a-11ec-b79a-f3ded6c9808c'
$machineTypeId = Get-VcData -InputObject 'Microsoft IIS' -Type 'MachinePlugin'

Initialize-PSSodium
}
Expand Down
2 changes: 1 addition & 1 deletion VenafiPS/VenafiPS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $vcGenericArgCompleterSb = {

'MachineType' {
if ( -not $script:vcMachineType ) {
$script:vcMachineType = Invoke-VenafiRestMethod -UriLeaf 'machinetypes' |
$script:vcMachineType = Invoke-VenafiRestMethod -UriLeaf 'plugins?pluginType=MACHINE' |
Select-Object -ExpandProperty machineTypes |
Select-Object -Property @{'n' = 'machineTypeId'; 'e' = { $_.Id } }, * -ExcludeProperty id |
Sort-Object -Property machineType
Expand Down

0 comments on commit d828a2d

Please sign in to comment.