Skip to content

Commit

Permalink
feat: update customer endpoints to use plural and add backup storage …
Browse files Browse the repository at this point in the history
…usage attributes

- Updated endpoint paths in CreateCustomerInviteRequest and LeaveCustomerRequest to use '/customers/' instead of '/customer/'.
- Added backup storage usage attributes (`backupStorageUsageInBytes`, `backupStorageUsageInBytesSetAt`) to ListProjectsOKResponse, ListProjectsOKResponseBodyItem, and Project schemas.
- Implemented getter methods and validation for newly added backup storage attributes in respective classes.
  • Loading branch information
mittwald-machine committed Nov 5, 2024
1 parent a6b39ec commit d9338be
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function buildUrl(): string
{
$mapped = $this->toJson();
$customerId = urlencode($mapped['customerId']);
return '/v2/customer/' . $customerId . '/invites';
return '/v2/customers/' . $customerId . '/invites';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function buildUrl(): string
{
$mapped = $this->toJson();
$customerId = urlencode($mapped['customerId']);
return '/v2/customer/' . $customerId . '/actions/leave';
return '/v2/customers/' . $customerId . '/actions/leave';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class ListProjectsOKResponse implements ResponseContainer
'body' => [
'items' => [
'properties' => [
'backupStorageUsageInBytes' => [
'type' => 'integer',
],
'backupStorageUsageInBytesSetAt' => [
'format' => 'date-time',
'type' => 'string',
],
'createdAt' => [
'format' => 'date-time',
'type' => 'string',
Expand Down Expand Up @@ -107,6 +114,8 @@ class ListProjectsOKResponse implements ResponseContainer
'statusSetAt',
'webStorageUsageInBytes',
'webStorageUsageInBytesSetAt',
'backupStorageUsageInBytes',
'backupStorageUsageInBytesSetAt',
],
'type' => 'object',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class ListProjectsOKResponseBodyItem
*/
private static array $schema = [
'properties' => [
'backupStorageUsageInBytes' => [
'type' => 'integer',
],
'backupStorageUsageInBytesSetAt' => [
'format' => 'date-time',
'type' => 'string',
],
'createdAt' => [
'format' => 'date-time',
'type' => 'string',
Expand Down Expand Up @@ -102,10 +109,16 @@ class ListProjectsOKResponseBodyItem
'statusSetAt',
'webStorageUsageInBytes',
'webStorageUsageInBytesSetAt',
'backupStorageUsageInBytes',
'backupStorageUsageInBytesSetAt',
],
'type' => 'object',
];

private int $backupStorageUsageInBytes;

private DateTime $backupStorageUsageInBytesSetAt;

private DateTime $createdAt;

private string $customerId;
Expand Down Expand Up @@ -147,8 +160,10 @@ class ListProjectsOKResponseBodyItem

private DateTime $webStorageUsageInBytesSetAt;

public function __construct(DateTime $createdAt, string $customerId, ListProjectsOKResponseBodyItemCustomerMeta $customerMeta, string $description, bool $enabled, string $id, bool $isReady, DeprecatedProjectReadinessStatus $readiness, string $shortId, ProjectStatus $status, DateTime $statusSetAt, int $webStorageUsageInBytes, DateTime $webStorageUsageInBytesSetAt)
public function __construct(int $backupStorageUsageInBytes, DateTime $backupStorageUsageInBytesSetAt, DateTime $createdAt, string $customerId, ListProjectsOKResponseBodyItemCustomerMeta $customerMeta, string $description, bool $enabled, string $id, bool $isReady, DeprecatedProjectReadinessStatus $readiness, string $shortId, ProjectStatus $status, DateTime $statusSetAt, int $webStorageUsageInBytes, DateTime $webStorageUsageInBytesSetAt)
{
$this->backupStorageUsageInBytes = $backupStorageUsageInBytes;
$this->backupStorageUsageInBytesSetAt = $backupStorageUsageInBytesSetAt;
$this->createdAt = $createdAt;
$this->customerId = $customerId;
$this->customerMeta = $customerMeta;
Expand All @@ -164,6 +179,16 @@ public function __construct(DateTime $createdAt, string $customerId, ListProject
$this->webStorageUsageInBytesSetAt = $webStorageUsageInBytesSetAt;
}

public function getBackupStorageUsageInBytes(): int
{
return $this->backupStorageUsageInBytes;
}

public function getBackupStorageUsageInBytesSetAt(): DateTime
{
return $this->backupStorageUsageInBytesSetAt;
}

public function getCreatedAt(): DateTime
{
return $this->createdAt;
Expand Down Expand Up @@ -261,6 +286,28 @@ public function getWebStorageUsageInBytesSetAt(): DateTime
return $this->webStorageUsageInBytesSetAt;
}

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

$clone = clone $this;
$clone->backupStorageUsageInBytes = $backupStorageUsageInBytes;

return $clone;
}

public function withBackupStorageUsageInBytesSetAt(DateTime $backupStorageUsageInBytesSetAt): self
{
$clone = clone $this;
$clone->backupStorageUsageInBytesSetAt = $backupStorageUsageInBytesSetAt;

return $clone;
}

public function withCreatedAt(DateTime $createdAt): self
{
$clone = clone $this;
Expand Down Expand Up @@ -523,6 +570,8 @@ public static function buildFromInput(array|object $input, bool $validate = true
static::validateInput($input);
}

$backupStorageUsageInBytes = (int)($input->{'backupStorageUsageInBytes'});
$backupStorageUsageInBytesSetAt = new DateTime($input->{'backupStorageUsageInBytesSetAt'});
$createdAt = new DateTime($input->{'createdAt'});
$customerId = $input->{'customerId'};
$customerMeta = ListProjectsOKResponseBodyItemCustomerMeta::buildFromInput($input->{'customerMeta'}, validate: $validate);
Expand Down Expand Up @@ -557,7 +606,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
$webStorageUsageInBytes = (int)($input->{'webStorageUsageInBytes'});
$webStorageUsageInBytesSetAt = new DateTime($input->{'webStorageUsageInBytesSetAt'});

$obj = new self($createdAt, $customerId, $customerMeta, $description, $enabled, $id, $isReady, $readiness, $shortId, $status, $statusSetAt, $webStorageUsageInBytes, $webStorageUsageInBytesSetAt);
$obj = new self($backupStorageUsageInBytes, $backupStorageUsageInBytesSetAt, $createdAt, $customerId, $customerMeta, $description, $enabled, $id, $isReady, $readiness, $shortId, $status, $statusSetAt, $webStorageUsageInBytes, $webStorageUsageInBytesSetAt);
$obj->disableReason = $disableReason;
$obj->disabledAt = $disabledAt;
$obj->imageRefId = $imageRefId;
Expand All @@ -574,6 +623,8 @@ public static function buildFromInput(array|object $input, bool $validate = true
public function toJson(): array
{
$output = [];
$output['backupStorageUsageInBytes'] = $this->backupStorageUsageInBytes;
$output['backupStorageUsageInBytesSetAt'] = ($this->backupStorageUsageInBytesSetAt)->format(DateTime::ATOM);
$output['createdAt'] = ($this->createdAt)->format(DateTime::ATOM);
$output['customerId'] = $this->customerId;
$output['customerMeta'] = ($this->customerMeta)->toJson();
Expand Down Expand Up @@ -632,6 +683,7 @@ public static function validateInput(array|object $input, bool $return = false):

public function __clone()
{
$this->backupStorageUsageInBytesSetAt = clone $this->backupStorageUsageInBytesSetAt;
$this->createdAt = clone $this->createdAt;
$this->customerMeta = clone $this->customerMeta;
if (isset($this->disabledAt)) {
Expand Down
57 changes: 55 additions & 2 deletions src/Generated/V2/Schemas/Project/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class Project
*/
private static array $schema = [
'properties' => [
'backupStorageUsageInBytes' => [
'format' => 'int64',
'type' => 'integer',
],
'backupStorageUsageInBytesSetAt' => [
'format' => 'date-time',
'type' => 'string',
],
'clusterDomain' => [
'example' => 'project.host',
'format' => 'hostname',
Expand Down Expand Up @@ -147,10 +155,16 @@ class Project
'statusSetAt',
'webStorageUsageInBytes',
'webStorageUsageInBytesSetAt',
'backupStorageUsageInBytes',
'backupStorageUsageInBytesSetAt',
],
'type' => 'object',
];

private int $backupStorageUsageInBytes;

private DateTime $backupStorageUsageInBytesSetAt;

private ?string $clusterDomain = null;

/**
Expand Down Expand Up @@ -215,8 +229,10 @@ class Project
/**
* @param string[] $directories
*/
public function __construct(DateTime $createdAt, string $customerId, string $description, array $directories, bool $enabled, string $id, bool $isReady, DeprecatedProjectReadinessStatus $readiness, string $shortId, ProjectStatus $status, DateTime $statusSetAt, int $webStorageUsageInBytes, DateTime $webStorageUsageInBytesSetAt)
public function __construct(int $backupStorageUsageInBytes, DateTime $backupStorageUsageInBytesSetAt, DateTime $createdAt, string $customerId, string $description, array $directories, bool $enabled, string $id, bool $isReady, DeprecatedProjectReadinessStatus $readiness, string $shortId, ProjectStatus $status, DateTime $statusSetAt, int $webStorageUsageInBytes, DateTime $webStorageUsageInBytesSetAt)
{
$this->backupStorageUsageInBytes = $backupStorageUsageInBytes;
$this->backupStorageUsageInBytesSetAt = $backupStorageUsageInBytesSetAt;
$this->createdAt = $createdAt;
$this->customerId = $customerId;
$this->description = $description;
Expand All @@ -232,6 +248,16 @@ public function __construct(DateTime $createdAt, string $customerId, string $des
$this->webStorageUsageInBytesSetAt = $webStorageUsageInBytesSetAt;
}

public function getBackupStorageUsageInBytes(): int
{
return $this->backupStorageUsageInBytes;
}

public function getBackupStorageUsageInBytesSetAt(): DateTime
{
return $this->backupStorageUsageInBytesSetAt;
}

public function getClusterDomain(): ?string
{
return $this->clusterDomain ?? null;
Expand Down Expand Up @@ -361,6 +387,28 @@ public function getWebStorageUsageInBytesSetAt(): DateTime
return $this->webStorageUsageInBytesSetAt;
}

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

$clone = clone $this;
$clone->backupStorageUsageInBytes = $backupStorageUsageInBytes;

return $clone;
}

public function withBackupStorageUsageInBytesSetAt(DateTime $backupStorageUsageInBytesSetAt): self
{
$clone = clone $this;
$clone->backupStorageUsageInBytesSetAt = $backupStorageUsageInBytesSetAt;

return $clone;
}

public function withClusterDomain(string $clusterDomain): self
{
$validator = new Validator();
Expand Down Expand Up @@ -739,6 +787,8 @@ public static function buildFromInput(array|object $input, bool $validate = true
static::validateInput($input);
}

$backupStorageUsageInBytes = (int)($input->{'backupStorageUsageInBytes'});
$backupStorageUsageInBytesSetAt = new DateTime($input->{'backupStorageUsageInBytesSetAt'});
$clusterDomain = null;
if (isset($input->{'clusterDomain'})) {
$clusterDomain = $input->{'clusterDomain'};
Expand Down Expand Up @@ -800,7 +850,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
$webStorageUsageInBytes = (int)($input->{'webStorageUsageInBytes'});
$webStorageUsageInBytesSetAt = new DateTime($input->{'webStorageUsageInBytesSetAt'});

$obj = new self($createdAt, $customerId, $description, $directories, $enabled, $id, $isReady, $readiness, $shortId, $status, $statusSetAt, $webStorageUsageInBytes, $webStorageUsageInBytesSetAt);
$obj = new self($backupStorageUsageInBytes, $backupStorageUsageInBytesSetAt, $createdAt, $customerId, $description, $directories, $enabled, $id, $isReady, $readiness, $shortId, $status, $statusSetAt, $webStorageUsageInBytes, $webStorageUsageInBytesSetAt);
$obj->clusterDomain = $clusterDomain;
$obj->clusterID = $clusterID;
$obj->clusterId = $clusterId;
Expand All @@ -823,6 +873,8 @@ public static function buildFromInput(array|object $input, bool $validate = true
public function toJson(): array
{
$output = [];
$output['backupStorageUsageInBytes'] = $this->backupStorageUsageInBytes;
$output['backupStorageUsageInBytesSetAt'] = ($this->backupStorageUsageInBytesSetAt)->format(DateTime::ATOM);
if (isset($this->clusterDomain)) {
$output['clusterDomain'] = $this->clusterDomain;
}
Expand Down Expand Up @@ -901,6 +953,7 @@ public static function validateInput(array|object $input, bool $return = false):

public function __clone()
{
$this->backupStorageUsageInBytesSetAt = clone $this->backupStorageUsageInBytesSetAt;
$this->createdAt = clone $this->createdAt;
if (isset($this->disabledAt)) {
$this->disabledAt = clone $this->disabledAt;
Expand Down

0 comments on commit d9338be

Please sign in to comment.