Skip to content

Commit

Permalink
feat: add vrslcm api functions (#439)
Browse files Browse the repository at this point in the history
- Locate `Get-`, `Set-` and `Remove-vRSLCMMyVmwareAccount` cmdlets together in the file
- Enhanced `Get-vRSLCMSshStatus` cmdlet with check for token.
- Enhanced `Set-vRSLCMSshStatus` cmdlet with check for token.

No update to CHANGELOG.md as functions are not released yet.

Signed-off-by: Gary Blake <gblake@vmware.com>
  • Loading branch information
GaryJBlake authored Dec 15, 2023
1 parent 69bbfa7 commit 9335ecf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 45 deletions.
2 changes: 1 addition & 1 deletion PowerValidatedSolutions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'PowerValidatedSolutions.psm1'

# Version number of this module.
ModuleVersion = '2.8.0.1016'
ModuleVersion = '2.8.0.1017'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
96 changes: 52 additions & 44 deletions PowerValidatedSolutions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -32630,7 +32630,7 @@ Function Get-vRSLCMMyVmwareAccount {
.EXAMPLE
Get-vRSLCMMyVmwareAccount
This example retrieves all the My VMware Accounts assigned in VMware Aria Suite Lifecycle.
#>
#>

Try {
if ($vrslcmAppliance) {
Expand All @@ -32645,39 +32645,6 @@ Function Get-vRSLCMMyVmwareAccount {
}
Export-ModuleMember -Function Get-vRSLCMMyVmwareAccount

Function Get-vRSLCMProductVersion {
<#
.SYNOPSIS
Get supported version for a product.

.DESCRIPTION
The Get-vRSLCMProductVersion cmdlet retrieves supported versions of a product from VMware Aria Suite Lifecycle

.EXAMPLE
Get-vRSLCMProductVersion -productId vra
This example retrieves the supported versions for VMware Aria Automation.

.PARAMETER productId
The product to get the supported versions for.
#>

Param (
[Parameter (Mandatory = $false)] [ValidateSet("vidm", "vra", "vrli", "vrni", "vrops", "vro", "vssc")][ValidateNotNullOrEmpty()] [String]$productId
)

Try {
if ($vrslcmAppliance) {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/policy/products/$productId/versions"
Invoke-RestMethod $uri -Method 'GET' -Headers $vrslcmHeaders
} else {
Write-Error "Not connected to VMware Aria Suite Lifecycle, run Request-vRSLCMToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
}
Export-ModuleMember -Function Get-vRSLCMProductVersion

Function New-vRSLCMMyVmwareAccount {
<#
.SYNOPSIS
Expand All @@ -32692,7 +32659,7 @@ Function New-vRSLCMMyVmwareAccount {

.PARAMETER alias
The alias of the My VMware account to add to VMware Aria Suite Lifecycle.
#>
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$alias
Expand Down Expand Up @@ -32731,7 +32698,7 @@ Function Remove-vRSLCMMyVmwareAccount {

.PARAMETER alias
The alias of the My VMware account to remove from VMware Aria Suite Lifecycle.
#>
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$alias
Expand All @@ -32756,6 +32723,39 @@ Function Remove-vRSLCMMyVmwareAccount {
}
Export-ModuleMember -Function Remove-vRSLCMMyVmwareAccount

Function Get-vRSLCMProductVersion {
<#
.SYNOPSIS
Get supported version for a product.

.DESCRIPTION
The Get-vRSLCMProductVersion cmdlet retrieves supported versions of a product from VMware Aria Suite Lifecycle

.EXAMPLE
Get-vRSLCMProductVersion -productId vra
This example retrieves the supported versions for VMware Aria Automation.

.PARAMETER productId
The product to get the supported versions for.
#>

Param (
[Parameter (Mandatory = $false)] [ValidateSet("vidm", "vra", "vrli", "vrni", "vrops", "vro", "vssc")][ValidateNotNullOrEmpty()] [String]$productId
)

Try {
if ($vrslcmAppliance) {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/policy/products/$productId/versions"
Invoke-RestMethod $uri -Method 'GET' -Headers $vrslcmHeaders
} else {
Write-Error "Not connected to VMware Aria Suite Lifecycle, run Request-vRSLCMToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
}
Export-ModuleMember -Function Get-vRSLCMProductVersion

Function Request-vRSLCMProductBinary {
<#
.SYNOPSIS
Expand All @@ -32781,7 +32781,7 @@ Function Request-vRSLCMProductBinary {

.PARAMETER productDownloadType
The type of product binary to download.
#>
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$version,
Expand Down Expand Up @@ -32829,11 +32829,15 @@ Function Get-vRSLCMSshStatus {
.EXAMPLE
Get-vRSLCMSshStatus
This example gets the SSH services.
#>
#>

Try {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/settings/ssh"
Invoke-RestMethod $uri -Method 'GET' -Headers $vrslcmHeaders
if ($vrslcmAppliance) {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/settings/ssh"
Invoke-RestMethod $uri -Method 'GET' -Headers $vrslcmHeaders
} else {
Write-Error "Not connected to VMware Aria Suite Lifecycle, run Request-vRSLCMToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
Expand All @@ -32851,16 +32855,20 @@ Function Set-vRSLCMSshStatus {
.EXAMPLE
Set-vRSLCMSshStatus -enabled false
This example disables the SSH services.
#>
#>

Param (
[Parameter (Mandatory = $true)] [ValidateSet('true','false')] [String]$enabled
)

Try {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/settings/ssh"
$body = '{"sshStatus": "'+ $enabled +'"}'
Invoke-RestMethod $uri -Method 'POST' -Headers $vrslcmHeaders -Body $body
if ($vrslcmAppliance) {
$uri = "https://$vrslcmAppliance/lcm/lcops/api/v2/settings/ssh"
$body = '{"sshStatus": "'+ $enabled +'"}'
Invoke-RestMethod $uri -Method 'POST' -Headers $vrslcmHeaders -Body $body
} else {
Write-Error "Not connected to VMware Aria Suite Lifecycle, run Request-vRSLCMToken and try again"
}
} Catch {
Write-Error $_.Exception.Message
}
Expand Down

0 comments on commit 9335ecf

Please sign in to comment.