3
3
namespace UKFast \SDK \Loadbalancers ;
4
4
5
5
use UKFast \SDK \Client as BaseClient ;
6
+ use UKFast \SDK \Loadbalancers \Entities \Deployment ;
6
7
7
8
class DeploymentClient extends BaseClient
8
9
{
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
+
9
19
protected $ basePath = 'loadbalancers/ ' ;
10
20
11
21
/**
@@ -29,4 +39,23 @@ public function validate($clusterId)
29
39
30
40
return $ response ->getStatusCode () == 200 ;
31
41
}
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
+ }
32
61
}
0 commit comments