Modules/Get-RestOcto.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<#
.SYNOPSIS
Makes a raw REST request to the configured Octopus instance
 
.DESCRIPTION
Perform a GET request against the given path fragment of the configured Octopus instance
 
.PARAMETER path
The API resource to get
 
.EXAMPLE
Get-RestOcto '/api/users/me'
 
.NOTES
You must have configured OctoVsts to use this with Initialize-OctoVsts
#>

function Get-RestOcto {
    param (
        [string] $path
    )
    $apikey = [System.Environment]::GetEnvironmentVariable('Octo-ApiKey', 'User')
    $OctopusURI = [System.Environment]::GetEnvironmentVariable('Octo-Uri', 'User')

    $url = $OctopusURI + $path
    Invoke-RestMethod -Method Get -Uri $url -Headers @{ "X-Octopus-ApiKey" = $apikey } -Verbose:$VerbosePreference
}