Skip to content

Commit

Permalink
feat: add cronjobId property to CronjobExecution schema and modify re…
Browse files Browse the repository at this point in the history
…lated methods

- Added cronjobId property to CronjobExecution schema with type string.
- Updated constructor to accept cronjobId as a parameter.
- Added getter method for cronjobId.
- Implemented withCronjobId method for setting cronjobId with validation.
- Adjusted buildFromInput and toJson methods to handle cronjobId.
  • Loading branch information
mittwald-machine committed Jan 14, 2025
1 parent ed3a463 commit 04aee49
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/Generated/V2/Schemas/Cronjob/CronjobExecution.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CronjobExecution
],
'type' => 'object',
],
'cronjobId' => [
'type' => 'string',
],
'durationInMilliseconds' => [
'example' => 12374,
'format' => 'int64',
Expand Down Expand Up @@ -94,12 +97,15 @@ class CronjobExecution
'id',
'status',
'successful',
'cronjobId',
],
'type' => 'object',
];

private ?CronjobExecutionAbortedBy $abortedBy = null;

private string $cronjobId;

private ?int $durationInMilliseconds = null;

private ?DateTime $end = null;
Expand All @@ -126,8 +132,9 @@ class CronjobExecution

private ?CronjobExecutionTriggeredBy $triggeredBy = null;

public function __construct(string $id, CronjobExecutionStatus $status, bool $successful)
public function __construct(string $cronjobId, string $id, CronjobExecutionStatus $status, bool $successful)
{
$this->cronjobId = $cronjobId;
$this->id = $id;
$this->status = $status;
$this->successful = $successful;
Expand All @@ -138,6 +145,11 @@ public function getAbortedBy(): ?CronjobExecutionAbortedBy
return $this->abortedBy ?? null;
}

public function getCronjobId(): string
{
return $this->cronjobId;
}

public function getDurationInMilliseconds(): ?int
{
return $this->durationInMilliseconds ?? null;
Expand Down Expand Up @@ -210,6 +222,20 @@ public function withoutAbortedBy(): self
return $clone;
}

public function withCronjobId(string $cronjobId): self
{
$validator = new Validator();
$validator->validate($cronjobId, static::$schema['properties']['cronjobId']);
if (!$validator->isValid()) {
throw new InvalidArgumentException($validator->getErrors()[0]['message']);
}

$clone = clone $this;
$clone->cronjobId = $cronjobId;

return $clone;
}

public function withDurationInMilliseconds(int $durationInMilliseconds): self
{
$validator = new Validator();
Expand Down Expand Up @@ -395,6 +421,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
if (isset($input->{'abortedBy'})) {
$abortedBy = CronjobExecutionAbortedBy::buildFromInput($input->{'abortedBy'}, validate: $validate);
}
$cronjobId = $input->{'cronjobId'};
$durationInMilliseconds = null;
if (isset($input->{'durationInMilliseconds'})) {
$durationInMilliseconds = (int)($input->{'durationInMilliseconds'});
Expand Down Expand Up @@ -427,7 +454,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
$triggeredBy = CronjobExecutionTriggeredBy::buildFromInput($input->{'triggeredBy'}, validate: $validate);
}

$obj = new self($id, $status, $successful);
$obj = new self($cronjobId, $id, $status, $successful);
$obj->abortedBy = $abortedBy;
$obj->durationInMilliseconds = $durationInMilliseconds;
$obj->end = $end;
Expand All @@ -450,6 +477,7 @@ public function toJson(): array
if (isset($this->abortedBy)) {
$output['abortedBy'] = ($this->abortedBy)->toJson();
}
$output['cronjobId'] = $this->cronjobId;
if (isset($this->durationInMilliseconds)) {
$output['durationInMilliseconds'] = $this->durationInMilliseconds;
}
Expand Down

0 comments on commit 04aee49

Please sign in to comment.