Skip to content

Commit

Permalink
Update generated client
Browse files Browse the repository at this point in the history
  • Loading branch information
mittwald-machine committed Mar 26, 2024
1 parent 03ce746 commit be8ef5a
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 1,506 deletions.
32 changes: 30 additions & 2 deletions src/Generated/V2/Schemas/App/AppVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class AppVersion
private static array $schema = [
'description' => 'An AppVersion is an officially supported version of an App, containing the necessary and recommended configuration und dependencies.',
'properties' => [
'appId' => [
'type' => 'string',
],
'breakingNote' => [
'$ref' => '#/components/schemas/de.mittwald.v1.app.BreakingNote',
],
Expand Down Expand Up @@ -78,10 +81,13 @@ class AppVersion
'internalVersion',
'docRoot',
'docRootUserEditable',
'appId',
],
'type' => 'object',
];

private string $appId;

private ?BreakingNote $breakingNote = null;

/**
Expand Down Expand Up @@ -113,15 +119,21 @@ class AppVersion
*/
private ?array $userInputs = null;

public function __construct(string $docRoot, bool $docRootUserEditable, string $externalVersion, string $id, string $internalVersion)
public function __construct(string $appId, string $docRoot, bool $docRootUserEditable, string $externalVersion, string $id, string $internalVersion)
{
$this->appId = $appId;
$this->docRoot = $docRoot;
$this->docRootUserEditable = $docRootUserEditable;
$this->externalVersion = $externalVersion;
$this->id = $id;
$this->internalVersion = $internalVersion;
}

public function getAppId(): string
{
return $this->appId;
}

public function getBreakingNote(): ?BreakingNote
{
return $this->breakingNote ?? null;
Expand Down Expand Up @@ -191,6 +203,20 @@ public function getUserInputs(): ?array
return $this->userInputs ?? null;
}

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

$clone = clone $this;
$clone->appId = $appId;

return $clone;
}

public function withBreakingNote(BreakingNote $breakingNote): self
{
$clone = clone $this;
Expand Down Expand Up @@ -387,6 +413,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
static::validateInput($input);
}

$appId = $input->{'appId'};
$breakingNote = null;
if (isset($input->{'breakingNote'})) {
$breakingNote = BreakingNote::buildFromInput($input->{'breakingNote'}, validate: $validate);
Expand Down Expand Up @@ -417,7 +444,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
$userInputs = array_map(fn (array|object $i): UserInput => UserInput::buildFromInput($i, validate: $validate), $input->{'userInputs'});
}

$obj = new self($docRoot, $docRootUserEditable, $externalVersion, $id, $internalVersion);
$obj = new self($appId, $docRoot, $docRootUserEditable, $externalVersion, $id, $internalVersion);
$obj->breakingNote = $breakingNote;
$obj->databases = $databases;
$obj->recommended = $recommended;
Expand All @@ -435,6 +462,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
public function toJson(): array
{
$output = [];
$output['appId'] = $this->appId;
if (isset($this->breakingNote)) {
$output['breakingNote'] = $this->breakingNote->toJson();
}
Expand Down
1 change: 1 addition & 0 deletions src/Generated/V2/Schemas/App/UserInputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ enum UserInputFormat: string
case email = 'email';
case password = 'password';
case url = 'url';
case uri = 'uri';
}
22 changes: 13 additions & 9 deletions src/Generated/V2/Schemas/Ingress/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Path
[
'$ref' => '#/components/schemas/de.mittwald.v1.ingress.TargetUseDefaultPage',
],
[
'$ref' => '#/components/schemas/de.mittwald.v1.ingress.TargetContainer',
],
],
],
],
Expand All @@ -53,12 +56,12 @@ class Path

private string $path;

private TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage $target;
private TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage|TargetContainer $target;

/**
* @param TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage $target
* @param TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage|TargetContainer $target
*/
public function __construct(string $path, TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage $target)
public function __construct(string $path, TargetContainer|TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage $target)
{
$this->path = $path;
$this->target = $target;
Expand All @@ -71,9 +74,9 @@ public function getPath(): string

/**
* @return
* TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage
* TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage|TargetContainer
*/
public function getTarget(): TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage
public function getTarget(): TargetContainer|TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage
{
return $this->target;
}
Expand All @@ -93,9 +96,9 @@ public function withPath(string $path): self
}

/**
* @param TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage $target
* @param TargetDirectory|TargetUrl|TargetInstallation|TargetUseDefaultPage|TargetContainer $target
*/
public function withTarget(TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage $target): self
public function withTarget(TargetContainer|TargetDirectory|TargetInstallation|TargetUrl|TargetUseDefaultPage $target): self
{
$clone = clone $this;
$clone->target = $target;
Expand Down Expand Up @@ -124,6 +127,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
TargetUrl::validateInput($input->{'target'}, true) => TargetUrl::buildFromInput($input->{'target'}, validate: $validate),
TargetInstallation::validateInput($input->{'target'}, true) => TargetInstallation::buildFromInput($input->{'target'}, validate: $validate),
TargetUseDefaultPage::validateInput($input->{'target'}, true) => TargetUseDefaultPage::buildFromInput($input->{'target'}, validate: $validate),
TargetContainer::validateInput($input->{'target'}, true) => TargetContainer::buildFromInput($input->{'target'}, validate: $validate),
};

$obj = new self($path, $target);
Expand All @@ -141,7 +145,7 @@ public function toJson(): array
$output = [];
$output['path'] = $this->path;
$output['target'] = match (true) {
($this->target) instanceof TargetDirectory, ($this->target) instanceof TargetUrl, ($this->target) instanceof TargetInstallation, ($this->target) instanceof TargetUseDefaultPage => $this->target->toJson(),
($this->target) instanceof TargetDirectory, ($this->target) instanceof TargetUrl, ($this->target) instanceof TargetInstallation, ($this->target) instanceof TargetUseDefaultPage, ($this->target) instanceof TargetContainer => $this->target->toJson(),
};

return $output;
Expand Down Expand Up @@ -174,7 +178,7 @@ public static function validateInput(array|object $input, bool $return = false):
public function __clone()
{
$this->target = match (true) {
($this->target) instanceof TargetDirectory, ($this->target) instanceof TargetUrl, ($this->target) instanceof TargetInstallation, ($this->target) instanceof TargetUseDefaultPage => $this->target,
($this->target) instanceof TargetDirectory, ($this->target) instanceof TargetUrl, ($this->target) instanceof TargetInstallation, ($this->target) instanceof TargetUseDefaultPage, ($this->target) instanceof TargetContainer => $this->target,
};
}
}
134 changes: 134 additions & 0 deletions src/Generated/V2/Schemas/Ingress/TargetContainer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

declare(strict_types=1);

namespace Mittwald\ApiClient\Generated\V2\Schemas\Ingress;

use InvalidArgumentException;
use JsonSchema\Validator;

/**
* Auto-generated class for de.mittwald.v1.ingress.TargetContainer.
*
* DO NOT EDIT; this class was generated by the mittwald/api-client-builder package
* (https://github.com/mittwald/api-client-php-builder). Please make any changes
* there.
*
* @generated
* @see https://github.com/mittwald/api-client-php-builder
*/
class TargetContainer
{
/**
* Schema used to validate input for creating instances of this class
*/
private static array $schema = [
'properties' => [
'container' => [
'properties' => [
'name' => [
'type' => 'string',
],
'portProtocol' => [
'description' => 'docker-compose port specification in format port/protocol (e.g. 8080/TCP)',
'format' => 'docker-network-port',
'type' => 'string',
],
],
'required' => [
'name',
'portProtocol',
],
'type' => 'object',
],
],
'required' => [
'container',
],
'type' => 'object',
];

private TargetContainerContainer $container;

public function __construct(TargetContainerContainer $container)
{
$this->container = $container;
}

public function getContainer(): TargetContainerContainer
{
return $this->container;
}

public function withContainer(TargetContainerContainer $container): self
{
$clone = clone $this;
$clone->container = $container;

return $clone;
}

/**
* Builds a new instance from an input array
*
* @param array|object $input Input data
* @param bool $validate Set this to false to skip validation; use at own risk
* @return TargetContainer Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): TargetContainer
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$container = TargetContainerContainer::buildFromInput($input->{'container'}, validate: $validate);

$obj = new self($container);

return $obj;
}

/**
* Converts this object back to a simple array that can be JSON-serialized
*
* @return array Converted array
*/
public function toJson(): array
{
$output = [];
$output['container'] = ($this->container)->toJson();

return $output;
}

/**
* Validates an input array
*
* @param array|object $input Input data
* @param bool $return Return instead of throwing errors
* @return bool Validation result
* @throws InvalidArgumentException
*/
public static function validateInput(array|object $input, bool $return = false): bool
{
$validator = new \Mittwald\ApiClient\Validator\Validator();
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
$validator->validate($input, static::$schema);

if (!$validator->isValid() && !$return) {
$errors = array_map(function (array $e): string {
return $e["property"] . ": " . $e["message"];
}, $validator->getErrors());
throw new InvalidArgumentException(join(", ", $errors));
}

return $validator->isValid();
}

public function __clone()
{
$this->container = clone $this->container;
}
}
Loading

0 comments on commit be8ef5a

Please sign in to comment.