Skip to content

Commit

Permalink
feat(deprecation): mark upload rules and extensions as deprecated
Browse files Browse the repository at this point in the history
- Added deprecation notices to the upload rules methods in FileClient and FileClientImpl.
- Introduced a deprecation property to the Extension class to indicate expiration details.
- Updated OptionalExtension and Extension classes with deprecated annotations on relevant properties and methods.
  • Loading branch information
mittwald-machine committed Oct 18, 2024
1 parent a331ed7 commit 899a0c6
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/Generated/V2/Clients/File/FileClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ interface FileClient
/**
* Get a Token's upload rules.
*
* Deprecated by `GET /v2/file-upload-tokens/{fileUploadToken}/rules`.
*
* @see https://developer.mittwald.de/reference/v2/#tag/File/operation/deprecated-file-get-file-token-rules
* @throws GuzzleException
* @throws UnexpectedResponseException
Expand All @@ -51,6 +53,8 @@ public function deprecatedFileGetFileTokenRules(DeprecatedFileGetFileTokenRulesR
/**
* Get a Type's upload rules.
*
* Deprecated by `GET /v2/file-upload-types/{fileUploadType}/rules`.
*
* @see https://developer.mittwald.de/reference/v2/#tag/File/operation/deprecated-file-get-file-type-rules
* @throws GuzzleException
* @throws UnexpectedResponseException
Expand Down
4 changes: 4 additions & 0 deletions src/Generated/V2/Clients/File/FileClientImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function __construct(Client $client)
/**
* Get a Token's upload rules.
*
* Deprecated by `GET /v2/file-upload-tokens/{fileUploadToken}/rules`.
*
* @see https://developer.mittwald.de/reference/v2/#tag/File/operation/deprecated-file-get-file-token-rules
* @throws GuzzleException
* @throws UnexpectedResponseException
Expand All @@ -122,6 +124,8 @@ public function deprecatedFileGetFileTokenRules(DeprecatedFileGetFileTokenRulesR
/**
* Get a Type's upload rules.
*
* Deprecated by `GET /v2/file-upload-types/{fileUploadType}/rules`.
*
* @see https://developer.mittwald.de/reference/v2/#tag/File/operation/deprecated-file-get-file-type-rules
* @throws GuzzleException
* @throws UnexpectedResponseException
Expand Down
60 changes: 60 additions & 0 deletions src/Generated/V2/Schemas/Marketplace/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Extension
private static array $schema = [
'properties' => [
'blocked' => [
'deprecated' => true,
'type' => 'boolean',
],
'context' => [
Expand All @@ -34,6 +35,19 @@ class Extension
'format' => 'uuid',
'type' => 'string',
],
'deprecation' => [
'description' => 'The Extension is deprecated by the contributor and will expire at the given date.',
'properties' => [
'deprecatedAt' => [
'format' => 'date-time',
'type' => 'string',
],
],
'required' => [
'deprecatedAt',
],
'type' => 'object',
],
'description' => [
'type' => 'string',
],
Expand Down Expand Up @@ -105,12 +119,20 @@ class Extension
'type' => 'object',
];

/**
* @deprecated
*/
private bool $blocked;

private Context $context;

private string $contributorId;

/**
* The Extension is deprecated by the contributor and will expire at the given date.
*/
private ?ExtensionDeprecation $deprecation = null;

private string $description;

private ?DetailedDescriptions $detailedDescriptions = null;
Expand Down Expand Up @@ -169,6 +191,9 @@ public function __construct(bool $blocked, Context $context, string $contributor
$this->tags = $tags;
}

/**
* @deprecated
*/
public function getBlocked(): bool
{
return $this->blocked;
Expand All @@ -184,6 +209,11 @@ public function getContributorId(): string
return $this->contributorId;
}

public function getDeprecation(): ?ExtensionDeprecation
{
return $this->deprecation ?? null;
}

public function getDescription(): string
{
return $this->description;
Expand Down Expand Up @@ -259,6 +289,9 @@ public function getTags(): array
return $this->tags;
}

/**
* @deprecated
*/
public function withBlocked(bool $blocked): self
{
$validator = new Validator();
Expand Down Expand Up @@ -295,6 +328,22 @@ public function withContributorId(string $contributorId): self
return $clone;
}

public function withDeprecation(ExtensionDeprecation $deprecation): self
{
$clone = clone $this;
$clone->deprecation = $deprecation;

return $clone;
}

public function withoutDeprecation(): self
{
$clone = clone $this;
unset($clone->deprecation);

return $clone;
}

public function withDescription(string $description): self
{
$validator = new Validator();
Expand Down Expand Up @@ -482,6 +531,10 @@ public static function buildFromInput(array|object $input, bool $validate = true
$blocked = (bool)($input->{'blocked'});
$context = Context::from($input->{'context'});
$contributorId = $input->{'contributorId'};
$deprecation = null;
if (isset($input->{'deprecation'})) {
$deprecation = ExtensionDeprecation::buildFromInput($input->{'deprecation'}, validate: $validate);
}
$description = $input->{'description'};
$detailedDescriptions = null;
if (isset($input->{'detailedDescriptions'})) {
Expand All @@ -504,6 +557,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
$tags = $input->{'tags'};

$obj = new self($blocked, $context, $contributorId, $description, $disabled, $id, $name, $scopes, $state, $support, $tags);
$obj->deprecation = $deprecation;
$obj->detailedDescriptions = $detailedDescriptions;
$obj->frontendComponents = $frontendComponents;
$obj->frontendFragments = $frontendFragments;
Expand All @@ -521,6 +575,9 @@ public function toJson(): array
$output['blocked'] = $this->blocked;
$output['context'] = $this->context->value;
$output['contributorId'] = $this->contributorId;
if (isset($this->deprecation)) {
$output['deprecation'] = ($this->deprecation)->toJson();
}
$output['description'] = $this->description;
if (isset($this->detailedDescriptions)) {
$output['detailedDescriptions'] = $this->detailedDescriptions->toJson();
Expand Down Expand Up @@ -568,5 +625,8 @@ public static function validateInput(array|object $input, bool $return = false):

public function __clone()
{
if (isset($this->deprecation)) {
$this->deprecation = clone $this->deprecation;
}
}
}
123 changes: 123 additions & 0 deletions src/Generated/V2/Schemas/Marketplace/ExtensionDeprecation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

declare(strict_types=1);

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

use DateTime;
use InvalidArgumentException;
use JsonSchema\Validator;

/**
* Auto-generated class for de.mittwald.v1.marketplace.Extension.
*
* 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 ExtensionDeprecation
{
/**
* Schema used to validate input for creating instances of this class
*/
private static array $schema = [
'description' => 'The Extension is deprecated by the contributor and will expire at the given date.',
'properties' => [
'deprecatedAt' => [
'format' => 'date-time',
'type' => 'string',
],
],
'required' => [
'deprecatedAt',
],
'type' => 'object',
];

private DateTime $deprecatedAt;

public function __construct(DateTime $deprecatedAt)
{
$this->deprecatedAt = $deprecatedAt;
}

public function getDeprecatedAt(): DateTime
{
return $this->deprecatedAt;
}

public function withDeprecatedAt(DateTime $deprecatedAt): self
{
$clone = clone $this;
$clone->deprecatedAt = $deprecatedAt;

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 ExtensionDeprecation Created instance
* @throws InvalidArgumentException
*/
public static function buildFromInput(array|object $input, bool $validate = true): ExtensionDeprecation
{
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
if ($validate) {
static::validateInput($input);
}

$deprecatedAt = new DateTime($input->{'deprecatedAt'});

$obj = new self($deprecatedAt);

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['deprecatedAt'] = ($this->deprecatedAt)->format(DateTime::ATOM);

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->deprecatedAt = clone $this->deprecatedAt;
}
}
19 changes: 10 additions & 9 deletions src/Generated/V2/Schemas/Marketplace/OptionalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class OptionalExtension
'$ref' => '#/components/schemas/de.mittwald.v1.marketplace.BackendComponents',
],
'blocked' => [
'deprecated' => true,
'type' => 'boolean',
],
'context' => [
Expand Down Expand Up @@ -72,7 +73,6 @@ class OptionalExtension
'type' => 'array',
],
'state' => [
'deprecated' => true,
'description' => 'deprecated',
'enum' => [
'enabled',
Expand Down Expand Up @@ -102,6 +102,9 @@ class OptionalExtension

private ?BackendComponents $backendComponents = null;

/**
* @deprecated
*/
private ?bool $blocked = null;

private ?Context $context = null;
Expand Down Expand Up @@ -135,8 +138,6 @@ class OptionalExtension

/**
* deprecated
*
* @deprecated
*/
private ?OptionalExtensionState $state = null;

Expand All @@ -163,6 +164,9 @@ public function getBackendComponents(): ?BackendComponents
return $this->backendComponents ?? null;
}

/**
* @deprecated
*/
public function getBlocked(): ?bool
{
return $this->blocked ?? null;
Expand Down Expand Up @@ -232,9 +236,6 @@ public function getScopes(): ?array
return $this->scopes ?? null;
}

/**
* @deprecated
*/
public function getState(): ?OptionalExtensionState
{
return $this->state ?? null;
Expand Down Expand Up @@ -269,6 +270,9 @@ public function withoutBackendComponents(): self
return $clone;
}

/**
* @deprecated
*/
public function withBlocked(bool $blocked): self
{
$validator = new Validator();
Expand Down Expand Up @@ -478,9 +482,6 @@ public function withoutScopes(): self
return $clone;
}

/**
* @deprecated
*/
public function withState(OptionalExtensionState $state): self
{
$clone = clone $this;
Expand Down

0 comments on commit 899a0c6

Please sign in to comment.