Skip to content

Commit 0a0b951

Browse files
authored
Merge pull request #471 from Gman98ish/cert-endpoints
Setup cert client
2 parents 8f103f4 + d9ac30f commit 0a0b951

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

src/Loadbalancers/CertClient.php

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace UKFast\SDK\Loadbalancers;
4+
5+
use UKFast\SDK\Client as BaseClient;
6+
use UKFast\SDK\Loadbalancers\Entities\Cert;
7+
8+
class CertClient extends BaseClient
9+
{
10+
protected $basePath = 'loadbalancers/';
11+
12+
const MAP = [
13+
'listener_id' => 'listenerId',
14+
'created_at' => 'createdAt',
15+
'updated_at' => 'updatedAt',
16+
'expires_at' => 'expiresAt',
17+
'ca_bundle' => 'caBundle',
18+
];
19+
20+
/**
21+
* Gets a paginated response of all Certs
22+
*
23+
* @param int $page
24+
* @param int $perPage
25+
* @param array $filters
26+
* @return \UKFast\SDK\Page
27+
*/
28+
public function getPage($page = 1, $perPage = 15, $filters = [])
29+
{
30+
$filters = $this->friendlyToApi($filters, self::MAP);
31+
$page = $this->paginatedRequest('v2/certs', $page, $perPage, $filters);
32+
$page->serializeWith(function ($item) {
33+
return $this->serializeCert($item);
34+
});
35+
36+
return $page;
37+
}
38+
39+
/**
40+
* @return \UKFast\SDK\Loadbalancers\Entities\Cert
41+
*/
42+
public function serializeCert($raw)
43+
{
44+
return new Cert($this->apiToFriendly($raw, self::MAP));
45+
}
46+
}

src/Loadbalancers/Client.php

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function vips()
3737
{
3838
return (new VipClient($this->httpClient))->auth($this->token);
3939
}
40+
41+
public function certs()
42+
{
43+
return (new CertClient($this->httpClient))->auth($this->token);
44+
}
4045

4146
public function accessIps()
4247
{

src/Loadbalancers/ListenerClient.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class ListenerClient extends BaseClient implements ClientEntityInterface
4040

4141
const CERT_MAP = [
4242
'frontend_id' => 'frontendId',
43-
'ca_bundle' => 'caBundle'
43+
'ca_bundle' => 'caBundle',
44+
'expires_at' => 'expiresAt',
4445
];
4546

4647

0 commit comments

Comments
 (0)