Discover Machines via Proxy
pixman20 opened this issue · comments
Currently the Discover function in MachineRepository.cs does not take a proxy id, but the url template and rest api allow for it.
Something like the following should work (I was unable to build and test due to Cake issues or I'd open a PR myself).
public MachineResource Discover(string host, int port = 10933, DiscoverableEndpointType type, String proxyId)
{
return Client.Get<MachineResource>(Client.RootDocument.Link("DiscoverMachine"), new { host, port, type, proxyId });
}
The current workaround using Powershell is
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $octoDll = $null,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $octoUrl = $null,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $octoApiKey = $null,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $hostname = $null,
[Parameter(Mandatory=$false)]
[string] $port = 10933,
[Parameter(Mandatory=$false)]
[string] $type = "TentaclePassive",
[Parameter(Mandatory=$false)]
[string] $proxyId = $null
)
Add-Type -Path $octoDll
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octoUrl,$octoApiKey
$octoRepo = New-Object Octopus.Client.OctopusRepository $endpoint
$urlParams = "?host=$hostname&port=$port&type=$type"
if(-not [string]::IsNullOrEmpty($proxyId)) {
$urlParams += '&proxyId=' + $proxyId
}
$client = $octoRepo.Machines.Client
$path = $client.RootDocument.Link("DiscoverMachine")
$path = $path -replace '\{.*', $urlParams
$method = $client.GetType().GetMethod("Get")
$genericMethod = $method.MakeGenericMethod([Octopus.Client.Model.MachineResource])
$server = $genericMethod.Invoke($client, @($path, $null))
return $server
Fixed in 4.33.0