Skip to content

Commit

Permalink
Merge pull request #240 from mpuckett159/master
Browse files Browse the repository at this point in the history
Add new Get functions
  • Loading branch information
jonathanmedd authored Jan 27, 2021
2 parents dab1581 + 0554a48 commit ca34692
Show file tree
Hide file tree
Showing 29 changed files with 2,955 additions and 5 deletions.
146 changes: 146 additions & 0 deletions src/Functions/Public/blueprint/Get-vRABlueprint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
function Get-vRABlueprint {
<#
.SYNOPSIS
Get a vRA Blueprint
.DESCRIPTION
Get a vRA Blueprint
.PARAMETER Id
The ID of the Blueprint
.PARAMETER Name
The Name of the Blueprint
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRABlueprint
.EXAMPLE
Get-vRABlueprint -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9'
.EXAMPLE
Get-vRABlueprint -Name 'TestBlueprint'
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="ById")]
[ValidateNotNullOrEmpty()]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
[String[]]$Name
)

begin {
$APIUrl = '/blueprint/api/blueprints'

function CalculateOutput([PSCustomObject]$Blueprint) {

[PSCustomObject] @{
Name = $Blueprint.name
Content = $Blueprint.content
Id = $Blueprint.id
CreatedAt = $Blueprint.createdAt
CreatedBy = $Blueprint.createdBy
UpdatedAt = $Blueprint.updatedAt
UpdatedBy = $Blueprint.updatedBy
OrgId = $Blueprint.orgId
ProjectId = $Blueprint.projectId
ProjectName = $Blueprint.projectName
Description = $Blueprint.description
Status = $Blueprint.status
TotalVersions = $Blueprint.totalVersions
TotalReleasedVersions = $Blueprint.totalReleasedVersions
RequestScopeOrg = $Blueprint.requestScopeOrg
Valid = $Blueprint.valid
ValidationMessages = $Blueprint.validationMessages
ContentSourceSyncMessages = $Blueprint.contentSourceSyncMessages
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Blueprint by Id
'ById' {

foreach ($BlueprintId in $Id){

$URI = "$($APIUrl)/$($BlueprintId)"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach($Blueprint in $Response){
CalculateOutput $Blueprint
}
}

break
}
# --- Get Blueprint by Name
'ByName' {

foreach ($BlueprintName in $Name){

$URI = "$($APIUrl)"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($Blueprint in $Response.content) {
if($Blueprint.name -eq $BlueprintName){
# Get individual blueprint link
$BlueprintSelfLink = $blueprint.selfLink

# Get full blueprint resource info
$FullBlueprints = Invoke-vRARestMethod -Method GET -URI $BlueprintSelfLink -Verbose:$VerbosePreference
foreach ($FullBlueprint in $FullBlueprints){
CalculateOutput $FullBlueprint
}
}
}
}

break
}
# --- No parameters passed so return all Blueprints
'Standard' {

$URI = $APIUrl
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($Blueprint in $Response.content) {
# Get individual blueprint link
$BlueprintSelfLink = $blueprint.selfLink

# Get full blueprint resource info
$FullBlueprints = Invoke-vRARestMethod -Method GET -URI $BlueprintSelfLink -Verbose:$VerbosePreference
foreach ($FullBlueprint in $FullBlueprints){
CalculateOutput $FullBlueprint
}
}
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

97 changes: 97 additions & 0 deletions src/Functions/Public/blueprint/Get-vRABlueprintVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
function Get-vRABlueprintVersion {
<#
.SYNOPSIS
Get a vRA Blueprint's Versions
.DESCRIPTION
Get a vRA Blueprint's Versions
.PARAMETER Blueprint
The vRA Blueprint object as returned by Get-vRABlueprint
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRABlueprint | Get-vRABlueprintVersion
.EXAMPLE
Get-vRABlueprintVersion -Blueprint (Get-vRABlueprint -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9')
.EXAMPLE
Get-vRABlueprintVersion -Blueprint (Get-vRABlueprint -Name 'TestBlueprint')
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="Blueprint")]
[ValidateNotNullOrEmpty()]
[PSCustomObject[]]$Blueprint
)

begin {
$APIUrl = '/blueprint/api/blueprints'

function CalculateOutput([PSCustomObject]$BlueprintVersion) {

[PSCustomObject] @{
Id = $BlueprintVersion.id
CreatedAt = $BlueprintVersion.createdAt
CreatedBy = $BlueprintVersion.createdBy
UpdatedAt = $BlueprintVersion.updatedAt
UpdatedBy = $BlueprintVersion.updatedBy
OrganizationId = $BlueprintVersion.orgId
ProjectId = $BlueprintVersion.projectId
ProjectName = $BlueprintVersion.projectName
SelfLink = $BlueprintVersion.selfLink
BlueprintId = $BlueprintVersion.blueprintId
Name = $BlueprintVersion.name
Description = $BlueprintVersion.description
Version = $BlueprintVersion.version
Status = $BlueprintVersion.status
VersionDescription = $BlueprintVersion.versionDescription
VersionChangeLog = $BlueprintVersion.versionChangeLog
Valid = $BlueprintVersion.valid
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get BlueprintVersion from Blueprint object
'Blueprint' {

foreach ($Blueprintobj in $Blueprint){

$URI = "$($APIUrl)/$($Blueprintobj.Id)/versions"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach($version in $Response.content){
CalculateOutput $version
}
}

break
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

126 changes: 126 additions & 0 deletions src/Functions/Public/catalog/Get-vRACatalogItem.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
function Get-vRACatalogItem {
<#
.SYNOPSIS
Get a vRA Catalog Item
.DESCRIPTION
Get a vRA Catalog Item
.PARAMETER Id
The ID of the Catalog Item
.PARAMETER Name
The Name of the Catalog Item
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSObject
.EXAMPLE
Get-vRACatalogItem
.EXAMPLE
Get-vRACatalogItem -Id '3492a6e8-r5d4-1293-b6c4-39037ba693f9'
.EXAMPLE
Get-vRACatalogItem -Name 'TestCatalogItem'
#>
[CmdletBinding(DefaultParameterSetName="Standard")][OutputType('System.Management.Automation.PSObject')]

Param (

[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName="ById")]
[ValidateNotNullOrEmpty()]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
[String[]]$Name
)

begin {
$APIUrl = '/catalog/api/items'

function CalculateOutput([PSCustomObject]$CatalogItem) {

[PSCustomObject] @{
Id = $CatalogItem.id
Name = $CatalogItem.name
Description = $CatalogItem.description
Type = $CatalogItem.type
ProjectIds = $CatalogItem.projectIds
CreatedAt = $CatalogItem.createdAt
CreatedBy = $CatalogItem.createdBy
LastUpdatedAt = $CatalogItem.lastUpdatedAt
LastUpdatedBy = $CatalogItem.lastUpdatedBy
IconId = $CatalogItem.iconId
BulkRequestLimit = $CatalogItem.bulkRequestLimit
}
}
}

process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Catalog Item by Id
'ById' {

foreach ($CatalogItemId in $Id){

$URI = "$($APIUrl)?`$filter=id eq '$($CatalogItemId)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($CatalogItem in $Response.content) {

CalculateOutput $CatalogItem
}
}

break
}
# --- Get Catalog Item by Name
'ByName' {

foreach ($CatalogItemName in $Name){

$URI = "$($APIUrl)?`$filter=name eq '$($CatalogItemName)'"
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($CatalogItem in $Response.content){

CalculateOutput $CatalogItem
}
}

break
}
# --- No parameters passed so return all Catalog Items
'Standard' {

$URI = $APIUrl
$Response = Invoke-vRARestMethod -Method GET -URI $URI -Verbose:$VerbosePreference

foreach ($CatalogItem in $Response.content){

CalculateOutput $CatalogItem
}
}
}
}
catch [Exception]{

throw
}
}

end {

}
}

Loading

0 comments on commit ca34692

Please sign in to comment.