Skip to content

Commit

Permalink
Loadbalancer Error Pages (#505)
Browse files Browse the repository at this point in the history
* Removed duplicate method

* Added ErrorPageClient and Entity.

LB-53 LBV2 SDK: Add Error Page elements to SDK

Co-authored-by: Tim Green <[email protected]>
  • Loading branch information
rawveg and Tim Green authored Nov 28, 2022
1 parent 4de1aba commit f6a830c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Loadbalancers/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public function deployments()
{
return (new DeploymentClient($this->httpClient))->auth($this->token);
}

public function errorPages()
{
return (new ErrorPageClient($this->httpClient))->auth($this->token);
}
}
18 changes: 18 additions & 0 deletions src/Loadbalancers/Entities/ErrorPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace UKFast\SDK\Loadbalancers\Entities;

use UKFast\SDK\Entity;

/**
* @property int $id
* @property int $targetGroupId
* @property string $statusCodes
* @property string $content
* @property \DateTime $createdAt
* @property \DateTime $updatedAt
*/
class ErrorPage extends Entity
{
protected $dates = ['createdAt', 'updatedAt'];
}
33 changes: 33 additions & 0 deletions src/Loadbalancers/ErrorPageClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace UKFast\SDK\Loadbalancers;

use UKFast\SDK\Entities\ClientEntityInterface;
use UKFast\SDK\Loadbalancers\Entities\ErrorPage;
use UKFast\SDK\Traits\PageItems;

class ErrorPageClient extends Client implements ClientEntityInterface
{
use PageItems;

protected $collectionPath = 'v2/error-pages';

public function getEntityMap()
{
return [
'id' => 'id',
'target_group_id' => 'targetGroupId',
'status_codes' => 'statusCodes',
'content' => 'content',
'created_at' => 'createdAt',
'updated_at' => 'updatedAt',
];
}

public function loadEntity($data)
{
return new ErrorPage(
$this->apiToFriendly($data, $this->getEntityMap())
);
}
}

0 comments on commit f6a830c

Please sign in to comment.