Updated response models
This commit is contained in:
parent
dd19846611
commit
7ebc6a5de9
|
@ -43,7 +43,7 @@ App::post('/v1/functions')
|
|||
],
|
||||
'dateCreated' => time(),
|
||||
'dateUpdated' => time(),
|
||||
'status' => 'paused',
|
||||
'status' => 'disabled',
|
||||
'name' => $name,
|
||||
'env' => $env,
|
||||
'tag' => '',
|
||||
|
|
|
@ -9,6 +9,7 @@ use Appwrite\Utopia\Response\Model\Error;
|
|||
use Appwrite\Utopia\Response\Model\ErrorDev;
|
||||
use Appwrite\Utopia\Response\Model\File;
|
||||
use Appwrite\Utopia\Response\Model\FileList;
|
||||
use Appwrite\Utopia\Response\Model\Functionx;
|
||||
use Appwrite\Utopia\Response\Model\User;
|
||||
use Appwrite\Utopia\Response\Model\Session;
|
||||
use Appwrite\Utopia\Response\Model\Team;
|
||||
|
@ -54,6 +55,14 @@ class Response extends UtopiaResponse
|
|||
const MODEL_MEMBERSHIP = 'membership';
|
||||
const MODEL_MEMBERSHIP_LIST = 'membershipList';
|
||||
|
||||
// Functions
|
||||
const MODEL_FUNCTION = 'function';
|
||||
const MODEL_FUNCTION_LIST = 'functionList';
|
||||
const MODEL_TAG = 'tag';
|
||||
const MODEL_TAG_LIST = 'tagList';
|
||||
const MODEL_EXECUTION = 'execution';
|
||||
const MODEL_EXECUTION_LIST = 'executionList';
|
||||
|
||||
/**
|
||||
* Response constructor.
|
||||
*/
|
||||
|
@ -71,6 +80,7 @@ class Response extends UtopiaResponse
|
|||
->setModel(new TeamList())
|
||||
->setModel(new Membership())
|
||||
->setModel(new MembershipList())
|
||||
->setModel(new Functionx())
|
||||
;
|
||||
|
||||
parent::__construct($time);
|
||||
|
|
41
src/Appwrite/Utopia/Response/Model/ExecutionList.php
Normal file
41
src/Appwrite/Utopia/Response/Model/ExecutionList.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class ExecutionList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->addRule('executions', [
|
||||
'type' => Response::MODEL_EXECUTION,
|
||||
'description' => 'List of function execitions.',
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Executions List';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_EXECUTION_LIST;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ class File extends Model
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
//return $value->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']);
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => 'string',
|
||||
|
@ -19,13 +18,12 @@ class File extends Model
|
|||
->addRule('$permissions', [
|
||||
'type' => Response::MODEL_PERMISSIONS,
|
||||
'description' => 'File permissions.',
|
||||
'example' => [],
|
||||
'example' => new \stdClass,
|
||||
'array' => false,
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => 'string',
|
||||
'description' => 'File name.',
|
||||
'default' => '',
|
||||
'example' => 'Pink.png',
|
||||
])
|
||||
->addRule('dateCreated', [
|
||||
|
@ -36,20 +34,17 @@ class File extends Model
|
|||
->addRule('signature', [
|
||||
'type' => 'string',
|
||||
'description' => 'File MD5 signature.',
|
||||
'default' => false,
|
||||
'example' => '5d529fd02b544198ae075bd57c1762bb',
|
||||
])
|
||||
->addRule('mimeType', [
|
||||
'type' => 'string',
|
||||
'description' => 'File mime type.',
|
||||
'default' => '',
|
||||
'example' => 'image/png',
|
||||
])
|
||||
->addRule('sizeOriginal', [
|
||||
'type' => 'integer',
|
||||
'description' => 'File original size in bytes.',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
'example' => 17890,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class FileList extends BaseList
|
|||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'File List';
|
||||
return 'Files List';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
106
src/Appwrite/Utopia/Response/Model/Functionx.php
Normal file
106
src/Appwrite/Utopia/Response/Model/Functionx.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Functionx extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function ID.',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function name.',
|
||||
'example' => 'My Function',
|
||||
])
|
||||
->addRule('dateCreated', [
|
||||
'type' => 'integer',
|
||||
'description' => 'Function creation date in Unix timestamp.',
|
||||
'example' => 1592981250,
|
||||
])
|
||||
->addRule('dateUpdated', [
|
||||
'type' => 'integer',
|
||||
'description' => 'Function update date in Unix timestamp.',
|
||||
'example' => 1592981257,
|
||||
])
|
||||
->addRule('status', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function status. Possible values: disabled, enabled',
|
||||
'example' => 'enabled',
|
||||
])
|
||||
->addRule('env', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function execution environment.',
|
||||
'example' => 'python-3.8',
|
||||
])
|
||||
->addRule('tag', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function active tag ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('vars', [
|
||||
'type' => 'json',
|
||||
'description' => 'Function environment variables.',
|
||||
'default' => new \stdClass,
|
||||
'example' => ['key' => 'value'],
|
||||
])
|
||||
->addRule('events', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function trigger events.',
|
||||
'default' => '',
|
||||
'example' => 'account.create',
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('schedule', [
|
||||
'type' => 'string',
|
||||
'description' => 'Function execution schedult in CRON format.',
|
||||
'default' => '',
|
||||
'example' => '5 4 * * *',
|
||||
])
|
||||
->addRule('next', [
|
||||
'type' => 'integer',
|
||||
'description' => 'Function next scheduled execution date in Unix timestamp.',
|
||||
'example' => 1592981292,
|
||||
])
|
||||
->addRule('previous', [
|
||||
'type' => 'integer',
|
||||
'description' => 'Function next scheduled execution date in Unix timestamp.',
|
||||
'example' => 1592981237,
|
||||
])
|
||||
->addRule('timeout', [
|
||||
'type' => 'integer',
|
||||
'description' => 'Function execution timeout in seconds.',
|
||||
'default' => 15,
|
||||
'example' => 1592981237,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Function';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_FUNCTION;
|
||||
}
|
||||
}
|
41
src/Appwrite/Utopia/Response/Model/FunctionxList.php
Normal file
41
src/Appwrite/Utopia/Response/Model/FunctionxList.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class FunctionxList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->addRule('functions', [
|
||||
'type' => Response::MODEL_MEMBERSHIP,
|
||||
'description' => 'List of functions.',
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Functions List';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_FUNCTION_LIST;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ class MembershipList extends BaseList
|
|||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Membership List';
|
||||
return 'Memberships List';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
41
src/Appwrite/Utopia/Response/Model/TagList.php
Normal file
41
src/Appwrite/Utopia/Response/Model/TagList.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class TagList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->addRule('tags', [
|
||||
'type' => Response::MODEL_TAG,
|
||||
'description' => 'List of tags.',
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Tags List';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_TAG_LIST;
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ class TeamList extends BaseList
|
|||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Team List';
|
||||
return 'Teams List';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,6 @@ class User extends Model
|
|||
->addRule('name', [
|
||||
'type' => 'string',
|
||||
'description' => 'User name.',
|
||||
'default' => '',
|
||||
'example' => 'John Doe',
|
||||
])
|
||||
->addRule('registration', [
|
||||
|
@ -29,13 +28,11 @@ class User extends Model
|
|||
->addRule('status', [
|
||||
'type' => 'integer',
|
||||
'description' => 'User status. 0 for Unavtivated, 1 for active and 2 is blocked.',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('email', [
|
||||
'type' => 'string',
|
||||
'description' => 'User email address.',
|
||||
'default' => '',
|
||||
'example' => 'john@appwrite.io',
|
||||
])
|
||||
->addRule('emailVerification', [
|
||||
|
|
Loading…
Reference in a new issue