I’m writing a function by using Octopus API, where I’m supposed to pass Environment name (Or ID) as input parameter and I’ll get all tenant name(s) associated to it as output.
Is there any straight forward way to fulfill this requirement(?).
This should be fairly easy to retrieve the environment information.
/api/environments will return a list of your environments with name and ID fields included.
If you’re using the octopus.client then this will retrieve the same information
$apikey = 'API-LREN0HDYII3BMDXP5A6X8NF3TCY' # Get this from your profile
$OctopusUrl = 'http://localhost/' # Your Octopus Server address
# You can this dll from your Octopus Server/Tentacle installation directory or from
# https://www.nuget.org/packages/Octopus.Client/
Add-Type -Path 'Octopus.Client.dll'
# Set up endpoint and Spaces repository
$endpoint = new-object Octopus.Client.OctopusServerEndpoint $OctopusUrl, $APIKey
$repository = New-Object Octopus.Client.OctopusRepository $endpoint
$repository.Environments.FindAll()