mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Merge pull request #1286 from lohanidamodar/feat-sb-collection
feat-sb-collection
This commit is contained in:
commit
c0ebe052f0
4 changed files with 199 additions and 2 deletions
|
|
@ -1436,6 +1436,97 @@ $collections = [
|
|||
],
|
||||
],
|
||||
],
|
||||
Database::SYSTEM_COLLECTION_BUCKETS => [
|
||||
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
|
||||
'$id' => Database::SYSTEM_COLLECTION_BUCKETS,
|
||||
'$permissions' => ['read' => ['*']],
|
||||
'name' => 'File',
|
||||
'structure' => true,
|
||||
'rules' => [
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Date Created',
|
||||
'key' => 'dateCreated',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_NUMERIC,
|
||||
'default' => 0,
|
||||
'required' => false,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Enabled',
|
||||
'key' => 'enabled',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN,
|
||||
'default' => true,
|
||||
'required' => false,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Name',
|
||||
'key' => 'name',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Adapter',
|
||||
'key' => 'adapter',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Adapter Crednetials',
|
||||
'key' => 'adapterCredentials',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
'array' => false,
|
||||
'filter' => ['json']
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Maximum File Size',
|
||||
'key' => 'maximumFileSize',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_NUMERIC,
|
||||
'default' => 0,
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Allowed File Extensions',
|
||||
'key' => 'allowedFileExtensions',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Encryption',
|
||||
'key' => 'encryption',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN,
|
||||
'default' => true,
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'Virus Scan',
|
||||
'key' => 'antiVirus',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_BOOLEAN,
|
||||
'default' => true,
|
||||
'required' => true,
|
||||
'array' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
Database::SYSTEM_COLLECTION_FUNCTIONS => [
|
||||
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
|
||||
'$id' => Database::SYSTEM_COLLECTION_FUNCTIONS,
|
||||
|
|
@ -1748,4 +1839,4 @@ foreach ($auth as $index => $method) {
|
|||
];
|
||||
}
|
||||
|
||||
return $collections;
|
||||
return $collections;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class Database
|
|||
|
||||
// Storage
|
||||
const SYSTEM_COLLECTION_FILES = 'files';
|
||||
const SYSTEM_COLLECTION_BUCKETS = 'buckets';
|
||||
|
||||
// Functions
|
||||
const SYSTEM_COLLECTION_FUNCTIONS = 'functions';
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class Response extends SwooleResponse
|
|||
// Storage
|
||||
const MODEL_FILE = 'file';
|
||||
const MODEL_FILE_LIST = 'fileList';
|
||||
const MODEL_BUCKET = 'bucket'; // - Missing
|
||||
const MODEL_BUCKET = 'bucket';
|
||||
const MODEL_BUCKET_LIST = 'bucketList';
|
||||
|
||||
// Locale
|
||||
const MODEL_LOCALE = 'locale';
|
||||
|
|
@ -154,6 +155,7 @@ class Response extends SwooleResponse
|
|||
->setModel(new BaseList('Sessions List', self::MODEL_SESSION_LIST, 'sessions', self::MODEL_SESSION))
|
||||
->setModel(new BaseList('Logs List', self::MODEL_LOG_LIST, 'logs', self::MODEL_LOG, false))
|
||||
->setModel(new BaseList('Files List', self::MODEL_FILE_LIST, 'files', self::MODEL_FILE))
|
||||
->setModel(new BaseList('Buckets List', self::MODEL_BUCKET_LIST, 'buckets', self::MODEL_BUCKET))
|
||||
->setModel(new BaseList('Teams List', self::MODEL_TEAM_LIST, 'teams', self::MODEL_TEAM))
|
||||
->setModel(new BaseList('Memberships List', self::MODEL_MEMBERSHIP_LIST, 'memberships', self::MODEL_MEMBERSHIP))
|
||||
->setModel(new BaseList('Functions List', self::MODEL_FUNCTION_LIST, 'functions', self::MODEL_FUNCTION))
|
||||
|
|
|
|||
103
src/Appwrite/Utopia/Response/Model/Bucket.php
Normal file
103
src/Appwrite/Utopia/Response/Model/Bucket.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Bucket extends Model
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('$id', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Bucket ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$permissions', [
|
||||
'type' => Response::MODEL_PERMISSIONS,
|
||||
'description' => 'File permissions.',
|
||||
'default' => new \stdClass,
|
||||
'example' => new \stdClass,
|
||||
'array' => false,
|
||||
])
|
||||
->addRule('dateCreated', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'File creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Bucket name.',
|
||||
'default' => '',
|
||||
'example' => 'Documents',
|
||||
])
|
||||
->addRule('enabled', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Bucket enabled.',
|
||||
'default' => true,
|
||||
'example' => false,
|
||||
])
|
||||
->addRule('adapter', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Storage adapter.',
|
||||
'default' => '',
|
||||
'example' => 'local',
|
||||
])
|
||||
->addRule('adapterCredentials', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Storage adapter credentials.',
|
||||
'default' => '',
|
||||
'example' => ['key' => 'value'],
|
||||
])
|
||||
->addRule('maximumFileSize', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Maximum file size supported.',
|
||||
'default' => 0,
|
||||
'example' => 100,
|
||||
])
|
||||
->addRule('allowedFileExtensions', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Allowed file extensions.',
|
||||
'default' => '',
|
||||
'example' => 'jpg,png',
|
||||
])
|
||||
->addRule('encryption', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Bucket is encrypted.',
|
||||
'default' => true,
|
||||
'example' => false,
|
||||
])
|
||||
->addRule('antiVirus', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Virus scanning is enabled.',
|
||||
'default' => true,
|
||||
'example' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Bucket';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_BUCKET;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue