Skip to content

Commit

Permalink
feat: add name param to Get-VCFPersonality (#257)
Browse files Browse the repository at this point in the history
Updated `Get-VCFPersonality` cmdlet with optional parameter `name`.

Signed-off-by: Nathan Thaler <nathan.thaler@broadcom.com>
  • Loading branch information
nthaler-vmware committed Jan 10, 2024
1 parent 960caaf commit b6afdcf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
> Released: Unreleased
- Updated `Get-VCFSystemPrecheckTask` cmdlet with optional parameter `failureOnly`.
- Updated `Get-VCFPersonality` cmdlet with optional parameter `name`.


## v2.4.1

Expand Down
2 changes: 1 addition & 1 deletion PowerVCF.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'PowerVCF.psm1'

# Version number of this module.
ModuleVersion = '2.5.0.1000'
ModuleVersion = '2.5.0.1001'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
23 changes: 20 additions & 3 deletions PowerVCF.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3265,18 +3265,24 @@ Function Get-VCFPersonality {
Get-VCFPersonality -id b4e3b2c4-31e8-4816-b1c5-801e848bef09
This example shows how to retrieve a vSphere Lifecycle Manager personality by unique ID.
.EXAMPLE
Get-VCFPersonality -name vSphere-8.0U1
This example shows how to retrieve a vSphere Lifecycle Manager personality by name.
.PARAMETER id
Specifies the unique ID of the vSphere Lifecycle Manager personality.
#>

Param (
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$id
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$id,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$name
)

Try {
createHeader # Set the Accept and Authorization headers.
checkVCFToken # Validate the access token and refresh, if necessary.
if ( -not $PsBoundParameters.ContainsKey("id")) {

if ((-Not $PsBoundParameters.ContainsKey('id')) -and (-Not $PsBoundParameters.ContainsKey('name'))) {
$uri = "https://$sddcManager/v1/personalities"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
$response.elements
Expand All @@ -3285,7 +3291,18 @@ Function Get-VCFPersonality {
$uri = "https://$sddcManager/v1/personalities/$id"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
$response
}
}
if ($PsBoundParameters.ContainsKey("name")) {
$uri ="https://$sddcManager/v1/personalities?personalityName=$name"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
# depending on the composition of the image, the response body may or may not contain elements
if (!$response.elements) {
$response
} else {
$response.elements
}
}

} Catch {
ResponseException -object $_
}
Expand Down
27 changes: 26 additions & 1 deletion docs/documentation/functions/personalities/Get-VCFPersonality.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Retrieves the vSphere Lifecycle Manager personalities.
## Syntax

```powershell
Get-VCFPersonality [[-id] <String>] [<CommonParameters>]
Get-VCFPersonality [[-id] <String>] [[-name] <String>] [<CommonParameters>]
```

## Description
Expand All @@ -32,6 +32,15 @@ Get-VCFPersonality -id b4e3b2c4-31e8-4816-b1c5-801e848bef09

This example shows how to retrieve a vSphere Lifecycle Manager personality by unique ID.

### Example 3

```powershell
Get-VCFPersonality -name vSphere-8.0U1
```

This example shows how to retrieve a vSphere Lifecycle Manager personality by unique name.


## Parameters

### -id
Expand All @@ -50,6 +59,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -name

Specifies the unique name of the vSphere Lifecycle Manager personality.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### Common Parameters

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).

0 comments on commit b6afdcf

Please sign in to comment.