Skip to content

Commit e36cc4f

Browse files
authored
Add list method to API
1 parent d0b79d0 commit e36cc4f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Service/BrancherApp.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@
99

1010
class BrancherApp extends AbstractService
1111
{
12+
/**
13+
* List all brancher nodes for given parent app.
14+
*
15+
* @param string $app Name of the parent app
16+
* @param array|null $data Extra data to be provided
17+
* @return array Array containing brancher nodes
18+
* @throws HypernodeApiClientException
19+
* @throws HypernodeApiServerException
20+
*/
21+
public function list(string $app, ?array $data = null): array
22+
{
23+
$url = sprintf(App::V2_APP_BRANCHER_URL, $app);
24+
25+
$response = $this->client->api->get($url, [], $data ? json_encode($data) : null);
26+
27+
$this->client->maybeThrowApiExceptions($response);
28+
29+
$data = $this->client->getJsonFromResponse($response);
30+
31+
return $data['branchers'];
32+
}
33+
1234
/**
1335
* Create a brancher app for given parent app.
1436
*
@@ -20,7 +42,7 @@ class BrancherApp extends AbstractService
2042
*/
2143
public function create(string $app, ?array $data = null): string
2244
{
23-
$url = sprintf(App::V2_BRANCHER_APP_URL, $app);
45+
$url = sprintf(App::V2_APP_BRANCHER_URL, $app);
2446

2547
$response = $this->client->api->post($url, [], $data ? json_encode($data) : null);
2648

0 commit comments

Comments
 (0)