Skip to content

Commit

Permalink
Merge branch 'master' into bugfix-update-calculateOutput-function
Browse files Browse the repository at this point in the history
  • Loading branch information
Carnes authored and Carnes committed Jun 24, 2020
2 parents cf3dbb1 + 7f38c1e commit 778db11
Show file tree
Hide file tree
Showing 6 changed files with 627 additions and 0 deletions.
123 changes: 123 additions & 0 deletions src/Functions/Public/codestream/Get-vRACodeStreamExecution.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
function Get-vRACodeStreamExecution {
<#
.SYNOPSIS
Retrieve vRA Code Stream Execution depending on input
.DESCRIPTION
Retrieve a list of vRA Code Stream Executions or a single Execution depending on input
.PARAMETER Id
The ID of the vRA Code Stream Execution
.PARAMETER Pipeline
The name of the Pipeline of the vRA Code Stream Execution
.PARAMETER Project
The name of the Project of the vRA Code Stream Execution
.OUTPUTS
System.Management.Automation.PSObject.
.EXAMPLE
Get-vRACodeStreamExecution
.EXAMPLE
Get-vRACodeStreamExecution -Id '96afe0f9-a2ac-4468-8671-a2ca6fdbca37'
.EXAMPLE
Get-vRACodeStreamExecution -Pipeline 'My Pipeline'
.EXAMPLE
Get-vRACodeStreamExecution -Project 'My Project'
#>
[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[]]$Pipeline,

[Parameter(Mandatory=$true,ParameterSetName="ByProject")]
[ValidateNotNullOrEmpty()]
[String[]]$Project

)
Begin {

$APIUrl = "/pipeline/api/executions"

function CalculateOutput($responseObject) {
foreach ($Record in $responseObject.documents.PsObject.Properties) {
[PSCustomObject]@{
Name = $Record.value.name+" #"+$Record.value.index
Project = $Record.value.project
Id = $Record.value.id
LastUpdated = $Record.value.updatedAt
Status = $Record.value.status
StatusMessage = $Record.value.statusMessage
ExecutedBy = $Record.value._executedBy
}
}
}
}
Process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Execution by its id
'ById' {
foreach ($executionId in $Id) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=id eq '$executionId'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Execution by its pipeline name
'ByName' {
foreach ($pipelineName in $Pipeline) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=name eq '$pipelineName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Execution by its project name
'ByProject' {
foreach ($projectName in $Project) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=project eq '$projectName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- No parameters passed so return all executions
'Standard' {
$Response = Invoke-vRARestMethod -URI $APIUrl -Method GET
CalculateOutput($Response)
}

}


}
catch [Exception]{

throw
}
}
End {

}
}
122 changes: 122 additions & 0 deletions src/Functions/Public/codestream/Get-vRACodeStreamPipeline.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
function Get-vRACodeStreamPipeline {
<#
.SYNOPSIS
Retrieve vRA Code Stream Pipeline depending on input
.DESCRIPTION
Retrieve a list of vRA Code Stream Pipelines or a single Pipeline depending on input
.PARAMETER Id
The ID of the vRA Code Stream Pipeline
.PARAMETER Pipeline
The name of the Pipeline of the vRA Code Stream Pipeline
.PARAMETER Project
The name of the Project of the vRA Code Stream Pipeline
.OUTPUTS
System.Management.Automation.PSObject.
.EXAMPLE
Get-vRACodeStreamPipeline
.EXAMPLE
Get-vRACodeStreamPipeline -Id '96afe0f9-a2ac-4468-8671-a2ca6fdbca37'
.EXAMPLE
Get-vRACodeStreamPipeline -Pipeline 'My Pipeline'
.EXAMPLE
Get-vRACodeStreamPipeline -Project 'My Project'
#>
[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[]]$Pipeline,

[Parameter(Mandatory=$true,ParameterSetName="ByProject")]
[ValidateNotNullOrEmpty()]
[String[]]$Project

)
Begin {

$APIUrl = "/pipeline/api/pipelines"

function CalculateOutput($responseObject) {
foreach ($Record in $responseObject.documents.PsObject.Properties) {
[PSCustomObject]@{
Name = $Record.value.name
Project = $Record.value.project
Id = $Record.value.id
LastUpdated = $Record.value.updatedAt
UpdatedBy = $Record.value._updatedBy
State = $Record.value.state
}
}
}
}
Process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Pipeline by its id
'ById' {
foreach ($pipelineId in $Id) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=id eq '$pipelineId'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Pipeline by its pipeline name
'ByName' {
foreach ($pipelineName in $Pipeline) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=name eq '$pipelineName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Pipeline by its project name
'ByProject' {
foreach ($projectName in $Project) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=project eq '$projectName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- No parameters passed so return all Pipelines
'Standard' {
$Response = Invoke-vRARestMethod -URI $APIUrl -Method GET
CalculateOutput($Response)
}

}


}
catch [Exception]{

throw
}
}
End {

}
}
123 changes: 123 additions & 0 deletions src/Functions/Public/codestream/Get-vRACodeStreamVariable.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
function Get-vRACodeStreamVariable {
<#
.SYNOPSIS
Retrieve vRA Code Stream Variable depending on input
.DESCRIPTION
Retrieve a list of vRA Code Stream Variables or a single Variable depending on input
.PARAMETER Id
The ID of the vRA Code Stream Variable
.PARAMETER Variable
The name of the Variable of the vRA Code Stream Variable
.PARAMETER Project
The name of the Project of the vRA Code Stream Variable
.OUTPUTS
System.Management.Automation.PSObject.
.EXAMPLE
Get-vRACodeStreamVariable
.EXAMPLE
Get-vRACodeStreamVariable -Id '96afe0f9-a2ac-4468-8671-a2ca6fdbca37'
.EXAMPLE
Get-vRACodeStreamVariable -Variable 'My Variable'
.EXAMPLE
Get-vRACodeStreamVariable -Project 'My Project'
#>
[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[]]$Variable,

[Parameter(Mandatory=$true,ParameterSetName="ByProject")]
[ValidateNotNullOrEmpty()]
[String[]]$Project

)
Begin {

$APIUrl = "/pipeline/api/variables"

function CalculateOutput($responseObject) {
foreach ($Record in $responseObject.documents.PsObject.Properties) {
[PSCustomObject]@{
Name = $Record.value.name
Project = $Record.value.project
Id = $Record.value.id
Type = $Record.value.type
LastUpdated = $Record.value.updatedAt
CreatedBy = $Record.value._createdBy
Value = $Record.value.value
}
}
}
}
Process {

try {

switch ($PsCmdlet.ParameterSetName) {

# --- Get Variable by its id
'ById' {
foreach ($variableId in $Id) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=id eq '$variableId'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Variable by its name
'ByName' {
foreach ($variableName in $Variable) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=name eq '$variableName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- Get Variable by its project name
'ByProject' {
foreach ($projectName in $Project) {
$Response = Invoke-vRARestMethod -URI "$APIUrl`?`$filter=project eq '$projectName'" -Method GET
CalculateOutput($Response)
}

break
}

# --- No parameters passed so return all Variables
'Standard' {
$Response = Invoke-vRARestMethod -URI $APIUrl -Method GET
CalculateOutput($Response)
}

}


}
catch [Exception]{

throw
}
}
End {

}
}
Loading

0 comments on commit 778db11

Please sign in to comment.