Skip to content

Commit bb9de25

Browse files
authored
surface load balancer networks (#463)
1 parent ed742cd commit bb9de25

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

src/eCloud/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ public function loadBalancerSpecs()
313313
return (new LoadBalancerSpecClient($this->httpClient))->auth($this->token);
314314
}
315315

316+
/**
317+
* @return BaseClient
318+
*/
319+
public function loadBalancerNetworks()
320+
{
321+
return (new LoadBalancerNetworkClient($this->httpClient))->auth($this->token);
322+
}
323+
316324
/**
317325
* @return BaseClient
318326
*/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace UKFast\SDK\eCloud\Entities;
4+
5+
use UKFast\SDK\Entity;
6+
7+
/**
8+
* @property string $id
9+
* @property string $name
10+
* @property string $loadBalancerId
11+
* @property string $networkId
12+
* @property string $sync
13+
* @property string $createdAt
14+
* @property string $updatedAt
15+
*/
16+
class LoadBalancerNetwork extends Entity
17+
{
18+
protected $dates = ['createdAt', 'updatedAt'];
19+
}

src/eCloud/LoadBalancerClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ public function loadEntity($data)
3333
$this->apiToFriendly($data, $this->getEntityMap())
3434
);
3535
}
36+
37+
public function getNetworks($id)
38+
{
39+
return $this->loadBalancerNetworks()->getAllByLoadBalancerId($id);
40+
}
3641
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace UKFast\SDK\eCloud;
4+
5+
use UKFast\SDK\Entities\ClientEntityInterface;
6+
use UKFast\SDK\Traits\PageItems;
7+
use UKFast\SDK\eCloud\Entities\LoadBalancerNetwork;
8+
9+
class LoadBalancerNetworkClient extends Client implements ClientEntityInterface
10+
{
11+
use PageItems;
12+
13+
protected $collectionPath = 'v2/load-balancer-networks';
14+
15+
public function getEntityMap()
16+
{
17+
return [
18+
'id' => 'id',
19+
'name' => 'name',
20+
'load_balancer_id' => 'loadBalancerId',
21+
'network_id' => 'networkId',
22+
'sync' => 'sync',
23+
'created_at' => 'createdAt',
24+
'updated_at' => 'updatedAt',
25+
];
26+
}
27+
28+
public function loadEntity($data)
29+
{
30+
return new LoadBalancerNetwork(
31+
$this->apiToFriendly($data, $this->getEntityMap())
32+
);
33+
}
34+
35+
public function getAllByLoadBalancerId($id)
36+
{
37+
return $this->getAll([
38+
'load_balancer_id' => $id
39+
]);
40+
}
41+
}

0 commit comments

Comments
 (0)