Skip to content

Commit c683a4c

Browse files
authored
Merge pull request #456 from rbibby/master
Add ability to get LB deployments
2 parents 0423373 + 2e579b3 commit c683a4c

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/Loadbalancers/DeploymentClient.php

+29
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
namespace UKFast\SDK\Loadbalancers;
44

55
use UKFast\SDK\Client as BaseClient;
6+
use UKFast\SDK\Loadbalancers\Entities\Deployment;
67

78
class DeploymentClient extends BaseClient
89
{
10+
const MAP = [
11+
'cluster_id' => 'clusterId',
12+
'requested_by_type' => 'requestedByType',
13+
'requested_by_id' => 'requestedById',
14+
'pss_id' => 'pssId',
15+
'created_at' => 'createdAt',
16+
'updated_at' => 'updatedAt',
17+
];
18+
919
protected $basePath = 'loadbalancers/';
1020

1121
/**
@@ -29,4 +39,23 @@ public function validate($clusterId)
2939

3040
return $response->getStatusCode() == 200;
3141
}
42+
43+
public function getPage($page = 1, $perPage = 15, $filters = [])
44+
{
45+
$filters = $this->friendlyToApi($filters, self::MAP);
46+
$page = $this->paginatedRequest('v2/deployments', $page, $perPage, $filters);
47+
$page->serializeWith(function ($item) {
48+
return new Deployment($this->apiToFriendly($item, self::MAP));
49+
});
50+
51+
return $page;
52+
}
53+
54+
public function getById($id)
55+
{
56+
$response = $this->request("GET", "v2/deployments/$id");
57+
$body = $this->decodeJson($response->getBody()->getContents());
58+
59+
return new Deployment($this->apiToFriendly($body->data, self::MAP));
60+
}
3261
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace UKFast\SDK\Loadbalancers\Entities;
4+
5+
use UKFast\SDK\Entity;
6+
7+
/**
8+
* @property int $id
9+
* @property int $clusterId
10+
* @property bool $successful
11+
* @property string $requestedByType
12+
* @property string $requestedById
13+
* @property int $pssId
14+
* @property \DateTime $createdAt
15+
* @property \DateTime $updatedAt
16+
*/
17+
class Deployment extends Entity
18+
{
19+
protected $dates = ['createdAt', 'updatedAt'];
20+
}

0 commit comments

Comments
 (0)