diff --git a/app/config/collections.php b/app/config/collections.php index 6789237c9c..3b28dd368d 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -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; \ No newline at end of file +return $collections; diff --git a/src/Appwrite/Database/Database.php b/src/Appwrite/Database/Database.php index d0defdec03..685dc82770 100644 --- a/src/Appwrite/Database/Database.php +++ b/src/Appwrite/Database/Database.php @@ -36,6 +36,7 @@ class Database // Storage const SYSTEM_COLLECTION_FILES = 'files'; + const SYSTEM_COLLECTION_BUCKETS = 'buckets'; // Functions const SYSTEM_COLLECTION_FUNCTIONS = 'functions'; diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index a6ec6891cc..e0b96834e3 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -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)) diff --git a/src/Appwrite/Utopia/Response/Model/Bucket.php b/src/Appwrite/Utopia/Response/Model/Bucket.php new file mode 100644 index 0000000000..e64d4d3b9a --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Bucket.php @@ -0,0 +1,103 @@ +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; + } +}