@@ -64,20 +64,14 @@ public function getServices(Request $request, Response $response, array $args =
64
64
65
65
public function getDeployments (Request $ request , Response $ response , array $ args = []): Response
66
66
{
67
- $ path = explode ('/ ' , trim ($ request ->getUri ()->getPath (), '/ ' ));
68
- if (implode ('/ ' , array_slice ($ path , 0 , 3 )) !== 'api/if/svc ' || !isset ($ path [3 ])) {
69
- throw new \Exception ('Invalid path ' );
67
+ $ db = new Sql ($ this ->pg , 'if__deployments ' );
68
+ $ qp = $ request ->getQueryParams ();
69
+ $ filters = ['uuid ' , 'service ' ];
70
+ foreach ($ filters as $ filter ) {
71
+ if (!empty ($ qp [$ filter ])) { $ db ->where ($ filter , '= ' , $ qp [$ filter ]); }
70
72
}
71
- $ service = $ path [3 ];
72
- $ this ->deployments ->where ('service ' , '= ' , $ service );
73
- $ this ->deployments ->selectModifier = "jsonb_build_object('uri', concat(' {$ this ->settings ['glued ' ]['baseuri ' ]}{$ this ->settings ['routes ' ]['be_if ' ]['pattern ' ]}svc/', doc->>'service', '/v1/', doc->>'uuid')) || " ;
74
- $ data = $ this ->deployments ->getAll ();
75
- $ xfi = new ArrayTransformer ();
76
- $ xfi ->map ('uri ' , 'uri ' , 'required ' )
77
- ->map ('uuid ' , 'uuid ' , 'required ' )
78
- ->map ('name ' , 'name ' , 'required ' )
79
- ->map ('description ' , 'description ' );
80
- $ data = $ xfi ->toArrays ($ data );
73
+ $ db ->selectModifier = "jsonb_build_object('uri', concat(' {$ this ->settings ['glued ' ]['baseuri ' ]}{$ this ->settings ['routes ' ]['be_if ' ]['pattern ' ]}svc/', doc->>'service', '/v1/', doc->>'uuid'), 'nonce', nonce, 'created_at', created_at, 'updated_at', updated_at) || " ;
74
+ $ data = $ db ->getAll ();
81
75
return $ response ->withJson ($ data );
82
76
}
83
77
0 commit comments