diff --git a/src/Generated/V2/Clients/Marketplace/MarketplaceClient.php b/src/Generated/V2/Clients/Marketplace/MarketplaceClient.php index 4951ddc1..a2695e09 100644 --- a/src/Generated/V2/Clients/Marketplace/MarketplaceClient.php +++ b/src/Generated/V2/Clients/Marketplace/MarketplaceClient.php @@ -35,8 +35,6 @@ use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensionInstances\ExtensionListExtensionInstancesRequest; use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensions\ExtensionListExtensionsOKResponse; use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensions\ExtensionListExtensionsRequest; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthOKResponse; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthRequest; /** * Client for Marketplace API @@ -213,14 +211,4 @@ public function extensionListExtensionInstances(ExtensionListExtensionInstancesR * @return ExtensionListExtensionsOKResponse OK */ public function extensionListExtensions(ExtensionListExtensionsRequest $request): ExtensionListExtensionsOKResponse; - /** - * Get all extensions and instances health for the contributor. - * - * @see https://developer.mittwald.de/reference/v2/#tag/Marketplace/operation/marketplace-get-extensionshealth - * @throws GuzzleException - * @throws UnexpectedResponseException - * @param GetExtensionshealthRequest $request An object representing the request for this operation - * @return GetExtensionshealthOKResponse OK - */ - public function getExtensionshealth(GetExtensionshealthRequest $request): GetExtensionshealthOKResponse; } diff --git a/src/Generated/V2/Clients/Marketplace/MarketplaceClientImpl.php b/src/Generated/V2/Clients/Marketplace/MarketplaceClientImpl.php index 12913faa..543662be 100644 --- a/src/Generated/V2/Clients/Marketplace/MarketplaceClientImpl.php +++ b/src/Generated/V2/Clients/Marketplace/MarketplaceClientImpl.php @@ -83,11 +83,6 @@ use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensions\ExtensionListExtensionsOKResponse; use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensions\ExtensionListExtensionsRequest; use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionListExtensions\ExtensionListExtensionsTooManyRequestsResponse; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthDefaultResponse; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthNotFoundResponse; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthOKResponse; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthRequest; -use Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth\GetExtensionshealthTooManyRequestsResponse; /** * Client for Marketplace API @@ -476,27 +471,4 @@ public function extensionListExtensions(ExtensionListExtensionsRequest $request) default => ExtensionListExtensionsDefaultResponse::fromResponse($httpResponse), }); } - - /** - * Get all extensions and instances health for the contributor. - * - * @see https://developer.mittwald.de/reference/v2/#tag/Marketplace/operation/marketplace-get-extensionshealth - * @throws GuzzleException - * @throws UnexpectedResponseException - * @param GetExtensionshealthRequest $request An object representing the request for this operation - * @return GetExtensionshealthOKResponse OK - */ - public function getExtensionshealth(GetExtensionshealthRequest $request): GetExtensionshealthOKResponse - { - $httpRequest = new Request(GetExtensionshealthRequest::method, $request->buildUrl()); - $httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions()); - if ($httpResponse->getStatusCode() === 200) { - return GetExtensionshealthOKResponse::fromResponse($httpResponse); - } - throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) { - 404 => GetExtensionshealthNotFoundResponse::fromResponse($httpResponse), - 429 => GetExtensionshealthTooManyRequestsResponse::fromResponse($httpResponse), - default => GetExtensionshealthDefaultResponse::fromResponse($httpResponse), - }); - } } diff --git a/src/Generated/V2/Clients/Project/ProjectClient.php b/src/Generated/V2/Clients/Project/ProjectClient.php index a45cfed1..c412f74e 100644 --- a/src/Generated/V2/Clients/Project/ProjectClient.php +++ b/src/Generated/V2/Clients/Project/ProjectClient.php @@ -48,6 +48,12 @@ use Mittwald\ApiClient\Generated\V2\Clients\Project\RequestServerAvatarUpload\RequestServerAvatarUploadOKResponse; use Mittwald\ApiClient\Generated\V2\Clients\Project\RequestServerAvatarUpload\RequestServerAvatarUploadRequest; use Mittwald\ApiClient\Generated\V2\Clients\Project\ResendProjectInviteMail\ResendProjectInviteMailRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsOKResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsOKResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdRequest; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateProjectDescription\UpdateProjectDescriptionRequest; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateProjectMembership\UpdateProjectMembershipRequest; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateServerDescription\UpdateServerDescriptionRequest; @@ -340,4 +346,44 @@ public function updateProjectMembership(UpdateProjectMembershipRequest $request) * @return EmptyResponse NoContent */ public function updateServerDescription(UpdateServerDescriptionRequest $request): EmptyResponse; + /** + * Get storage space Statistics belonging to a Project. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-get-project-statistics + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceGetProjectStatisticsRequest $request An object representing the request for this operation + * @return StoragespaceGetProjectStatisticsOKResponse OK + */ + public function storagespaceGetProjectStatistics(StoragespaceGetProjectStatisticsRequest $request): StoragespaceGetProjectStatisticsOKResponse; + /** + * Get storage space Statistics belonging to a Server. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-get-server-statistics + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceGetServerStatisticsRequest $request An object representing the request for this operation + * @return StoragespaceGetServerStatisticsOKResponse OK + */ + public function storagespaceGetServerStatistics(StoragespaceGetServerStatisticsRequest $request): StoragespaceGetServerStatisticsOKResponse; + /** + * Update a Project's storage space notification threshold. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-replace-project-notification-threshold + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceReplaceProjectNotificationThresholdRequest $request An object representing the request for this operation + * @return EmptyResponse NoContent + */ + public function storagespaceReplaceProjectNotificationThreshold(StoragespaceReplaceProjectNotificationThresholdRequest $request): EmptyResponse; + /** + * Update a Server's storage space notification threshold. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-replace-server-notification-threshold + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceReplaceServerNotificationThresholdRequest $request An object representing the request for this operation + * @return EmptyResponse NoContent + */ + public function storagespaceReplaceServerNotificationThreshold(StoragespaceReplaceServerNotificationThresholdRequest $request): EmptyResponse; } diff --git a/src/Generated/V2/Clients/Project/ProjectClientImpl.php b/src/Generated/V2/Clients/Project/ProjectClientImpl.php index 024fc1cb..57b05c97 100644 --- a/src/Generated/V2/Clients/Project/ProjectClientImpl.php +++ b/src/Generated/V2/Clients/Project/ProjectClientImpl.php @@ -138,6 +138,32 @@ use Mittwald\ApiClient\Generated\V2\Clients\Project\ResendProjectInviteMail\ResendProjectInviteMailForbiddenResponse; use Mittwald\ApiClient\Generated\V2\Clients\Project\ResendProjectInviteMail\ResendProjectInviteMailRequest; use Mittwald\ApiClient\Generated\V2\Clients\Project\ResendProjectInviteMail\ResendProjectInviteMailTooManyRequestsResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsBadRequestResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsDefaultResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsForbiddenResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsInternalServerErrorResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsNotFoundResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsOKResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics\StoragespaceGetProjectStatisticsTooManyRequestsResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsBadRequestResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsDefaultResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsForbiddenResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsInternalServerErrorResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsNotFoundResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsOKResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics\StoragespaceGetServerStatisticsTooManyRequestsResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdDefaultResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdForbiddenResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceProjectNotificationThreshold\StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdDefaultResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdForbiddenResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdRequest; +use Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold\StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateProjectDescription\UpdateProjectDescriptionBadRequestResponse; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateProjectDescription\UpdateProjectDescriptionDefaultResponse; use Mittwald\ApiClient\Generated\V2\Clients\Project\UpdateProjectDescription\UpdateProjectDescriptionForbiddenResponse; @@ -824,4 +850,104 @@ public function updateServerDescription(UpdateServerDescriptionRequest $request) default => UpdateServerDescriptionDefaultResponse::fromResponse($httpResponse), }); } + + /** + * Get storage space Statistics belonging to a Project. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-get-project-statistics + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceGetProjectStatisticsRequest $request An object representing the request for this operation + * @return StoragespaceGetProjectStatisticsOKResponse OK + */ + public function storagespaceGetProjectStatistics(StoragespaceGetProjectStatisticsRequest $request): StoragespaceGetProjectStatisticsOKResponse + { + $httpRequest = new Request(StoragespaceGetProjectStatisticsRequest::method, $request->buildUrl()); + $httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions()); + if ($httpResponse->getStatusCode() === 200) { + return StoragespaceGetProjectStatisticsOKResponse::fromResponse($httpResponse); + } + throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) { + 400 => StoragespaceGetProjectStatisticsBadRequestResponse::fromResponse($httpResponse), + 403 => StoragespaceGetProjectStatisticsForbiddenResponse::fromResponse($httpResponse), + 404 => StoragespaceGetProjectStatisticsNotFoundResponse::fromResponse($httpResponse), + 429 => StoragespaceGetProjectStatisticsTooManyRequestsResponse::fromResponse($httpResponse), + 500 => StoragespaceGetProjectStatisticsInternalServerErrorResponse::fromResponse($httpResponse), + default => StoragespaceGetProjectStatisticsDefaultResponse::fromResponse($httpResponse), + }); + } + + /** + * Get storage space Statistics belonging to a Server. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-get-server-statistics + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceGetServerStatisticsRequest $request An object representing the request for this operation + * @return StoragespaceGetServerStatisticsOKResponse OK + */ + public function storagespaceGetServerStatistics(StoragespaceGetServerStatisticsRequest $request): StoragespaceGetServerStatisticsOKResponse + { + $httpRequest = new Request(StoragespaceGetServerStatisticsRequest::method, $request->buildUrl()); + $httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions()); + if ($httpResponse->getStatusCode() === 200) { + return StoragespaceGetServerStatisticsOKResponse::fromResponse($httpResponse); + } + throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) { + 400 => StoragespaceGetServerStatisticsBadRequestResponse::fromResponse($httpResponse), + 403 => StoragespaceGetServerStatisticsForbiddenResponse::fromResponse($httpResponse), + 404 => StoragespaceGetServerStatisticsNotFoundResponse::fromResponse($httpResponse), + 429 => StoragespaceGetServerStatisticsTooManyRequestsResponse::fromResponse($httpResponse), + 500 => StoragespaceGetServerStatisticsInternalServerErrorResponse::fromResponse($httpResponse), + default => StoragespaceGetServerStatisticsDefaultResponse::fromResponse($httpResponse), + }); + } + + /** + * Update a Project's storage space notification threshold. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-replace-project-notification-threshold + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceReplaceProjectNotificationThresholdRequest $request An object representing the request for this operation + * @return EmptyResponse NoContent + */ + public function storagespaceReplaceProjectNotificationThreshold(StoragespaceReplaceProjectNotificationThresholdRequest $request): EmptyResponse + { + $httpRequest = new Request(StoragespaceReplaceProjectNotificationThresholdRequest::method, $request->buildUrl()); + $httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions()); + if ($httpResponse->getStatusCode() === 204) { + return new EmptyResponse($httpResponse); + } + throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) { + 403 => StoragespaceReplaceProjectNotificationThresholdForbiddenResponse::fromResponse($httpResponse), + 429 => StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse::fromResponse($httpResponse), + 500 => StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse::fromResponse($httpResponse), + default => StoragespaceReplaceProjectNotificationThresholdDefaultResponse::fromResponse($httpResponse), + }); + } + + /** + * Update a Server's storage space notification threshold. + * + * @see https://developer.mittwald.de/reference/v2/#tag/Project/operation/storagespace-replace-server-notification-threshold + * @throws GuzzleException + * @throws UnexpectedResponseException + * @param StoragespaceReplaceServerNotificationThresholdRequest $request An object representing the request for this operation + * @return EmptyResponse NoContent + */ + public function storagespaceReplaceServerNotificationThreshold(StoragespaceReplaceServerNotificationThresholdRequest $request): EmptyResponse + { + $httpRequest = new Request(StoragespaceReplaceServerNotificationThresholdRequest::method, $request->buildUrl()); + $httpResponse = $this->client->send($httpRequest, $request->buildRequestOptions()); + if ($httpResponse->getStatusCode() === 204) { + return new EmptyResponse($httpResponse); + } + throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) { + 403 => StoragespaceReplaceServerNotificationThresholdForbiddenResponse::fromResponse($httpResponse), + 429 => StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse::fromResponse($httpResponse), + 500 => StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse::fromResponse($httpResponse), + default => StoragespaceReplaceServerNotificationThresholdDefaultResponse::fromResponse($httpResponse), + }); + } } diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsBadRequestResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsBadRequestResponse.php new file mode 100644 index 00000000..e9eea6f4 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsBadRequestResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.ValidationErrors', + ], + ], + ]; + + private ValidationErrors $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(ValidationErrors $body) + { + $this->body = $body; + } + + public function getBody(): ValidationErrors + { + return $this->body; + } + + public function withBody(ValidationErrors $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsBadRequestResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsBadRequestResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = ValidationErrors::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsDefaultResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsDefaultResponse.php new file mode 100644 index 00000000..24f34713 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsDefaultResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsDefaultResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsDefaultResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsForbiddenResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsForbiddenResponse.php new file mode 100644 index 00000000..6748f9b9 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsForbiddenResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsForbiddenResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsForbiddenResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsInternalServerErrorResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsInternalServerErrorResponse.php new file mode 100644 index 00000000..b0a9f271 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsInternalServerErrorResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsInternalServerErrorResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsInternalServerErrorResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsNotFoundResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsNotFoundResponse.php new file mode 100644 index 00000000..d239f6f6 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsNotFoundResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsNotFoundResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsNotFoundResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsOKResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsOKResponse.php new file mode 100644 index 00000000..6fafee1d --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsOKResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.Statistics', + ], + ], + ]; + + private Statistics $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Statistics $body) + { + $this->body = $body; + } + + public function getBody(): Statistics + { + return $this->body; + } + + public function withBody(Statistics $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetProjectStatisticsOKResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsOKResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Statistics::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthRequest.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsRequest.php similarity index 78% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthRequest.php rename to src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsRequest.php index ccb278e4..1b222f73 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthRequest.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsRequest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics; use InvalidArgumentException; use JsonSchema\Validator; -class GetExtensionshealthRequest +class StoragespaceGetProjectStatisticsRequest { public const method = 'get'; @@ -17,42 +17,41 @@ class GetExtensionshealthRequest private static array $schema = [ 'type' => 'object', 'properties' => [ - 'contributorId' => [ - 'format' => 'uuid', + 'projectId' => [ 'type' => 'string', ], ], 'required' => [ - 'contributorId', + 'projectId', ], ]; - private string $contributorId; + private string $projectId; private array $headers = [ ]; - public function __construct(string $contributorId) + public function __construct(string $projectId) { - $this->contributorId = $contributorId; + $this->projectId = $projectId; } - public function getContributorId(): string + public function getProjectId(): string { - return $this->contributorId; + return $this->projectId; } - public function withContributorId(string $contributorId): self + public function withProjectId(string $projectId): self { $validator = new Validator(); - $validator->validate($contributorId, static::$schema['properties']['contributorId']); + $validator->validate($projectId, static::$schema['properties']['projectId']); if (!$validator->isValid()) { throw new InvalidArgumentException($validator->getErrors()[0]['message']); } $clone = clone $this; - $clone->contributorId = $contributorId; + $clone->projectId = $projectId; return $clone; } @@ -62,19 +61,19 @@ public function withContributorId(string $contributorId): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthRequest Created instance + * @return StoragespaceGetProjectStatisticsRequest Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthRequest + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsRequest { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { static::validateInput($input); } - $contributorId = $input->{'contributorId'}; + $projectId = $input->{'projectId'}; - $obj = new self($contributorId); + $obj = new self($projectId); return $obj; } @@ -87,7 +86,7 @@ public static function buildFromInput(array|object $input, bool $validate = true public function toJson(): array { $output = []; - $output['contributorId'] = $this->contributorId; + $output['projectId'] = $this->projectId; return $output; } @@ -132,8 +131,8 @@ public function __clone() public function buildUrl(): string { $mapped = $this->toJson(); - $contributorId = urlencode($mapped['contributorId']); - return '/v2/marketplace/' . $contributorId . '/extensionshealth'; + $projectId = urlencode($mapped['projectId']); + return '/v2/projects/' . $projectId . '/storage-space-statistics'; } /** diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponse.php similarity index 72% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponse.php rename to src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponse.php index 870c78ed..d7077638 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponse.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponse.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetProjectStatistics; use InvalidArgumentException; use JsonSchema\Validator; use Mittwald\ApiClient\Client\ResponseContainer; use Psr\Http\Message\ResponseInterface; -class GetExtensionshealthOKResponse implements ResponseContainer +class StoragespaceGetProjectStatisticsTooManyRequestsResponse implements ResponseContainer { /** * Schema used to validate input for creating instances of this class @@ -21,37 +21,36 @@ class GetExtensionshealthOKResponse implements ResponseContainer ], 'properties' => [ 'body' => [ + 'type' => 'object', 'properties' => [ - 'extensionsHealth' => [ - 'items' => [ - '$ref' => '#/components/schemas/de.mittwald.v1.marketplace.ExtensionHealth', - ], - 'type' => 'array', + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', ], ], - 'required' => [ - 'extensionsHealth', - ], - 'type' => 'object', ], ], ]; - private GetExtensionshealthOKResponseBody $body; + private StoragespaceGetProjectStatisticsTooManyRequestsResponseBody $body; private ResponseInterface|null $httpResponse = null; - public function __construct(GetExtensionshealthOKResponseBody $body) + public function __construct(StoragespaceGetProjectStatisticsTooManyRequestsResponseBody $body) { $this->body = $body; } - public function getBody(): GetExtensionshealthOKResponseBody + public function getBody(): StoragespaceGetProjectStatisticsTooManyRequestsResponseBody { return $this->body; } - public function withBody(GetExtensionshealthOKResponseBody $body): self + public function withBody(StoragespaceGetProjectStatisticsTooManyRequestsResponseBody $body): self { $clone = clone $this; $clone->body = $body; @@ -64,17 +63,17 @@ public function withBody(GetExtensionshealthOKResponseBody $body): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthOKResponse Created instance + * @return StoragespaceGetProjectStatisticsTooManyRequestsResponse Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthOKResponse + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsTooManyRequestsResponse { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { static::validateInput($input); } - $body = GetExtensionshealthOKResponseBody::buildFromInput($input->{'body'}, validate: $validate); + $body = StoragespaceGetProjectStatisticsTooManyRequestsResponseBody::buildFromInput($input->{'body'}, validate: $validate); $obj = new self($body); diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponseBody.php b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponseBody.php new file mode 100644 index 00000000..19e6710c --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetProjectStatistics/StoragespaceGetProjectStatisticsTooManyRequestsResponseBody.php @@ -0,0 +1,169 @@ + 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', + ], + ], + ]; + + private ?string $message = null; + + private ?string $type = null; + + /** + * + */ + public function __construct() + { + } + + public function getMessage(): ?string + { + return $this->message ?? null; + } + + public function getType(): ?string + { + return $this->type ?? null; + } + + public function withMessage(string $message): self + { + $validator = new Validator(); + $validator->validate($message, static::$schema['properties']['message']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->message = $message; + + return $clone; + } + + public function withoutMessage(): self + { + $clone = clone $this; + unset($clone->message); + + return $clone; + } + + public function withType(string $type): self + { + $validator = new Validator(); + $validator->validate($type, static::$schema['properties']['type']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->type = $type; + + return $clone; + } + + public function withoutType(): self + { + $clone = clone $this; + unset($clone->type); + + 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 StoragespaceGetProjectStatisticsTooManyRequestsResponseBody Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetProjectStatisticsTooManyRequestsResponseBody + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $message = null; + if (isset($input->{'message'})) { + $message = $input->{'message'}; + } + $type = null; + if (isset($input->{'type'})) { + $type = $input->{'type'}; + } + + $obj = new self(); + $obj->message = $message; + $obj->type = $type; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->message)) { + $output['message'] = $this->message; + } + if (isset($this->type)) { + $output['type'] = $this->type; + } + + 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() + { + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsBadRequestResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsBadRequestResponse.php new file mode 100644 index 00000000..539b36a6 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsBadRequestResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.ValidationErrors', + ], + ], + ]; + + private ValidationErrors $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(ValidationErrors $body) + { + $this->body = $body; + } + + public function getBody(): ValidationErrors + { + return $this->body; + } + + public function withBody(ValidationErrors $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetServerStatisticsBadRequestResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsBadRequestResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = ValidationErrors::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthDefaultResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsDefaultResponse.php similarity index 91% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthDefaultResponse.php rename to src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsDefaultResponse.php index 14aa54d8..0ca8784a 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthDefaultResponse.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsDefaultResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics; use InvalidArgumentException; use JsonSchema\Validator; @@ -10,7 +10,7 @@ use Mittwald\ApiClient\Generated\V2\Schemas\Commons\Error; use Psr\Http\Message\ResponseInterface; -class GetExtensionshealthDefaultResponse implements ResponseContainer +class StoragespaceGetServerStatisticsDefaultResponse implements ResponseContainer { /** * Schema used to validate input for creating instances of this class @@ -54,10 +54,10 @@ public function withBody(Error $body): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthDefaultResponse Created instance + * @return StoragespaceGetServerStatisticsDefaultResponse Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthDefaultResponse + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsDefaultResponse { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsForbiddenResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsForbiddenResponse.php new file mode 100644 index 00000000..d7d4c804 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsForbiddenResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetServerStatisticsForbiddenResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsForbiddenResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsInternalServerErrorResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsInternalServerErrorResponse.php new file mode 100644 index 00000000..d29f7088 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsInternalServerErrorResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetServerStatisticsInternalServerErrorResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsInternalServerErrorResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthNotFoundResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsNotFoundResponse.php similarity index 91% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthNotFoundResponse.php rename to src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsNotFoundResponse.php index de86abf7..bbecaec5 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthNotFoundResponse.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsNotFoundResponse.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics; use InvalidArgumentException; use JsonSchema\Validator; @@ -10,7 +10,7 @@ use Mittwald\ApiClient\Generated\V2\Schemas\Commons\Error; use Psr\Http\Message\ResponseInterface; -class GetExtensionshealthNotFoundResponse implements ResponseContainer +class StoragespaceGetServerStatisticsNotFoundResponse implements ResponseContainer { /** * Schema used to validate input for creating instances of this class @@ -54,10 +54,10 @@ public function withBody(Error $body): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthNotFoundResponse Created instance + * @return StoragespaceGetServerStatisticsNotFoundResponse Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthNotFoundResponse + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsNotFoundResponse { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsOKResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsOKResponse.php new file mode 100644 index 00000000..7f21d7f4 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsOKResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.Statistics', + ], + ], + ]; + + private Statistics $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Statistics $body) + { + $this->body = $body; + } + + public function getBody(): Statistics + { + return $this->body; + } + + public function withBody(Statistics $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceGetServerStatisticsOKResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsOKResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Statistics::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsRequest.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsRequest.php new file mode 100644 index 00000000..79e2a966 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsRequest.php @@ -0,0 +1,172 @@ + 'object', + 'properties' => [ + 'serverId' => [ + 'type' => 'string', + ], + ], + 'required' => [ + 'serverId', + ], + ]; + + private string $serverId; + + private array $headers = [ + + ]; + + public function __construct(string $serverId) + { + $this->serverId = $serverId; + } + + public function getServerId(): string + { + return $this->serverId; + } + + public function withServerId(string $serverId): self + { + $validator = new Validator(); + $validator->validate($serverId, static::$schema['properties']['serverId']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->serverId = $serverId; + + 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 StoragespaceGetServerStatisticsRequest Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsRequest + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $serverId = $input->{'serverId'}; + + $obj = new self($serverId); + + 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['serverId'] = $this->serverId; + + 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() + { + } + + /** + * Builds the URL for this request + * + * This method is used internally by the client to build the URL for this request. + * You should not need to call this method directly. + * + * @internal + * @return string The URL for this request + */ + public function buildUrl(): string + { + $mapped = $this->toJson(); + $serverId = urlencode($mapped['serverId']); + return '/v2/servers/' . $serverId . '/storage-space-statistics'; + } + + /** + * Builds the request options for this request + * + * This method is used internally by the client to build the Guzzle request options + * for this request. You should not need to call this method directly. + * + * @internal + * @return array The Guzzle request options for this request + */ + public function buildRequestOptions(): array + { + $mapped = $this->toJson(); + $query = []; + return [ + 'query' => $query, + 'headers' => $this->headers, + ]; + } + + /** + * Adds a header to this request + * + * You can use this method to add custom HTTP headers to the request. + * + * @param string $name The name of the header to add + * @param string|array $value The value of the header to add + * @return self A clone of this request with the header added + */ + public function withHeader(string $name, string|array $value): self + { + $clone = clone $this; + $clone->headers[$name] = $value; + return $clone; + } +} diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponse.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponse.php similarity index 79% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponse.php rename to src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponse.php index eb790698..09778df9 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponse.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponse.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics; use InvalidArgumentException; use JsonSchema\Validator; use Mittwald\ApiClient\Client\ResponseContainer; use Psr\Http\Message\ResponseInterface; -class GetExtensionshealthTooManyRequestsResponse implements ResponseContainer +class StoragespaceGetServerStatisticsTooManyRequestsResponse implements ResponseContainer { /** * Schema used to validate input for creating instances of this class @@ -36,21 +36,21 @@ class GetExtensionshealthTooManyRequestsResponse implements ResponseContainer ], ]; - private GetExtensionshealthTooManyRequestsResponseBody $body; + private StoragespaceGetServerStatisticsTooManyRequestsResponseBody $body; private ResponseInterface|null $httpResponse = null; - public function __construct(GetExtensionshealthTooManyRequestsResponseBody $body) + public function __construct(StoragespaceGetServerStatisticsTooManyRequestsResponseBody $body) { $this->body = $body; } - public function getBody(): GetExtensionshealthTooManyRequestsResponseBody + public function getBody(): StoragespaceGetServerStatisticsTooManyRequestsResponseBody { return $this->body; } - public function withBody(GetExtensionshealthTooManyRequestsResponseBody $body): self + public function withBody(StoragespaceGetServerStatisticsTooManyRequestsResponseBody $body): self { $clone = clone $this; $clone->body = $body; @@ -63,17 +63,17 @@ public function withBody(GetExtensionshealthTooManyRequestsResponseBody $body): * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthTooManyRequestsResponse Created instance + * @return StoragespaceGetServerStatisticsTooManyRequestsResponse Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthTooManyRequestsResponse + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsTooManyRequestsResponse { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { static::validateInput($input); } - $body = GetExtensionshealthTooManyRequestsResponseBody::buildFromInput($input->{'body'}, validate: $validate); + $body = StoragespaceGetServerStatisticsTooManyRequestsResponseBody::buildFromInput($input->{'body'}, validate: $validate); $obj = new self($body); diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponseBody.php b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponseBody.php similarity index 92% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponseBody.php rename to src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponseBody.php index e2e5223a..2d30a7df 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthTooManyRequestsResponseBody.php +++ b/src/Generated/V2/Clients/Project/StoragespaceGetServerStatistics/StoragespaceGetServerStatisticsTooManyRequestsResponseBody.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceGetServerStatistics; use InvalidArgumentException; use JsonSchema\Validator; -class GetExtensionshealthTooManyRequestsResponseBody +class StoragespaceGetServerStatisticsTooManyRequestsResponseBody { /** * Schema used to validate input for creating instances of this class @@ -96,10 +96,10 @@ public function withoutType(): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthTooManyRequestsResponseBody Created instance + * @return StoragespaceGetServerStatisticsTooManyRequestsResponseBody Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthTooManyRequestsResponseBody + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceGetServerStatisticsTooManyRequestsResponseBody { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdDefaultResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdDefaultResponse.php new file mode 100644 index 00000000..49b27cec --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdDefaultResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceProjectNotificationThresholdDefaultResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdDefaultResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdForbiddenResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdForbiddenResponse.php new file mode 100644 index 00000000..9492c026 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdForbiddenResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceProjectNotificationThresholdForbiddenResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdForbiddenResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse.php new file mode 100644 index 00000000..b13b0987 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdInternalServerErrorResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequest.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequest.php new file mode 100644 index 00000000..14263748 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequest.php @@ -0,0 +1,202 @@ + 'object', + 'properties' => [ + 'projectId' => [ + 'type' => 'string', + ], + 'body' => [ + 'properties' => [ + 'notificationThresholdInBytes' => [ + 'example' => 10000, + 'nullable' => true, + 'type' => 'integer', + ], + ], + ], + ], + 'required' => [ + 'projectId', + 'body', + ], + ]; + + private string $projectId; + + private StoragespaceReplaceProjectNotificationThresholdRequestBody $body; + + private array $headers = [ + + ]; + + public function __construct(string $projectId, StoragespaceReplaceProjectNotificationThresholdRequestBody $body) + { + $this->projectId = $projectId; + $this->body = $body; + } + + public function getProjectId(): string + { + return $this->projectId; + } + + public function getBody(): StoragespaceReplaceProjectNotificationThresholdRequestBody + { + return $this->body; + } + + public function withProjectId(string $projectId): self + { + $validator = new Validator(); + $validator->validate($projectId, static::$schema['properties']['projectId']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->projectId = $projectId; + + return $clone; + } + + public function withBody(StoragespaceReplaceProjectNotificationThresholdRequestBody $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceProjectNotificationThresholdRequest Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdRequest + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $projectId = $input->{'projectId'}; + $body = StoragespaceReplaceProjectNotificationThresholdRequestBody::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($projectId, $body); + + 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['projectId'] = $this->projectId; + $output['body'] = ($this->body)->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->body = clone $this->body; + } + + /** + * Builds the URL for this request + * + * This method is used internally by the client to build the URL for this request. + * You should not need to call this method directly. + * + * @internal + * @return string The URL for this request + */ + public function buildUrl(): string + { + $mapped = $this->toJson(); + $projectId = urlencode($mapped['projectId']); + return '/v2/projects/' . $projectId . '/storage-space-notification-threshold'; + } + + /** + * Builds the request options for this request + * + * This method is used internally by the client to build the Guzzle request options + * for this request. You should not need to call this method directly. + * + * @internal + * @return array The Guzzle request options for this request + */ + public function buildRequestOptions(): array + { + $mapped = $this->toJson(); + $query = []; + return [ + 'query' => $query, + 'headers' => $this->headers, + 'json' => $this->getBody()->toJson(), + ]; + } + + /** + * Adds a header to this request + * + * You can use this method to add custom HTTP headers to the request. + * + * @param string $name The name of the header to add + * @param string|array $value The value of the header to add + * @return self A clone of this request with the header added + */ + public function withHeader(string $name, string|array $value): self + { + $clone = clone $this; + $clone->headers[$name] = $value; + return $clone; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequestBody.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequestBody.php new file mode 100644 index 00000000..5653eba0 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdRequestBody.php @@ -0,0 +1,128 @@ + [ + 'notificationThresholdInBytes' => [ + 'example' => 10000, + 'nullable' => true, + 'type' => 'integer', + ], + ], + ]; + + private ?int $notificationThresholdInBytes = null; + + /** + * + */ + public function __construct() + { + } + + public function getNotificationThresholdInBytes(): ?int + { + return $this->notificationThresholdInBytes ?? null; + } + + public function withNotificationThresholdInBytes(int $notificationThresholdInBytes): self + { + $validator = new Validator(); + $validator->validate($notificationThresholdInBytes, static::$schema['properties']['notificationThresholdInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->notificationThresholdInBytes = $notificationThresholdInBytes; + + return $clone; + } + + public function withoutNotificationThresholdInBytes(): self + { + $clone = clone $this; + unset($clone->notificationThresholdInBytes); + + 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 StoragespaceReplaceProjectNotificationThresholdRequestBody Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdRequestBody + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $notificationThresholdInBytes = null; + if (isset($input->{'notificationThresholdInBytes'})) { + $notificationThresholdInBytes = (int)($input->{'notificationThresholdInBytes'}); + } + + $obj = new self(); + $obj->notificationThresholdInBytes = $notificationThresholdInBytes; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->notificationThresholdInBytes)) { + $output['notificationThresholdInBytes'] = $this->notificationThresholdInBytes; + } + + 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() + { + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse.php new file mode 100644 index 00000000..8305a447 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse.php @@ -0,0 +1,141 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + 'type' => 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', + ], + ], + ], + ], + ]; + + private StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody $body) + { + $this->body = $body; + } + + /** + * @return + * StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody + */ + public function getBody(): StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody + { + return $this->body; + } + + public function withBody(StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = ($this->body)->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->body = clone $this->body; + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody.php new file mode 100644 index 00000000..d677ac3c --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceProjectNotificationThreshold/StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody.php @@ -0,0 +1,169 @@ + 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', + ], + ], + ]; + + private ?string $message = null; + + private ?string $type = null; + + /** + * + */ + public function __construct() + { + } + + public function getMessage(): ?string + { + return $this->message ?? null; + } + + public function getType(): ?string + { + return $this->type ?? null; + } + + public function withMessage(string $message): self + { + $validator = new Validator(); + $validator->validate($message, static::$schema['properties']['message']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->message = $message; + + return $clone; + } + + public function withoutMessage(): self + { + $clone = clone $this; + unset($clone->message); + + return $clone; + } + + public function withType(string $type): self + { + $validator = new Validator(); + $validator->validate($type, static::$schema['properties']['type']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->type = $type; + + return $clone; + } + + public function withoutType(): self + { + $clone = clone $this; + unset($clone->type); + + 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 StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceProjectNotificationThresholdTooManyRequestsResponseBody + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $message = null; + if (isset($input->{'message'})) { + $message = $input->{'message'}; + } + $type = null; + if (isset($input->{'type'})) { + $type = $input->{'type'}; + } + + $obj = new self(); + $obj->message = $message; + $obj->type = $type; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->message)) { + $output['message'] = $this->message; + } + if (isset($this->type)) { + $output['type'] = $this->type; + } + + 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() + { + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdDefaultResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdDefaultResponse.php new file mode 100644 index 00000000..22ffc5f3 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdDefaultResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceServerNotificationThresholdDefaultResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdDefaultResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdForbiddenResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdForbiddenResponse.php new file mode 100644 index 00000000..0dbed5ec --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdForbiddenResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceServerNotificationThresholdForbiddenResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdForbiddenResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse.php new file mode 100644 index 00000000..ef508d0a --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse.php @@ -0,0 +1,127 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.commons.Error', + ], + ], + ]; + + private Error $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(Error $body) + { + $this->body = $body; + } + + public function getBody(): Error + { + return $this->body; + } + + public function withBody(Error $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdInternalServerErrorResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = Error::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = $this->body->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() + { + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequest.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequest.php new file mode 100644 index 00000000..935c690e --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequest.php @@ -0,0 +1,202 @@ + 'object', + 'properties' => [ + 'serverId' => [ + 'type' => 'string', + ], + 'body' => [ + 'properties' => [ + 'notificationThresholdInBytes' => [ + 'example' => 10000, + 'nullable' => true, + 'type' => 'integer', + ], + ], + ], + ], + 'required' => [ + 'serverId', + 'body', + ], + ]; + + private string $serverId; + + private StoragespaceReplaceServerNotificationThresholdRequestBody $body; + + private array $headers = [ + + ]; + + public function __construct(string $serverId, StoragespaceReplaceServerNotificationThresholdRequestBody $body) + { + $this->serverId = $serverId; + $this->body = $body; + } + + public function getServerId(): string + { + return $this->serverId; + } + + public function getBody(): StoragespaceReplaceServerNotificationThresholdRequestBody + { + return $this->body; + } + + public function withServerId(string $serverId): self + { + $validator = new Validator(); + $validator->validate($serverId, static::$schema['properties']['serverId']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->serverId = $serverId; + + return $clone; + } + + public function withBody(StoragespaceReplaceServerNotificationThresholdRequestBody $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceServerNotificationThresholdRequest Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdRequest + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $serverId = $input->{'serverId'}; + $body = StoragespaceReplaceServerNotificationThresholdRequestBody::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($serverId, $body); + + 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['serverId'] = $this->serverId; + $output['body'] = ($this->body)->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->body = clone $this->body; + } + + /** + * Builds the URL for this request + * + * This method is used internally by the client to build the URL for this request. + * You should not need to call this method directly. + * + * @internal + * @return string The URL for this request + */ + public function buildUrl(): string + { + $mapped = $this->toJson(); + $serverId = urlencode($mapped['serverId']); + return '/v2/servers/' . $serverId . '/storage-space-notification-threshold'; + } + + /** + * Builds the request options for this request + * + * This method is used internally by the client to build the Guzzle request options + * for this request. You should not need to call this method directly. + * + * @internal + * @return array The Guzzle request options for this request + */ + public function buildRequestOptions(): array + { + $mapped = $this->toJson(); + $query = []; + return [ + 'query' => $query, + 'headers' => $this->headers, + 'json' => $this->getBody()->toJson(), + ]; + } + + /** + * Adds a header to this request + * + * You can use this method to add custom HTTP headers to the request. + * + * @param string $name The name of the header to add + * @param string|array $value The value of the header to add + * @return self A clone of this request with the header added + */ + public function withHeader(string $name, string|array $value): self + { + $clone = clone $this; + $clone->headers[$name] = $value; + return $clone; + } +} diff --git a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponseBody.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequestBody.php similarity index 52% rename from src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponseBody.php rename to src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequestBody.php index e05351dc..4448b83f 100644 --- a/src/Generated/V2/Clients/Marketplace/GetExtensionshealth/GetExtensionshealthOKResponseBody.php +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdRequestBody.php @@ -2,60 +2,58 @@ declare(strict_types=1); -namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\GetExtensionshealth; +namespace Mittwald\ApiClient\Generated\V2\Clients\Project\StoragespaceReplaceServerNotificationThreshold; use InvalidArgumentException; use JsonSchema\Validator; -use Mittwald\ApiClient\Generated\V2\Schemas\Marketplace\ExtensionHealth; -class GetExtensionshealthOKResponseBody +class StoragespaceReplaceServerNotificationThresholdRequestBody { /** * Schema used to validate input for creating instances of this class */ private static array $schema = [ 'properties' => [ - 'extensionsHealth' => [ - 'items' => [ - '$ref' => '#/components/schemas/de.mittwald.v1.marketplace.ExtensionHealth', - ], - 'type' => 'array', + 'notificationThresholdInBytes' => [ + 'example' => 10000, + 'nullable' => true, + 'type' => 'integer', ], ], - 'required' => [ - 'extensionsHealth', - ], - 'type' => 'object', ]; - /** - * @var ExtensionHealth[] - */ - private array $extensionsHealth; + private ?int $notificationThresholdInBytes = null; /** - * @param ExtensionHealth[] $extensionsHealth + * */ - public function __construct(array $extensionsHealth) + public function __construct() { - $this->extensionsHealth = $extensionsHealth; } - /** - * @return ExtensionHealth[] - */ - public function getExtensionsHealth(): array + public function getNotificationThresholdInBytes(): ?int { - return $this->extensionsHealth; + return $this->notificationThresholdInBytes ?? null; } - /** - * @param ExtensionHealth[] $extensionsHealth - */ - public function withExtensionsHealth(array $extensionsHealth): self + public function withNotificationThresholdInBytes(int $notificationThresholdInBytes): self { + $validator = new Validator(); + $validator->validate($notificationThresholdInBytes, static::$schema['properties']['notificationThresholdInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + $clone = clone $this; - $clone->extensionsHealth = $extensionsHealth; + $clone->notificationThresholdInBytes = $notificationThresholdInBytes; + + return $clone; + } + + public function withoutNotificationThresholdInBytes(): self + { + $clone = clone $this; + unset($clone->notificationThresholdInBytes); return $clone; } @@ -65,20 +63,23 @@ public function withExtensionsHealth(array $extensionsHealth): self * * @param array|object $input Input data * @param bool $validate Set this to false to skip validation; use at own risk - * @return GetExtensionshealthOKResponseBody Created instance + * @return StoragespaceReplaceServerNotificationThresholdRequestBody Created instance * @throws InvalidArgumentException */ - public static function buildFromInput(array|object $input, bool $validate = true): GetExtensionshealthOKResponseBody + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdRequestBody { $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; if ($validate) { static::validateInput($input); } - $extensionsHealth = array_map(fn (array|object $i): ExtensionHealth => ExtensionHealth::buildFromInput($i, validate: $validate), $input->{'extensionsHealth'}); - - $obj = new self($extensionsHealth); + $notificationThresholdInBytes = null; + if (isset($input->{'notificationThresholdInBytes'})) { + $notificationThresholdInBytes = (int)($input->{'notificationThresholdInBytes'}); + } + $obj = new self(); + $obj->notificationThresholdInBytes = $notificationThresholdInBytes; return $obj; } @@ -90,7 +91,9 @@ public static function buildFromInput(array|object $input, bool $validate = true public function toJson(): array { $output = []; - $output['extensionsHealth'] = array_map(fn (ExtensionHealth $i): array => $i->toJson(), $this->extensionsHealth); + if (isset($this->notificationThresholdInBytes)) { + $output['notificationThresholdInBytes'] = $this->notificationThresholdInBytes; + } return $output; } diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse.php new file mode 100644 index 00000000..1a50720a --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse.php @@ -0,0 +1,141 @@ + 'object', + 'required' => [ + 'body', + ], + 'properties' => [ + 'body' => [ + 'type' => 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', + ], + ], + ], + ], + ]; + + private StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody $body; + + private ResponseInterface|null $httpResponse = null; + + public function __construct(StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody $body) + { + $this->body = $body; + } + + /** + * @return + * StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody + */ + public function getBody(): StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody + { + return $this->body; + } + + public function withBody(StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody $body): self + { + $clone = clone $this; + $clone->body = $body; + + 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 StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponse + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $body = StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody::buildFromInput($input->{'body'}, validate: $validate); + + $obj = new self($body); + + 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['body'] = ($this->body)->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->body = clone $this->body; + } + + public static function fromResponse(ResponseInterface $httpResponse): self + { + $parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true); + $response = static::buildFromInput(['body' => $parsedBody], validate: false); + $response->httpResponse = $httpResponse; + return $response; + } + + public function getResponse(): ResponseInterface|null + { + return $this->httpResponse; + } +} diff --git a/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody.php b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody.php new file mode 100644 index 00000000..56c38481 --- /dev/null +++ b/src/Generated/V2/Clients/Project/StoragespaceReplaceServerNotificationThreshold/StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody.php @@ -0,0 +1,169 @@ + 'object', + 'properties' => [ + 'message' => [ + 'type' => 'string', + 'example' => 'too many requests', + ], + 'type' => [ + 'type' => 'string', + 'example' => 'RateLimitError', + ], + ], + ]; + + private ?string $message = null; + + private ?string $type = null; + + /** + * + */ + public function __construct() + { + } + + public function getMessage(): ?string + { + return $this->message ?? null; + } + + public function getType(): ?string + { + return $this->type ?? null; + } + + public function withMessage(string $message): self + { + $validator = new Validator(); + $validator->validate($message, static::$schema['properties']['message']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->message = $message; + + return $clone; + } + + public function withoutMessage(): self + { + $clone = clone $this; + unset($clone->message); + + return $clone; + } + + public function withType(string $type): self + { + $validator = new Validator(); + $validator->validate($type, static::$schema['properties']['type']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->type = $type; + + return $clone; + } + + public function withoutType(): self + { + $clone = clone $this; + unset($clone->type); + + 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 StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StoragespaceReplaceServerNotificationThresholdTooManyRequestsResponseBody + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $message = null; + if (isset($input->{'message'})) { + $message = $input->{'message'}; + } + $type = null; + if (isset($input->{'type'})) { + $type = $input->{'type'}; + } + + $obj = new self(); + $obj->message = $message; + $obj->type = $type; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->message)) { + $output['message'] = $this->message; + } + if (isset($this->type)) { + $output['type'] = $this->type; + } + + 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() + { + } +} diff --git a/src/Generated/V2/Schemas/Marketplace/ExtensionHealth.php b/src/Generated/V2/Schemas/Marketplace/ExtensionHealth.php index 834a3abf..c1b1f07d 100644 --- a/src/Generated/V2/Schemas/Marketplace/ExtensionHealth.php +++ b/src/Generated/V2/Schemas/Marketplace/ExtensionHealth.php @@ -24,49 +24,77 @@ class ExtensionHealth */ private static array $schema = [ 'properties' => [ + 'disfunctionalReason' => [ + 'type' => 'string', + ], 'extensionInstancesHealth' => [ + 'default' => [ + + ], 'items' => [ '$ref' => '#/components/schemas/de.mittwald.v1.marketplace.ExtensionInstanceHealth', ], 'type' => 'array', ], 'functional' => [ + 'default' => false, 'type' => 'boolean', ], 'id' => [ 'format' => 'uuid', 'type' => 'string', ], + 'published' => [ + 'default' => false, + 'type' => 'boolean', + ], + 'withdrawalReason' => [ + 'type' => 'string', + ], ], 'required' => [ 'id', 'functional', + 'published', + 'extensionInstancesHealth', ], 'type' => 'object', ]; + private ?string $disfunctionalReason = null; + /** - * @var ExtensionInstanceHealth[]|null + * @var ExtensionInstanceHealth[] */ - private ?array $extensionInstancesHealth = null; + private array $extensionInstancesHealth = [ + + ]; - private bool $functional; + private bool $functional = false; private string $id; - public function __construct(bool $functional, string $id) + private bool $published = false; + + private ?string $withdrawalReason = null; + + public function __construct(string $id) { - $this->functional = $functional; $this->id = $id; } + public function getDisfunctionalReason(): ?string + { + return $this->disfunctionalReason ?? null; + } + /** * @return - * ExtensionInstanceHealth[]|null + * ExtensionInstanceHealth[] */ - public function getExtensionInstancesHealth(): ?array + public function getExtensionInstancesHealth(): array { - return $this->extensionInstancesHealth ?? null; + return $this->extensionInstancesHealth; } public function getFunctional(): bool @@ -79,21 +107,45 @@ public function getId(): string return $this->id; } - /** - * @param ExtensionInstanceHealth[] $extensionInstancesHealth - */ - public function withExtensionInstancesHealth(array $extensionInstancesHealth): self + public function getPublished(): bool { + return $this->published; + } + + public function getWithdrawalReason(): ?string + { + return $this->withdrawalReason ?? null; + } + + public function withDisfunctionalReason(string $disfunctionalReason): self + { + $validator = new Validator(); + $validator->validate($disfunctionalReason, static::$schema['properties']['disfunctionalReason']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + $clone = clone $this; - $clone->extensionInstancesHealth = $extensionInstancesHealth; + $clone->disfunctionalReason = $disfunctionalReason; return $clone; } - public function withoutExtensionInstancesHealth(): self + public function withoutDisfunctionalReason(): self { $clone = clone $this; - unset($clone->extensionInstancesHealth); + unset($clone->disfunctionalReason); + + return $clone; + } + + /** + * @param ExtensionInstanceHealth[] $extensionInstancesHealth + */ + public function withExtensionInstancesHealth(array $extensionInstancesHealth): self + { + $clone = clone $this; + $clone->extensionInstancesHealth = $extensionInstancesHealth; return $clone; } @@ -126,6 +178,42 @@ public function withId(string $id): self return $clone; } + public function withPublished(bool $published): self + { + $validator = new Validator(); + $validator->validate($published, static::$schema['properties']['published']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->published = $published; + + return $clone; + } + + public function withWithdrawalReason(string $withdrawalReason): self + { + $validator = new Validator(); + $validator->validate($withdrawalReason, static::$schema['properties']['withdrawalReason']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->withdrawalReason = $withdrawalReason; + + return $clone; + } + + public function withoutWithdrawalReason(): self + { + $clone = clone $this; + unset($clone->withdrawalReason); + + return $clone; + } + /** * Builds a new instance from an input array * @@ -141,15 +229,36 @@ public static function buildFromInput(array|object $input, bool $validate = true static::validateInput($input); } - $extensionInstancesHealth = null; + $disfunctionalReason = null; + if (isset($input->{'disfunctionalReason'})) { + $disfunctionalReason = $input->{'disfunctionalReason'}; + } + $extensionInstancesHealth = [ + + ]; if (isset($input->{'extensionInstancesHealth'})) { $extensionInstancesHealth = array_map(fn (array|object $i): ExtensionInstanceHealth => ExtensionInstanceHealth::buildFromInput($i, validate: $validate), $input->{'extensionInstancesHealth'}); } - $functional = (bool)($input->{'functional'}); + $functional = false; + if (isset($input->{'functional'})) { + $functional = (bool)($input->{'functional'}); + } $id = $input->{'id'}; + $published = false; + if (isset($input->{'published'})) { + $published = (bool)($input->{'published'}); + } + $withdrawalReason = null; + if (isset($input->{'withdrawalReason'})) { + $withdrawalReason = $input->{'withdrawalReason'}; + } - $obj = new self($functional, $id); + $obj = new self($id); + $obj->disfunctionalReason = $disfunctionalReason; $obj->extensionInstancesHealth = $extensionInstancesHealth; + $obj->functional = $functional; + $obj->published = $published; + $obj->withdrawalReason = $withdrawalReason; return $obj; } @@ -161,11 +270,16 @@ public static function buildFromInput(array|object $input, bool $validate = true public function toJson(): array { $output = []; - if (isset($this->extensionInstancesHealth)) { - $output['extensionInstancesHealth'] = array_map(fn (ExtensionInstanceHealth $i): array => $i->toJson(), $this->extensionInstancesHealth); + if (isset($this->disfunctionalReason)) { + $output['disfunctionalReason'] = $this->disfunctionalReason; } + $output['extensionInstancesHealth'] = array_map(fn (ExtensionInstanceHealth $i): array => $i->toJson(), $this->extensionInstancesHealth); $output['functional'] = $this->functional; $output['id'] = $this->id; + $output['published'] = $this->published; + if (isset($this->withdrawalReason)) { + $output['withdrawalReason'] = $this->withdrawalReason; + } return $output; } diff --git a/src/Generated/V2/Schemas/Marketplace/ExtensionInstanceHealth.php b/src/Generated/V2/Schemas/Marketplace/ExtensionInstanceHealth.php index 1b5d6b31..6df080e5 100644 --- a/src/Generated/V2/Schemas/Marketplace/ExtensionInstanceHealth.php +++ b/src/Generated/V2/Schemas/Marketplace/ExtensionInstanceHealth.php @@ -29,34 +29,42 @@ class ExtensionInstanceHealth 'type' => 'string', ], 'pendingInstallation' => [ + 'default' => false, 'type' => 'boolean', ], - 'pendingRemval' => [ + 'pendingRemoval' => [ + 'default' => false, 'type' => 'boolean', ], 'pendingWebhooks' => [ + 'default' => 0, 'minimum' => 0, 'type' => 'integer', ], 'webhooksHalted' => [ + 'default' => false, 'type' => 'boolean', ], ], 'required' => [ 'id', + 'webhooksHalted', + 'pendingInstallation', + 'pendingRemoval', + 'pendingWebhooks', ], 'type' => 'object', ]; private string $id; - private ?bool $pendingInstallation = null; + private bool $pendingInstallation = false; - private ?bool $pendingRemval = null; + private bool $pendingRemoval = false; - private ?int $pendingWebhooks = null; + private int $pendingWebhooks = 0; - private ?bool $webhooksHalted = null; + private bool $webhooksHalted = false; public function __construct(string $id) { @@ -68,24 +76,24 @@ public function getId(): string return $this->id; } - public function getPendingInstallation(): ?bool + public function getPendingInstallation(): bool { - return $this->pendingInstallation ?? null; + return $this->pendingInstallation; } - public function getPendingRemval(): ?bool + public function getPendingRemoval(): bool { - return $this->pendingRemval ?? null; + return $this->pendingRemoval; } - public function getPendingWebhooks(): ?int + public function getPendingWebhooks(): int { - return $this->pendingWebhooks ?? null; + return $this->pendingWebhooks; } - public function getWebhooksHalted(): ?bool + public function getWebhooksHalted(): bool { - return $this->webhooksHalted ?? null; + return $this->webhooksHalted; } public function withId(string $id): self @@ -116,32 +124,16 @@ public function withPendingInstallation(bool $pendingInstallation): self return $clone; } - public function withoutPendingInstallation(): self - { - $clone = clone $this; - unset($clone->pendingInstallation); - - return $clone; - } - - public function withPendingRemval(bool $pendingRemval): self + public function withPendingRemoval(bool $pendingRemoval): self { $validator = new Validator(); - $validator->validate($pendingRemval, static::$schema['properties']['pendingRemval']); + $validator->validate($pendingRemoval, static::$schema['properties']['pendingRemoval']); if (!$validator->isValid()) { throw new InvalidArgumentException($validator->getErrors()[0]['message']); } $clone = clone $this; - $clone->pendingRemval = $pendingRemval; - - return $clone; - } - - public function withoutPendingRemval(): self - { - $clone = clone $this; - unset($clone->pendingRemval); + $clone->pendingRemoval = $pendingRemoval; return $clone; } @@ -160,14 +152,6 @@ public function withPendingWebhooks(int $pendingWebhooks): self return $clone; } - public function withoutPendingWebhooks(): self - { - $clone = clone $this; - unset($clone->pendingWebhooks); - - return $clone; - } - public function withWebhooksHalted(bool $webhooksHalted): self { $validator = new Validator(); @@ -182,14 +166,6 @@ public function withWebhooksHalted(bool $webhooksHalted): self return $clone; } - public function withoutWebhooksHalted(): self - { - $clone = clone $this; - unset($clone->webhooksHalted); - - return $clone; - } - /** * Builds a new instance from an input array * @@ -206,26 +182,26 @@ public static function buildFromInput(array|object $input, bool $validate = true } $id = $input->{'id'}; - $pendingInstallation = null; + $pendingInstallation = false; if (isset($input->{'pendingInstallation'})) { $pendingInstallation = (bool)($input->{'pendingInstallation'}); } - $pendingRemval = null; - if (isset($input->{'pendingRemval'})) { - $pendingRemval = (bool)($input->{'pendingRemval'}); + $pendingRemoval = false; + if (isset($input->{'pendingRemoval'})) { + $pendingRemoval = (bool)($input->{'pendingRemoval'}); } - $pendingWebhooks = null; + $pendingWebhooks = 0; if (isset($input->{'pendingWebhooks'})) { $pendingWebhooks = (int)($input->{'pendingWebhooks'}); } - $webhooksHalted = null; + $webhooksHalted = false; if (isset($input->{'webhooksHalted'})) { $webhooksHalted = (bool)($input->{'webhooksHalted'}); } $obj = new self($id); $obj->pendingInstallation = $pendingInstallation; - $obj->pendingRemval = $pendingRemval; + $obj->pendingRemoval = $pendingRemoval; $obj->pendingWebhooks = $pendingWebhooks; $obj->webhooksHalted = $webhooksHalted; return $obj; @@ -240,18 +216,10 @@ public function toJson(): array { $output = []; $output['id'] = $this->id; - if (isset($this->pendingInstallation)) { - $output['pendingInstallation'] = $this->pendingInstallation; - } - if (isset($this->pendingRemval)) { - $output['pendingRemval'] = $this->pendingRemval; - } - if (isset($this->pendingWebhooks)) { - $output['pendingWebhooks'] = $this->pendingWebhooks; - } - if (isset($this->webhooksHalted)) { - $output['webhooksHalted'] = $this->webhooksHalted; - } + $output['pendingInstallation'] = $this->pendingInstallation; + $output['pendingRemoval'] = $this->pendingRemoval; + $output['pendingWebhooks'] = $this->pendingWebhooks; + $output['webhooksHalted'] = $this->webhooksHalted; return $output; } diff --git a/src/Generated/V2/Schemas/Storagespace/Statistics.php b/src/Generated/V2/Schemas/Storagespace/Statistics.php new file mode 100644 index 00000000..67fa5796 --- /dev/null +++ b/src/Generated/V2/Schemas/Storagespace/Statistics.php @@ -0,0 +1,375 @@ + [ + 'childStatistics' => [ + 'items' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.Statistics', + ], + 'type' => 'array', + 'uniqueItems' => true, + ], + 'description' => [ + 'example' => 'My First Project', + 'type' => 'string', + ], + 'id' => [ + 'example' => '169cea81-2c11-46a4-8f0b-5b0b47caeb78', + 'type' => 'string', + ], + 'kind' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.StatisticsKind', + ], + 'meta' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.StatisticsMeta', + ], + 'name' => [ + 'example' => 'p-zkl8tr', + 'type' => 'string', + ], + 'notificationThresholdInBytes' => [ + 'example' => 10000, + 'type' => 'integer', + ], + 'statisticCategories' => [ + 'items' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.StatisticsCategory', + ], + 'type' => 'array', + 'uniqueItems' => true, + ], + ], + 'required' => [ + 'id', + 'kind', + 'name', + 'meta', + ], + 'type' => 'object', + ]; + + /** + * @var Statistics[]|null + */ + private ?array $childStatistics = null; + + private ?string $description = null; + + private string $id; + + private StatisticsKind $kind; + + private StatisticsMeta $meta; + + private string $name; + + private ?int $notificationThresholdInBytes = null; + + /** + * @var StatisticsCategory[]|null + */ + private ?array $statisticCategories = null; + + public function __construct(string $id, StatisticsKind $kind, StatisticsMeta $meta, string $name) + { + $this->id = $id; + $this->kind = $kind; + $this->meta = $meta; + $this->name = $name; + } + + /** + * @return Statistics[]|null + */ + public function getChildStatistics(): ?array + { + return $this->childStatistics ?? null; + } + + public function getDescription(): ?string + { + return $this->description ?? null; + } + + public function getId(): string + { + return $this->id; + } + + public function getKind(): StatisticsKind + { + return $this->kind; + } + + public function getMeta(): StatisticsMeta + { + return $this->meta; + } + + public function getName(): string + { + return $this->name; + } + + public function getNotificationThresholdInBytes(): ?int + { + return $this->notificationThresholdInBytes ?? null; + } + + /** + * @return + * StatisticsCategory[]|null + */ + public function getStatisticCategories(): ?array + { + return $this->statisticCategories ?? null; + } + + /** + * @param Statistics[] $childStatistics + */ + public function withChildStatistics(array $childStatistics): self + { + $clone = clone $this; + $clone->childStatistics = $childStatistics; + + return $clone; + } + + public function withoutChildStatistics(): self + { + $clone = clone $this; + unset($clone->childStatistics); + + return $clone; + } + + public function withDescription(string $description): self + { + $validator = new Validator(); + $validator->validate($description, static::$schema['properties']['description']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->description = $description; + + return $clone; + } + + public function withoutDescription(): self + { + $clone = clone $this; + unset($clone->description); + + return $clone; + } + + public function withId(string $id): self + { + $validator = new Validator(); + $validator->validate($id, static::$schema['properties']['id']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->id = $id; + + return $clone; + } + + public function withKind(StatisticsKind $kind): self + { + $clone = clone $this; + $clone->kind = $kind; + + return $clone; + } + + public function withMeta(StatisticsMeta $meta): self + { + $clone = clone $this; + $clone->meta = $meta; + + return $clone; + } + + public function withName(string $name): self + { + $validator = new Validator(); + $validator->validate($name, static::$schema['properties']['name']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->name = $name; + + return $clone; + } + + public function withNotificationThresholdInBytes(int $notificationThresholdInBytes): self + { + $validator = new Validator(); + $validator->validate($notificationThresholdInBytes, static::$schema['properties']['notificationThresholdInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->notificationThresholdInBytes = $notificationThresholdInBytes; + + return $clone; + } + + public function withoutNotificationThresholdInBytes(): self + { + $clone = clone $this; + unset($clone->notificationThresholdInBytes); + + return $clone; + } + + /** + * @param StatisticsCategory[] $statisticCategories + */ + public function withStatisticCategories(array $statisticCategories): self + { + $clone = clone $this; + $clone->statisticCategories = $statisticCategories; + + return $clone; + } + + public function withoutStatisticCategories(): self + { + $clone = clone $this; + unset($clone->statisticCategories); + + 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 Statistics Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): Statistics + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $childStatistics = null; + if (isset($input->{'childStatistics'})) { + $childStatistics = array_map(fn (array|object $i): Statistics => Statistics::buildFromInput($i, validate: $validate), $input->{'childStatistics'}); + } + $description = null; + if (isset($input->{'description'})) { + $description = $input->{'description'}; + } + $id = $input->{'id'}; + $kind = StatisticsKind::from($input->{'kind'}); + $meta = StatisticsMeta::buildFromInput($input->{'meta'}, validate: $validate); + $name = $input->{'name'}; + $notificationThresholdInBytes = null; + if (isset($input->{'notificationThresholdInBytes'})) { + $notificationThresholdInBytes = (int)($input->{'notificationThresholdInBytes'}); + } + $statisticCategories = null; + if (isset($input->{'statisticCategories'})) { + $statisticCategories = array_map(fn (array|object $i): StatisticsCategory => StatisticsCategory::buildFromInput($i, validate: $validate), $input->{'statisticCategories'}); + } + + $obj = new self($id, $kind, $meta, $name); + $obj->childStatistics = $childStatistics; + $obj->description = $description; + $obj->notificationThresholdInBytes = $notificationThresholdInBytes; + $obj->statisticCategories = $statisticCategories; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->childStatistics)) { + $output['childStatistics'] = array_map(fn (Statistics $i): array => $i->toJson(), $this->childStatistics); + } + if (isset($this->description)) { + $output['description'] = $this->description; + } + $output['id'] = $this->id; + $output['kind'] = $this->kind->value; + $output['meta'] = $this->meta->toJson(); + $output['name'] = $this->name; + if (isset($this->notificationThresholdInBytes)) { + $output['notificationThresholdInBytes'] = $this->notificationThresholdInBytes; + } + if (isset($this->statisticCategories)) { + $output['statisticCategories'] = array_map(fn (StatisticsCategory $i): array => $i->toJson(), $this->statisticCategories); + } + + 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() + { + } +} diff --git a/src/Generated/V2/Schemas/Storagespace/StatisticsCategory.php b/src/Generated/V2/Schemas/Storagespace/StatisticsCategory.php new file mode 100644 index 00000000..36dc54a1 --- /dev/null +++ b/src/Generated/V2/Schemas/Storagespace/StatisticsCategory.php @@ -0,0 +1,199 @@ + [ + 'kind' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.StatisticsCategoryKind', + ], + 'resources' => [ + 'items' => [ + '$ref' => '#/components/schemas/de.mittwald.v1.storagespace.StatisticsResource', + ], + 'type' => 'array', + 'uniqueItems' => true, + ], + 'totalUsageInBytes' => [ + 'example' => 1000, + 'type' => 'integer', + ], + ], + 'required' => [ + 'kind', + 'totalUsageInBytes', + ], + 'type' => 'object', + ]; + + private StatisticsCategoryKind $kind; + + /** + * @var StatisticsResource[]|null + */ + private ?array $resources = null; + + private int $totalUsageInBytes; + + public function __construct(StatisticsCategoryKind $kind, int $totalUsageInBytes) + { + $this->kind = $kind; + $this->totalUsageInBytes = $totalUsageInBytes; + } + + /** + * @return + * StatisticsCategoryKind + */ + public function getKind(): StatisticsCategoryKind + { + return $this->kind; + } + + /** + * @return + * StatisticsResource[]|null + */ + public function getResources(): ?array + { + return $this->resources ?? null; + } + + public function getTotalUsageInBytes(): int + { + return $this->totalUsageInBytes; + } + + public function withKind(StatisticsCategoryKind $kind): self + { + $clone = clone $this; + $clone->kind = $kind; + + return $clone; + } + + /** + * @param StatisticsResource[] $resources + */ + public function withResources(array $resources): self + { + $clone = clone $this; + $clone->resources = $resources; + + return $clone; + } + + public function withoutResources(): self + { + $clone = clone $this; + unset($clone->resources); + + return $clone; + } + + public function withTotalUsageInBytes(int $totalUsageInBytes): self + { + $validator = new Validator(); + $validator->validate($totalUsageInBytes, static::$schema['properties']['totalUsageInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalUsageInBytes = $totalUsageInBytes; + + 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 StatisticsCategory Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StatisticsCategory + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $kind = StatisticsCategoryKind::from($input->{'kind'}); + $resources = null; + if (isset($input->{'resources'})) { + $resources = array_map(fn (array|object $i): StatisticsResource => StatisticsResource::buildFromInput($i, validate: $validate), $input->{'resources'}); + } + $totalUsageInBytes = (int)($input->{'totalUsageInBytes'}); + + $obj = new self($kind, $totalUsageInBytes); + $obj->resources = $resources; + 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['kind'] = $this->kind->value; + if (isset($this->resources)) { + $output['resources'] = array_map(fn (StatisticsResource $i): array => $i->toJson(), $this->resources); + } + $output['totalUsageInBytes'] = $this->totalUsageInBytes; + + 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() + { + } +} diff --git a/src/Generated/V2/Schemas/Storagespace/StatisticsCategoryKind.php b/src/Generated/V2/Schemas/Storagespace/StatisticsCategoryKind.php new file mode 100644 index 00000000..fe66a007 --- /dev/null +++ b/src/Generated/V2/Schemas/Storagespace/StatisticsCategoryKind.php @@ -0,0 +1,15 @@ + [ + 'isExceeding' => [ + 'example' => false, + 'type' => 'boolean', + ], + 'limitInBytes' => [ + 'example' => 100000, + 'type' => 'integer', + ], + 'notificationThresholdUsedAsLimit' => [ + 'description' => 'If true, set notification threshold is used as limit for meta calculations. E.g. for projects with a parent server.', + 'example' => false, + 'type' => 'boolean', + ], + 'totalExceedanceInBytes' => [ + 'example' => 10, + 'type' => 'integer', + ], + 'totalExceedanceInBytesSetAt' => [ + 'example' => '2023-12-22T13:46:52.000Z', + 'format' => 'date-time', + 'type' => 'string', + ], + 'totalFreeInBytes' => [ + 'example' => 99000, + 'type' => 'integer', + ], + 'totalFreeInPercentage' => [ + 'example' => 90, + 'type' => 'number', + ], + 'totalUsageInBytes' => [ + 'example' => 1000, + 'type' => 'integer', + ], + 'totalUsageInPercentage' => [ + 'example' => 10, + 'type' => 'number', + ], + ], + 'required' => [ + 'totalUsageInBytes', + ], + 'type' => 'object', + ]; + + private ?bool $isExceeding = null; + + private ?int $limitInBytes = null; + + /** + * If true, set notification threshold is used as limit for meta calculations. E.g. for projects with a parent server. + */ + private ?bool $notificationThresholdUsedAsLimit = null; + + private ?int $totalExceedanceInBytes = null; + + private ?DateTime $totalExceedanceInBytesSetAt = null; + + private ?int $totalFreeInBytes = null; + + private int|float|null $totalFreeInPercentage = null; + + private int $totalUsageInBytes; + + private int|float|null $totalUsageInPercentage = null; + + public function __construct(int $totalUsageInBytes) + { + $this->totalUsageInBytes = $totalUsageInBytes; + } + + public function getIsExceeding(): ?bool + { + return $this->isExceeding ?? null; + } + + public function getLimitInBytes(): ?int + { + return $this->limitInBytes ?? null; + } + + public function getNotificationThresholdUsedAsLimit(): ?bool + { + return $this->notificationThresholdUsedAsLimit ?? null; + } + + public function getTotalExceedanceInBytes(): ?int + { + return $this->totalExceedanceInBytes ?? null; + } + + public function getTotalExceedanceInBytesSetAt(): ?DateTime + { + return $this->totalExceedanceInBytesSetAt ?? null; + } + + public function getTotalFreeInBytes(): ?int + { + return $this->totalFreeInBytes ?? null; + } + + public function getTotalFreeInPercentage(): int|float|null + { + return $this->totalFreeInPercentage; + } + + public function getTotalUsageInBytes(): int + { + return $this->totalUsageInBytes; + } + + public function getTotalUsageInPercentage(): int|float|null + { + return $this->totalUsageInPercentage; + } + + public function withIsExceeding(bool $isExceeding): self + { + $validator = new Validator(); + $validator->validate($isExceeding, static::$schema['properties']['isExceeding']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->isExceeding = $isExceeding; + + return $clone; + } + + public function withoutIsExceeding(): self + { + $clone = clone $this; + unset($clone->isExceeding); + + return $clone; + } + + public function withLimitInBytes(int $limitInBytes): self + { + $validator = new Validator(); + $validator->validate($limitInBytes, static::$schema['properties']['limitInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->limitInBytes = $limitInBytes; + + return $clone; + } + + public function withoutLimitInBytes(): self + { + $clone = clone $this; + unset($clone->limitInBytes); + + return $clone; + } + + public function withNotificationThresholdUsedAsLimit(bool $notificationThresholdUsedAsLimit): self + { + $validator = new Validator(); + $validator->validate($notificationThresholdUsedAsLimit, static::$schema['properties']['notificationThresholdUsedAsLimit']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->notificationThresholdUsedAsLimit = $notificationThresholdUsedAsLimit; + + return $clone; + } + + public function withoutNotificationThresholdUsedAsLimit(): self + { + $clone = clone $this; + unset($clone->notificationThresholdUsedAsLimit); + + return $clone; + } + + public function withTotalExceedanceInBytes(int $totalExceedanceInBytes): self + { + $validator = new Validator(); + $validator->validate($totalExceedanceInBytes, static::$schema['properties']['totalExceedanceInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalExceedanceInBytes = $totalExceedanceInBytes; + + return $clone; + } + + public function withoutTotalExceedanceInBytes(): self + { + $clone = clone $this; + unset($clone->totalExceedanceInBytes); + + return $clone; + } + + public function withTotalExceedanceInBytesSetAt(DateTime $totalExceedanceInBytesSetAt): self + { + $clone = clone $this; + $clone->totalExceedanceInBytesSetAt = $totalExceedanceInBytesSetAt; + + return $clone; + } + + public function withoutTotalExceedanceInBytesSetAt(): self + { + $clone = clone $this; + unset($clone->totalExceedanceInBytesSetAt); + + return $clone; + } + + public function withTotalFreeInBytes(int $totalFreeInBytes): self + { + $validator = new Validator(); + $validator->validate($totalFreeInBytes, static::$schema['properties']['totalFreeInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalFreeInBytes = $totalFreeInBytes; + + return $clone; + } + + public function withoutTotalFreeInBytes(): self + { + $clone = clone $this; + unset($clone->totalFreeInBytes); + + return $clone; + } + + /** + * @param int|float $totalFreeInPercentage + */ + public function withTotalFreeInPercentage(int|float $totalFreeInPercentage): self + { + $validator = new Validator(); + $validator->validate($totalFreeInPercentage, static::$schema['properties']['totalFreeInPercentage']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalFreeInPercentage = $totalFreeInPercentage; + + return $clone; + } + + public function withoutTotalFreeInPercentage(): self + { + $clone = clone $this; + unset($clone->totalFreeInPercentage); + + return $clone; + } + + public function withTotalUsageInBytes(int $totalUsageInBytes): self + { + $validator = new Validator(); + $validator->validate($totalUsageInBytes, static::$schema['properties']['totalUsageInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalUsageInBytes = $totalUsageInBytes; + + return $clone; + } + + /** + * @param int|float $totalUsageInPercentage + */ + public function withTotalUsageInPercentage(int|float $totalUsageInPercentage): self + { + $validator = new Validator(); + $validator->validate($totalUsageInPercentage, static::$schema['properties']['totalUsageInPercentage']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->totalUsageInPercentage = $totalUsageInPercentage; + + return $clone; + } + + public function withoutTotalUsageInPercentage(): self + { + $clone = clone $this; + unset($clone->totalUsageInPercentage); + + 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 StatisticsMeta Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StatisticsMeta + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $isExceeding = null; + if (isset($input->{'isExceeding'})) { + $isExceeding = (bool)($input->{'isExceeding'}); + } + $limitInBytes = null; + if (isset($input->{'limitInBytes'})) { + $limitInBytes = (int)($input->{'limitInBytes'}); + } + $notificationThresholdUsedAsLimit = null; + if (isset($input->{'notificationThresholdUsedAsLimit'})) { + $notificationThresholdUsedAsLimit = (bool)($input->{'notificationThresholdUsedAsLimit'}); + } + $totalExceedanceInBytes = null; + if (isset($input->{'totalExceedanceInBytes'})) { + $totalExceedanceInBytes = (int)($input->{'totalExceedanceInBytes'}); + } + $totalExceedanceInBytesSetAt = null; + if (isset($input->{'totalExceedanceInBytesSetAt'})) { + $totalExceedanceInBytesSetAt = new DateTime($input->{'totalExceedanceInBytesSetAt'}); + } + $totalFreeInBytes = null; + if (isset($input->{'totalFreeInBytes'})) { + $totalFreeInBytes = (int)($input->{'totalFreeInBytes'}); + } + $totalFreeInPercentage = null; + if (isset($input->{'totalFreeInPercentage'})) { + $totalFreeInPercentage = str_contains((string)($input->{'totalFreeInPercentage'}), '.') ? (float)($input->{'totalFreeInPercentage'}) : (int)($input->{'totalFreeInPercentage'}); + } + $totalUsageInBytes = (int)($input->{'totalUsageInBytes'}); + $totalUsageInPercentage = null; + if (isset($input->{'totalUsageInPercentage'})) { + $totalUsageInPercentage = str_contains((string)($input->{'totalUsageInPercentage'}), '.') ? (float)($input->{'totalUsageInPercentage'}) : (int)($input->{'totalUsageInPercentage'}); + } + + $obj = new self($totalUsageInBytes); + $obj->isExceeding = $isExceeding; + $obj->limitInBytes = $limitInBytes; + $obj->notificationThresholdUsedAsLimit = $notificationThresholdUsedAsLimit; + $obj->totalExceedanceInBytes = $totalExceedanceInBytes; + $obj->totalExceedanceInBytesSetAt = $totalExceedanceInBytesSetAt; + $obj->totalFreeInBytes = $totalFreeInBytes; + $obj->totalFreeInPercentage = $totalFreeInPercentage; + $obj->totalUsageInPercentage = $totalUsageInPercentage; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->isExceeding)) { + $output['isExceeding'] = $this->isExceeding; + } + if (isset($this->limitInBytes)) { + $output['limitInBytes'] = $this->limitInBytes; + } + if (isset($this->notificationThresholdUsedAsLimit)) { + $output['notificationThresholdUsedAsLimit'] = $this->notificationThresholdUsedAsLimit; + } + if (isset($this->totalExceedanceInBytes)) { + $output['totalExceedanceInBytes'] = $this->totalExceedanceInBytes; + } + if (isset($this->totalExceedanceInBytesSetAt)) { + $output['totalExceedanceInBytesSetAt'] = ($this->totalExceedanceInBytesSetAt)->format(DateTime::ATOM); + } + if (isset($this->totalFreeInBytes)) { + $output['totalFreeInBytes'] = $this->totalFreeInBytes; + } + if (isset($this->totalFreeInPercentage)) { + $output['totalFreeInPercentage'] = $this->totalFreeInPercentage; + } + $output['totalUsageInBytes'] = $this->totalUsageInBytes; + if (isset($this->totalUsageInPercentage)) { + $output['totalUsageInPercentage'] = $this->totalUsageInPercentage; + } + + 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() + { + if (isset($this->totalExceedanceInBytesSetAt)) { + $this->totalExceedanceInBytesSetAt = clone $this->totalExceedanceInBytesSetAt; + } + } +} diff --git a/src/Generated/V2/Schemas/Storagespace/StatisticsResource.php b/src/Generated/V2/Schemas/Storagespace/StatisticsResource.php new file mode 100644 index 00000000..ce6d93c4 --- /dev/null +++ b/src/Generated/V2/Schemas/Storagespace/StatisticsResource.php @@ -0,0 +1,250 @@ + [ + 'description' => [ + 'example' => 'MySQL DB for Wordpress', + 'type' => 'string', + ], + 'id' => [ + 'example' => '169cea81-2c11-46a4-8f0b-5b0b47caeb78', + 'type' => 'string', + ], + 'name' => [ + 'example' => 'mysql-xyz', + 'type' => 'string', + ], + 'usageInBytes' => [ + 'example' => 1000, + 'type' => 'integer', + ], + 'usageInBytesSetAt' => [ + 'example' => '2023-12-22T13:46:52.000Z', + 'format' => 'date-time', + 'type' => 'string', + ], + ], + 'required' => [ + 'id', + 'name', + 'usageInBytes', + 'usageInBytesSetAt', + ], + 'type' => 'object', + ]; + + private ?string $description = null; + + private string $id; + + private string $name; + + private int $usageInBytes; + + private DateTime $usageInBytesSetAt; + + public function __construct(string $id, string $name, int $usageInBytes, DateTime $usageInBytesSetAt) + { + $this->id = $id; + $this->name = $name; + $this->usageInBytes = $usageInBytes; + $this->usageInBytesSetAt = $usageInBytesSetAt; + } + + public function getDescription(): ?string + { + return $this->description ?? null; + } + + public function getId(): string + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function getUsageInBytes(): int + { + return $this->usageInBytes; + } + + public function getUsageInBytesSetAt(): DateTime + { + return $this->usageInBytesSetAt; + } + + public function withDescription(string $description): self + { + $validator = new Validator(); + $validator->validate($description, static::$schema['properties']['description']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->description = $description; + + return $clone; + } + + public function withoutDescription(): self + { + $clone = clone $this; + unset($clone->description); + + return $clone; + } + + public function withId(string $id): self + { + $validator = new Validator(); + $validator->validate($id, static::$schema['properties']['id']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->id = $id; + + return $clone; + } + + public function withName(string $name): self + { + $validator = new Validator(); + $validator->validate($name, static::$schema['properties']['name']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->name = $name; + + return $clone; + } + + public function withUsageInBytes(int $usageInBytes): self + { + $validator = new Validator(); + $validator->validate($usageInBytes, static::$schema['properties']['usageInBytes']); + if (!$validator->isValid()) { + throw new InvalidArgumentException($validator->getErrors()[0]['message']); + } + + $clone = clone $this; + $clone->usageInBytes = $usageInBytes; + + return $clone; + } + + public function withUsageInBytesSetAt(DateTime $usageInBytesSetAt): self + { + $clone = clone $this; + $clone->usageInBytesSetAt = $usageInBytesSetAt; + + 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 StatisticsResource Created instance + * @throws InvalidArgumentException + */ + public static function buildFromInput(array|object $input, bool $validate = true): StatisticsResource + { + $input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; + if ($validate) { + static::validateInput($input); + } + + $description = null; + if (isset($input->{'description'})) { + $description = $input->{'description'}; + } + $id = $input->{'id'}; + $name = $input->{'name'}; + $usageInBytes = (int)($input->{'usageInBytes'}); + $usageInBytesSetAt = new DateTime($input->{'usageInBytesSetAt'}); + + $obj = new self($id, $name, $usageInBytes, $usageInBytesSetAt); + $obj->description = $description; + return $obj; + } + + /** + * Converts this object back to a simple array that can be JSON-serialized + * + * @return array Converted array + */ + public function toJson(): array + { + $output = []; + if (isset($this->description)) { + $output['description'] = $this->description; + } + $output['id'] = $this->id; + $output['name'] = $this->name; + $output['usageInBytes'] = $this->usageInBytes; + $output['usageInBytesSetAt'] = ($this->usageInBytesSetAt)->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->usageInBytesSetAt = clone $this->usageInBytesSetAt; + } +}