LKDevelopment / hetzner-cloud-php-sdk

A PHP SDK for the Hetzner Cloud API
MIT License
104 stars 51 forks source link

LoadBalancer handling overly complex #109

Open cztk opened 9 months ago

cztk commented 9 months ago

This can't be meant how it's to be used is it?

$lb = $hetznerClient->loadBalancers()->getByName('...');
foreach($lb->targets as $target) {
    $ip = new LoadBalancerTargetIp($target->ip->ip);
    $lb->removeTarget('ip', $ip);
}

Same for addTarget

How I expected it to work;

$lb = $hetznerClient->loadBalancers()->getByName('...');
foreach($lb->targets as $target) {
    $lb->removeTarget($target);
   # or maybe, or make it smart and work with $target only aswell
    $lb->removeTargetByIp($target->ip);
}

Also missing a removeTargets($targets);