Skip to content

Commit f6a830c

Browse files
rawvegTim Green
and
Tim Green
authored
Loadbalancer Error Pages (#505)
* Removed duplicate method * Added ErrorPageClient and Entity. LB-53 LBV2 SDK: Add Error Page elements to SDK Co-authored-by: Tim Green <tim.green@ukfast.co.uk>
1 parent 4de1aba commit f6a830c

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

src/Loadbalancers/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ public function deployments()
5252
{
5353
return (new DeploymentClient($this->httpClient))->auth($this->token);
5454
}
55+
56+
public function errorPages()
57+
{
58+
return (new ErrorPageClient($this->httpClient))->auth($this->token);
59+
}
5560
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace UKFast\SDK\Loadbalancers\Entities;
4+
5+
use UKFast\SDK\Entity;
6+
7+
/**
8+
* @property int $id
9+
* @property int $targetGroupId
10+
* @property string $statusCodes
11+
* @property string $content
12+
* @property \DateTime $createdAt
13+
* @property \DateTime $updatedAt
14+
*/
15+
class ErrorPage extends Entity
16+
{
17+
protected $dates = ['createdAt', 'updatedAt'];
18+
}

src/Loadbalancers/ErrorPageClient.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace UKFast\SDK\Loadbalancers;
4+
5+
use UKFast\SDK\Entities\ClientEntityInterface;
6+
use UKFast\SDK\Loadbalancers\Entities\ErrorPage;
7+
use UKFast\SDK\Traits\PageItems;
8+
9+
class ErrorPageClient extends Client implements ClientEntityInterface
10+
{
11+
use PageItems;
12+
13+
protected $collectionPath = 'v2/error-pages';
14+
15+
public function getEntityMap()
16+
{
17+
return [
18+
'id' => 'id',
19+
'target_group_id' => 'targetGroupId',
20+
'status_codes' => 'statusCodes',
21+
'content' => 'content',
22+
'created_at' => 'createdAt',
23+
'updated_at' => 'updatedAt',
24+
];
25+
}
26+
27+
public function loadEntity($data)
28+
{
29+
return new ErrorPage(
30+
$this->apiToFriendly($data, $this->getEntityMap())
31+
);
32+
}
33+
}

0 commit comments

Comments
 (0)