2020-10-29 13:07:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
2022-01-18 15:12:26 +00:00
|
|
|
use stdClass;
|
|
|
|
|
use Utopia\Database\Document;
|
2020-10-29 13:07:56 +00:00
|
|
|
|
|
|
|
|
class Func 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' => 'Function ID.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
|
])
|
2022-06-15 12:46:52 +00:00
|
|
|
->addRule('$createdAt', [
|
2022-07-04 09:55:11 +00:00
|
|
|
'type' => self::TYPE_DATETIME,
|
2022-09-04 21:26:16 +00:00
|
|
|
'description' => 'Function creation date in ISO 8601 format.',
|
2022-07-04 09:55:11 +00:00
|
|
|
'default' => '',
|
2022-08-14 10:27:07 +00:00
|
|
|
'example' => self::TYPE_DATETIME_EXAMPLE,
|
2022-06-15 12:46:52 +00:00
|
|
|
])
|
|
|
|
|
->addRule('$updatedAt', [
|
2022-07-04 09:55:11 +00:00
|
|
|
'type' => self::TYPE_DATETIME,
|
2022-09-04 21:26:16 +00:00
|
|
|
'description' => 'Function update date in ISO 8601 format.',
|
2022-07-04 09:55:11 +00:00
|
|
|
'default' => '',
|
2022-08-14 10:27:07 +00:00
|
|
|
'example' => self::TYPE_DATETIME_EXAMPLE,
|
2022-06-15 12:46:52 +00:00
|
|
|
])
|
2021-08-07 12:49:36 +00:00
|
|
|
->addRule('execute', [
|
2021-12-14 10:42:34 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Execution permissions.',
|
2022-02-15 23:09:37 +00:00
|
|
|
'default' => [],
|
2022-08-03 04:17:49 +00:00
|
|
|
'example' => 'users',
|
2022-02-15 23:09:37 +00:00
|
|
|
'array' => true,
|
2020-12-30 12:25:42 +00:00
|
|
|
])
|
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' => 'Function name.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => 'My Function',
|
2023-02-20 13:11:29 +00:00
|
|
|
])
|
2022-09-09 08:49:18 +00:00
|
|
|
->addRule('enabled', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Function enabled.',
|
|
|
|
|
'default' => true,
|
2023-06-22 10:59:41 +00:00
|
|
|
'example' => false,
|
|
|
|
|
])
|
|
|
|
|
->addRule('live', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Is function live (deployed with latest config)?',
|
|
|
|
|
'default' => true,
|
2022-09-09 08:49:18 +00:00
|
|
|
'example' => false,
|
2020-10-29 13:07:56 +00:00
|
|
|
])
|
2023-02-24 09:24:20 +00:00
|
|
|
->addRule('logging', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Function logging.',
|
|
|
|
|
'default' => true,
|
|
|
|
|
'example' => false,
|
|
|
|
|
])
|
2021-06-22 15:56:05 +00:00
|
|
|
->addRule('runtime', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2021-06-22 15:56:05 +00:00
|
|
|
'description' => 'Function execution runtime.',
|
2021-01-13 15:06:36 +00:00
|
|
|
'default' => '',
|
2020-10-29 13:07:56 +00:00
|
|
|
'example' => 'python-3.8',
|
|
|
|
|
])
|
2022-01-24 23:31:41 +00:00
|
|
|
->addRule('deployment', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2022-01-24 23:31:41 +00:00
|
|
|
'description' => 'Function\'s active deployment ID.',
|
2020-10-29 13:07:56 +00:00
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
|
])
|
2022-08-09 12:00:16 +00:00
|
|
|
->addRule('vars', [
|
2022-08-12 15:51:24 +00:00
|
|
|
'type' => Response::MODEL_VARIABLE,
|
2022-08-19 09:57:59 +00:00
|
|
|
'description' => 'Function variables.',
|
2022-08-12 15:51:24 +00:00
|
|
|
'default' => [],
|
2022-08-13 19:18:48 +00:00
|
|
|
'example' => [],
|
2022-08-12 15:51:24 +00:00
|
|
|
'array' => true
|
2022-08-09 12:00:16 +00:00
|
|
|
])
|
2020-10-29 13:07:56 +00:00
|
|
|
->addRule('events', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'Function trigger events.',
|
|
|
|
|
'default' => [],
|
2021-02-01 21:31:54 +00:00
|
|
|
'example' => 'account.create',
|
2020-10-29 13:07:56 +00:00
|
|
|
'array' => true,
|
|
|
|
|
])
|
|
|
|
|
->addRule('schedule', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'Function execution schedult in CRON format.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '5 4 * * *',
|
|
|
|
|
])
|
|
|
|
|
->addRule('timeout', [
|
2020-11-07 22:14:48 +00:00
|
|
|
'type' => self::TYPE_INTEGER,
|
2020-10-29 13:07:56 +00:00
|
|
|
'description' => 'Function execution timeout in seconds.',
|
|
|
|
|
'default' => 15,
|
|
|
|
|
'example' => 1592981237,
|
|
|
|
|
])
|
2023-03-16 10:07:15 +00:00
|
|
|
->addRule('entrypoint', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
2023-03-28 13:21:42 +00:00
|
|
|
'description' => 'The entrypoint file used to execute the deployment.',
|
2023-03-16 10:07:15 +00:00
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'index.js',
|
|
|
|
|
])
|
2023-03-28 13:21:42 +00:00
|
|
|
->addRule('buildCommand', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'The build command used to build the deployment.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'npm run build',
|
|
|
|
|
])
|
|
|
|
|
->addRule('installCommand', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'The install command used to build the deployment.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'npm install',
|
|
|
|
|
])
|
2023-05-25 22:29:08 +00:00
|
|
|
->addRule('vcsInstallationId', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Function vcs installation id.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => '644051bd6572792165cc',
|
|
|
|
|
])
|
2023-06-07 15:50:32 +00:00
|
|
|
->addRule('vcsRepositoryId', [
|
2023-05-22 10:58:13 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2023-05-25 22:29:08 +00:00
|
|
|
'description' => 'Git Repository ID',
|
2023-05-22 19:27:14 +00:00
|
|
|
'default' => '',
|
2023-05-25 22:29:08 +00:00
|
|
|
'example' => 'appwrite',
|
2023-05-22 10:58:13 +00:00
|
|
|
])
|
2023-06-07 15:50:32 +00:00
|
|
|
->addRule('vcsBranch', [
|
2023-05-22 10:58:13 +00:00
|
|
|
'type' => self::TYPE_STRING,
|
2023-05-25 22:29:08 +00:00
|
|
|
'description' => 'Git branch name',
|
2023-05-22 10:58:13 +00:00
|
|
|
'default' => '',
|
2023-05-25 22:29:08 +00:00
|
|
|
'example' => 'main',
|
2023-05-22 10:58:13 +00:00
|
|
|
])
|
2023-06-07 15:50:32 +00:00
|
|
|
->addRule('vcsRootDirectory', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Path to function in git repository',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'functions/helloWorld',
|
|
|
|
|
])
|
|
|
|
|
->addRule('vcsSilentMode', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Is VCS connection is in silent mode?',
|
|
|
|
|
'default' => false,
|
|
|
|
|
'example' => false,
|
|
|
|
|
])
|
2020-10-29 13:07:56 +00:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get Name
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2020-10-29 13:07:56 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getName(): string
|
2020-10-29 13:07:56 +00:00
|
|
|
{
|
|
|
|
|
return 'Function';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-15 10:19:29 +00:00
|
|
|
* Get Type
|
2021-10-06 14:22:38 +00:00
|
|
|
*
|
2020-10-29 13:07:56 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getType(): string
|
2020-10-29 13:07:56 +00:00
|
|
|
{
|
|
|
|
|
return Response::MODEL_FUNCTION;
|
|
|
|
|
}
|
2021-10-06 14:22:38 +00:00
|
|
|
}
|