mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
update: use abstract for getResponseModel.
This commit is contained in:
parent
cb64484c44
commit
96b89693fc
55 changed files with 287 additions and 323 deletions
|
|
@ -30,9 +30,9 @@ abstract class Action extends UtopiaAction
|
|||
private ?string $context = DATABASE_ATTRIBUTES_CONTEXT;
|
||||
|
||||
/**
|
||||
* @var string|array|null The current response model for the attribute/column type.
|
||||
* Get the correct response model.
|
||||
*/
|
||||
private string|array|null $responseModel = null;
|
||||
abstract protected function getResponseModel(): string|array;
|
||||
|
||||
/**
|
||||
* Set the context to either `column` or `attribute`.
|
||||
|
|
@ -92,26 +92,6 @@ abstract class Action extends UtopiaAction
|
|||
return $this->getContext() . 'Id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the correct response model.
|
||||
*/
|
||||
final protected function setResponseModel(string|array $model): void
|
||||
{
|
||||
$this->responseModel = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct response model.
|
||||
*/
|
||||
final protected function getResponseModel(): string|array
|
||||
{
|
||||
if ($this->responseModel === null) {
|
||||
throw new \LogicException("Missing response model: you must call setResponseModel() before using it.");
|
||||
}
|
||||
|
||||
return $this->responseModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate parent level not found exception.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,10 +26,13 @@ class Create extends Action
|
|||
return 'createBooleanColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean')
|
||||
|
|
@ -66,19 +69,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?bool $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->createAttribute($databaseId, $collectionId, new Document([
|
||||
'key' => $key,
|
||||
'type' => Database::VAR_BOOLEAN,
|
||||
|
|
|
|||
|
|
@ -26,10 +26,13 @@ class Update extends Action
|
|||
return 'updateBooleanColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/boolean/:key')
|
||||
|
|
@ -66,17 +69,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?bool $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Create extends Action
|
|||
return 'createDatetimeAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_DATETIME;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_DATETIME);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime')
|
||||
|
|
@ -67,18 +70,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->createAttribute(
|
||||
$databaseId,
|
||||
$collectionId,
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateDatetimeAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_DATETIME;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_DATETIME);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/datetime/:key')
|
||||
|
|
@ -67,17 +70,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -27,11 +27,14 @@ class Delete extends Action
|
|||
return 'deleteAttribute';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
// we should correctly & carefully set the context later.
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_NONE);
|
||||
return UtopiaResponse::MODEL_NONE;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_DELETE)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
|
||||
|
|
@ -44,8 +47,8 @@ class Delete extends Action
|
|||
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
group: 'attributes',
|
||||
name: 'deleteAttribute',
|
||||
group: $this->getSdkGroup(),
|
||||
name: self::getName(),
|
||||
description: '/docs/references/databases/delete-attribute.md',
|
||||
auth: [AuthType::KEY],
|
||||
responses: [
|
||||
|
|
@ -66,15 +69,8 @@ class Delete extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($db->isEmpty()) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Create extends Action
|
|||
return 'createEmailAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_EMAIL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_EMAIL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/email')
|
||||
|
|
@ -67,18 +70,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->createAttribute(
|
||||
$databaseId,
|
||||
$collectionId,
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateEmailAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_EMAIL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_EMAIL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/email/:key')
|
||||
|
|
@ -67,17 +70,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ class Create extends Action
|
|||
return 'createEnumAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_ENUM;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_ENUM);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/enum')
|
||||
|
|
@ -70,19 +73,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
array $elements,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, array $elements, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
if (!is_null($default) && !\in_array($default, $elements, true)) {
|
||||
throw new Exception($this->getInvalidValueException(), 'Default value not found in elements');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@ class Update extends Action
|
|||
return 'updateEnumAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_ENUM;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_ENUM);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/enum/:key')
|
||||
|
|
@ -69,18 +72,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?array $elements,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?array $elements, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ class Create extends Action
|
|||
return 'createFloatAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_FLOAT;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_FLOAT);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/float')
|
||||
|
|
@ -71,20 +74,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?float $min,
|
||||
?float $max,
|
||||
?float $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$min ??= -PHP_FLOAT_MAX;
|
||||
$max ??= PHP_FLOAT_MAX;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateFloatAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_FLOAT;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_FLOAT);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/float/:key')
|
||||
|
|
@ -69,19 +72,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?float $min,
|
||||
?float $max,
|
||||
?float $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ class Get extends Action
|
|||
return 'getColumn';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
$this->setResponseModel([
|
||||
return [
|
||||
UtopiaResponse::MODEL_ATTRIBUTE_BOOLEAN,
|
||||
UtopiaResponse::MODEL_ATTRIBUTE_INTEGER,
|
||||
UtopiaResponse::MODEL_ATTRIBUTE_FLOAT,
|
||||
|
|
@ -36,8 +36,11 @@ class Get extends Action
|
|||
UtopiaResponse::MODEL_ATTRIBUTE_DATETIME,
|
||||
UtopiaResponse::MODEL_ATTRIBUTE_RELATIONSHIP,
|
||||
UtopiaResponse::MODEL_ATTRIBUTE_STRING,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/:key')
|
||||
|
|
@ -47,8 +50,8 @@ class Get extends Action
|
|||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
group: 'columns',
|
||||
name: 'getColumn',
|
||||
group: $this->getSdkGroup(),
|
||||
name: self::getName(),
|
||||
description: '/docs/references/databases/get-attribute.md',
|
||||
auth: [AuthType::KEY],
|
||||
responses: [
|
||||
|
|
@ -66,13 +69,8 @@ class Get extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $tableId,
|
||||
string $key,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject
|
||||
): void {
|
||||
public function action(string $databaseId, string $tableId, string $key, UtopiaResponse $response, Database $dbForProject): void
|
||||
{
|
||||
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
|
||||
if ($database->isEmpty()) {
|
||||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Create extends Action
|
|||
return 'createIpAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_IP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_IP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/ip')
|
||||
|
|
@ -67,18 +70,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->createAttribute(
|
||||
$databaseId,
|
||||
$collectionId,
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateIpAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_IP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_IP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/ip/:key')
|
||||
|
|
@ -67,17 +70,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?string $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ class Create extends Action
|
|||
return 'createIntegerAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_INTEGER;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_INTEGER);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/integer')
|
||||
|
|
@ -71,20 +74,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?int $min,
|
||||
?int $max,
|
||||
?int $default,
|
||||
bool $array,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$min ??= \PHP_INT_MIN;
|
||||
$max ??= \PHP_INT_MAX;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateIntegerAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_INTEGER;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_INTEGER);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/integer/:key')
|
||||
|
|
@ -69,19 +72,8 @@ class Update extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $key,
|
||||
?bool $required,
|
||||
?int $min,
|
||||
?int $max,
|
||||
?int $default,
|
||||
?string $newKey,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void
|
||||
{
|
||||
$attribute = $this->updateAttribute(
|
||||
databaseId: $databaseId,
|
||||
collectionId: $collectionId,
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ class Create extends Action
|
|||
return 'createRelationshipAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_RELATIONSHIP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_RELATIONSHIP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/relationship')
|
||||
|
|
@ -80,20 +83,8 @@ class Create extends Action
|
|||
->callback([$this, 'action']);
|
||||
}
|
||||
|
||||
public function action(
|
||||
string $databaseId,
|
||||
string $collectionId,
|
||||
string $relatedCollectionId,
|
||||
string $type,
|
||||
bool $twoWay,
|
||||
?string $key,
|
||||
?string $twoWayKey,
|
||||
string $onDelete,
|
||||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
): void {
|
||||
public function action(string $databaseId, string $collectionId, string $relatedCollectionId, string $type, bool $twoWay, ?string $key, ?string $twoWayKey, string $onDelete, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
|
||||
{
|
||||
$key ??= $relatedCollectionId;
|
||||
$twoWayKey ??= $collectionId;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,13 @@ class Update extends Action
|
|||
return 'updateRelationshipAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_RELATIONSHIP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_RELATIONSHIP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/:key/relationship')
|
||||
|
|
|
|||
|
|
@ -30,10 +30,13 @@ class Create extends Action
|
|||
return 'createStringAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_STRING;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_STRING);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/string')
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ class Update extends Action
|
|||
return 'updateStringAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_STRING;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_STRING);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/string/:key')
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Create extends Action
|
|||
return 'createUrlAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_URL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_URL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/url')
|
||||
|
|
|
|||
|
|
@ -27,10 +27,13 @@ class Update extends Action
|
|||
return 'updateUrlAttribute';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_URL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_URL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/url/:key')
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@ class XList extends Action
|
|||
return 'listAttributes';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_ATTRIBUTE_LIST;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_ATTRIBUTE_LIST);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes')
|
||||
|
|
@ -67,8 +70,8 @@ class XList extends Action
|
|||
throw new Exception(Exception::DATABASE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$table = $dbForProject->getDocument('database_' . $database->getInternalId(), $tableId);
|
||||
if ($table->isEmpty()) {
|
||||
$collection = $dbForProject->getDocument('database_' . $database->getInternalId(), $tableId);
|
||||
if ($collection->isEmpty()) {
|
||||
throw new Exception($this->getParentNotFoundException());
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +80,7 @@ class XList extends Action
|
|||
\array_push(
|
||||
$queries,
|
||||
Query::equal('databaseInternalId', [$database->getInternalId()]),
|
||||
Query::equal('collectionInternalId', [$table->getInternalId()])
|
||||
Query::equal('collectionInternalId', [$collection->getInternalId()])
|
||||
);
|
||||
|
||||
$cursor = \array_filter(
|
||||
|
|
@ -96,7 +99,7 @@ class XList extends Action
|
|||
$cursorDocument = Authorization::skip(
|
||||
fn () => $dbForProject->find('attributes', [
|
||||
Query::equal('databaseInternalId', [$database->getInternalId()]),
|
||||
Query::equal('collectionInternalId', [$table->getInternalId()]),
|
||||
Query::equal('collectionInternalId', [$collection->getInternalId()]),
|
||||
Query::equal('key', [$attributeId]),
|
||||
Query::limit(1),
|
||||
])
|
||||
|
|
@ -104,7 +107,7 @@ class XList extends Action
|
|||
|
||||
if (empty($cursorDocument) || $cursorDocument[0]->isEmpty()) {
|
||||
$type = ucfirst($this->getContext());
|
||||
throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "$type '{$attributeId}' for the 'cursor' value not found.");
|
||||
throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "$type '$attributeId' for the 'cursor' value not found.");
|
||||
}
|
||||
|
||||
$cursor->setValue($cursorDocument[0]);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ abstract class Action extends UtopiaAction
|
|||
*/
|
||||
private ?string $context = DATABASE_COLLECTIONS_CONTEXT;
|
||||
|
||||
/**
|
||||
* Get the response model used in the SDK and HTTP responses.
|
||||
*/
|
||||
abstract protected function getResponseModel(): string;
|
||||
|
||||
/**
|
||||
* Set the current API context.
|
||||
*
|
||||
|
|
@ -50,11 +55,6 @@ abstract class Action extends UtopiaAction
|
|||
return $this->getContext() . 'Id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response model used in the SDK and HTTP responses.
|
||||
*/
|
||||
abstract protected function getResponseModel(): string;
|
||||
|
||||
/**
|
||||
* Determine if the current action is for the Collections API.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -25,10 +25,14 @@ class Create extends BooleanCreate
|
|||
return 'createBooleanColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_BOOLEAN;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_BOOLEAN);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Update extends BooleanUpdate
|
|||
return 'updateBooleanColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_BOOLEAN;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_BOOLEAN);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends DatetimeCreate
|
|||
return 'createDatetimeColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_DATETIME;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_DATETIME);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Update extends DatetimeUpdate
|
|||
return 'updateDatetimeColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_DATETIME;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_DATETIME);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -25,13 +25,16 @@ class Delete extends AttributesDelete
|
|||
return 'deleteColumn';
|
||||
}
|
||||
|
||||
// parent handles multiple model types internally
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_NONE;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
|
||||
// parent action handles multiple model types internally
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_NONE);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_DELETE)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/columns/:key')
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends EmailCreate
|
|||
return 'createEmailColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_EMAIL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_EMAIL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Update extends EmailUpdate
|
|||
return 'updateEmailColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_EMAIL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_EMAIL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Create extends EnumCreate
|
|||
return 'createEnumColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_ENUM;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_ENUM);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -28,10 +28,14 @@ class Update extends EnumUpdate
|
|||
return 'updateEnumColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_ENUM;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_ENUM);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends FloatCreate
|
|||
return 'createFloatColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_FLOAT;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_FLOAT);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Update extends FloatUpdate
|
|||
return 'updateFloatColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_FLOAT;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_FLOAT);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,9 @@ class Get extends AttributesGet
|
|||
return 'getColumn';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
|
||||
$this->setResponseModel([
|
||||
return [
|
||||
UtopiaResponse::MODEL_COLUMN_BOOLEAN,
|
||||
UtopiaResponse::MODEL_COLUMN_INTEGER,
|
||||
UtopiaResponse::MODEL_COLUMN_FLOAT,
|
||||
|
|
@ -37,7 +35,12 @@ class Get extends AttributesGet
|
|||
UtopiaResponse::MODEL_COLUMN_DATETIME,
|
||||
UtopiaResponse::MODEL_COLUMN_RELATIONSHIP,
|
||||
UtopiaResponse::MODEL_COLUMN_STRING,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends IPCreate
|
|||
return 'createIpColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_IP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_IP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Update extends IPUpdate
|
|||
return 'updateIpColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_IP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_IP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends IntegerCreate
|
|||
return 'createIntegerColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_INTEGER;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_INTEGER);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ class Update extends IntegerUpdate
|
|||
return 'updateIntegerColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_INTEGER;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_INTEGER);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends RelationshipCreate
|
|||
return 'createRelationshipColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_RELATIONSHIP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_RELATIONSHIP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -25,15 +25,18 @@ class Update extends RelationshipUpdate
|
|||
return 'updateRelationshipColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_RELATIONSHIP;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_RELATIONSHIP);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/columns/:key/relationship')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/attributes/:key/relationship')
|
||||
->desc('Update relationship column')
|
||||
->groups(['api', 'database', 'schema'])
|
||||
->label('scope', 'collections.write')
|
||||
|
|
|
|||
|
|
@ -28,10 +28,14 @@ class Create extends StringCreate
|
|||
return 'createStringColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_STRING;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_STRING);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -29,10 +29,14 @@ class Update extends StringUpdate
|
|||
return 'updateStringColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_STRING;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_STRING);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,14 @@ class Create extends URLCreate
|
|||
return 'createUrlColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_URL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_URL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
|
|
|
|||
|
|
@ -27,15 +27,18 @@ class Update extends URLUpdate
|
|||
return 'updateUrlColumn';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_URL;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_URL);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/columns/url/:key')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/attributes/url/:key')
|
||||
->desc('Update URL column')
|
||||
->groups(['api', 'database', 'schema'])
|
||||
->label('scope', 'collections.write')
|
||||
|
|
|
|||
|
|
@ -22,10 +22,14 @@ class XList extends AttributesXList
|
|||
return 'listColumns';
|
||||
}
|
||||
|
||||
protected function getResponseModel(): string|array
|
||||
{
|
||||
return UtopiaResponse::MODEL_COLUMN_LIST;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setContext(DATABASE_COLUMNS_CONTEXT);
|
||||
$this->setResponseModel(UtopiaResponse::MODEL_COLUMN_LIST);
|
||||
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ class Create extends Action
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_POST)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/indexes')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/indexes')
|
||||
->desc('Create index')
|
||||
->groups(['api', 'database'])
|
||||
->label('event', 'databases.[databaseId].tables.[tableId].indexes.[indexId].create')
|
||||
->label('scope', 'collections.write')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('audits.event', 'index.create')
|
||||
// TODO: audits table or collections, check the context type if possible, move into another module.
|
||||
->label('audits.resource', 'database/{request.databaseId}/table/{request.tableId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ class Delete extends Action
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_DELETE)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/indexes/:key')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/indexes/:key')
|
||||
->desc('Delete index')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.write')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('event', 'databases.[databaseId].tables.[tableId].indexes.[indexId].update')
|
||||
->label('audits.event', 'index.delete')
|
||||
// TODO: audits table or collections, check the context type if possible
|
||||
->label('audits.resource', 'database/{request.databaseId}/table/{request.tableId}')
|
||||
->label('sdk', new Method(
|
||||
namespace: 'databases',
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Get extends Action
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/indexes/:key')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/indexes/:key')
|
||||
->desc('Get index')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class XList extends Action
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/indexes')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/indexes')
|
||||
->desc('List indexes')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'collections.read')
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ class Get extends DocumentGet
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/rows/:rowId')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/documents/:rowId')
|
||||
->desc('Get row')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'documents.read')
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class Update extends DocumentUpdate
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_PATCH)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/rows/:rowId')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/documents/:rowId')
|
||||
->desc('Update row')
|
||||
->groups(['api', 'database'])
|
||||
->label('event', 'databases.[databaseId].tables.[tableId].rows.[rowId].update')
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ class XList extends DocumentXList
|
|||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/databases/:databaseId/tables/:tableId/rows')
|
||||
->httpAlias('/v1/databases/:databaseId/collections/:tableId/documents')
|
||||
->desc('List rows')
|
||||
->groups(['api', 'database'])
|
||||
->label('scope', 'documents.read')
|
||||
|
|
|
|||
Loading…
Reference in a new issue