2020-10-29 13:07:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
class Collection extends Model
|
|
|
|
|
{
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this
|
|
|
|
|
->addRule('$id', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'Collection ID.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2021-06-30 15:10:45 +00:00
|
|
|
'example' => '5e5ea5c16897e',
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
2021-06-10 18:19:10 +00:00
|
|
|
->addRule('$read', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Collection read permissions.',
|
|
|
|
|
'default' => '',
|
2021-06-30 15:10:45 +00:00
|
|
|
'example' => 'role:all',
|
2021-06-10 18:19:10 +00:00
|
|
|
'array' => true
|
|
|
|
|
])
|
|
|
|
|
->addRule('$write', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Collection write permissions.',
|
|
|
|
|
'default' => '',
|
2021-06-30 15:10:45 +00:00
|
|
|
'example' => 'user:608f9da25e7e1',
|
2021-06-10 18:19:10 +00:00
|
|
|
'array' => true
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
|
|
|
|
->addRule('name', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'Collection name.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2021-08-21 04:48:28 +00:00
|
|
|
'example' => 'My Collection',
|
|
|
|
|
])
|
|
|
|
|
->addRule('permission', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Collection permission model. Possible values: `document` or `collection`',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'document',
|
2021-06-10 18:19:10 +00:00
|
|
|
])
|
|
|
|
|
->addRule('attributes', [
|
2021-09-14 08:26:16 +00:00
|
|
|
'type' => [
|
|
|
|
|
Response::MODEL_ATTRIBUTE_BOOLEAN,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_INTEGER,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_FLOAT,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_EMAIL,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_URL,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_IP,
|
|
|
|
|
Response::MODEL_ATTRIBUTE_STRING, // needs to be last, since its condition would dominate any other string attribute
|
|
|
|
|
],
|
2021-06-10 18:19:10 +00:00
|
|
|
'description' => 'Collection attributes.',
|
2021-06-11 15:27:51 +00:00
|
|
|
'default' => [],
|
2021-10-05 15:39:39 +00:00
|
|
|
'example' => new \stdClass,
|
2021-08-27 23:42:24 +00:00
|
|
|
'array' => true,
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
2021-06-10 18:19:10 +00:00
|
|
|
->addRule('indexes', [
|
2021-06-11 15:27:51 +00:00
|
|
|
'type' => Response::MODEL_INDEX,
|
2021-06-10 18:19:10 +00:00
|
|
|
'description' => 'Collection indexes.',
|
2021-06-11 15:27:51 +00:00
|
|
|
'default' => [],
|
2021-10-05 15:39:39 +00:00
|
|
|
'example' => new \stdClass,
|
2021-06-10 18:19:10 +00:00
|
|
|
'array' => true
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Name
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getName():string
|
|
|
|
|
{
|
|
|
|
|
return 'Collection';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Collection
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getType():string
|
|
|
|
|
{
|
|
|
|
|
return Response::MODEL_COLLECTION;
|
|
|
|
|
}
|
2021-06-30 15:10:45 +00:00
|
|
|
}
|