33namespace UKFast \SDK \Loadbalancers ;
44
55use UKFast \SDK \Client as BaseClient ;
6+ use UKFast \SDK \Loadbalancers \Entities \Deployment ;
67
78class 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}
0 commit comments