Skip to content

Commit 2444bac

Browse files
committed
FEATURE: add JobLogs API
1 parent a6ee7c5 commit 2444bac

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Classes/Dto/JobLogs.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
4+
namespace Flowpack\Prunner\Dto;
5+
6+
use Neos\Flow\Annotations as Flow;
7+
8+
/**
9+
* @Flow\Proxy(false)
10+
*/
11+
class JobLogs
12+
{
13+
private string $stderr;
14+
private string $stdout;
15+
16+
private function __construct(string $stderr, string $stdout)
17+
{
18+
$this->stderr = $stderr;
19+
$this->stdout = $stdout;
20+
}
21+
22+
public static function fromJsonArray(array $in): self
23+
{
24+
return new self($in['stderr'], $in['stdout']);
25+
}
26+
27+
/**
28+
* @return string
29+
*/
30+
public function getStderr(): string
31+
{
32+
return $this->stderr;
33+
}
34+
35+
/**
36+
* @return string
37+
*/
38+
public function getStdout(): string
39+
{
40+
return $this->stdout;
41+
}
42+
}

Classes/PrunnerApiService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Firebase\JWT\JWT;
66
use Flowpack\Prunner\Dto\Job;
7+
use Flowpack\Prunner\Dto\JobLogs;
78
use Flowpack\Prunner\Dto\PipelinesAndJobsResponse;
89
use Flowpack\Prunner\ValueObject\JobId;
910
use Flowpack\Prunner\ValueObject\PipelineName;
@@ -57,6 +58,13 @@ public function loadJobDetail(JobId $jobId): Job
5758
return Job::fromJsonArray($result);
5859
}
5960

61+
public function loadJobLogs(JobId $jobId, string $taskName): JobLogs
62+
{
63+
$resultString = $this->apiCall('GET', 'job/logs?' . http_build_query(['id' => $jobId->getId(), 'task' => $taskName]), null)->getBody()->getContents();
64+
$result = json_decode($resultString, true);
65+
return JobLogs::fromJsonArray($result);
66+
}
67+
6068
public function schedulePipeline(PipelineName $pipeline, array $variables): JobId
6169
{
6270
$response = $this->apiCall('POST', 'pipelines/schedule', json_encode([

0 commit comments

Comments
 (0)