Updated collections
This commit is contained in:
parent
a79af138ff
commit
09e57b46ce
5 changed files with 330 additions and 116 deletions
File diff suppressed because it is too large
Load diff
|
@ -75,6 +75,13 @@ return [
|
||||||
'sdk' => true,
|
'sdk' => true,
|
||||||
'tests' => false,
|
'tests' => false,
|
||||||
],
|
],
|
||||||
|
'v1/functions' => [
|
||||||
|
'name' => 'Users',
|
||||||
|
'description' => '/docs/services/functions.md',
|
||||||
|
'controller' => 'controllers/api/functions.php',
|
||||||
|
'sdk' => true,
|
||||||
|
'tests' => false,
|
||||||
|
],
|
||||||
'v1/mock' => [
|
'v1/mock' => [
|
||||||
'name' => 'Mock',
|
'name' => 'Mock',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
|
|
44
app/controllers/api/functions.php
Normal file
44
app/controllers/api/functions.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
global $utopia, $response, $projectDB;
|
||||||
|
|
||||||
|
use Appwrite\Database\Database;
|
||||||
|
use Appwrite\Database\Document;
|
||||||
|
use Utopia\Validator\Text;
|
||||||
|
use Utopia\Validator\Range;
|
||||||
|
|
||||||
|
include_once __DIR__ . '/../shared/api.php';
|
||||||
|
|
||||||
|
$utopia->post('/v1/functions')
|
||||||
|
->desc('Create Function')
|
||||||
|
->label('scope', 'functions.write')
|
||||||
|
->label('sdk.platform', [APP_PLATFORM_SERVER])
|
||||||
|
->label('sdk.namespace', 'functions')
|
||||||
|
->label('sdk.method', 'create')
|
||||||
|
->label('sdk.description', '/docs/references/users/create-function.md')
|
||||||
|
->param('name', '', function () { return new Text(128); }, 'Function name.')
|
||||||
|
->param('timeout', '', function () { return new Range(1, 10); }, 'Function maximum execution time in seconds.')
|
||||||
|
->action(
|
||||||
|
function ($name, $timeout) use ($response, $projectDB) {
|
||||||
|
$function = new Document([
|
||||||
|
'$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
|
||||||
|
'$permissions' => [
|
||||||
|
'read' => [],
|
||||||
|
'write' => [],
|
||||||
|
],
|
||||||
|
'name' => $name,
|
||||||
|
'timeout' => $timeout,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// $response
|
||||||
|
// ->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||||
|
// ->json(array_merge($user->getArrayCopy(array_merge([
|
||||||
|
// '$id',
|
||||||
|
// 'status',
|
||||||
|
// 'email',
|
||||||
|
// 'registration',
|
||||||
|
// 'emailVerification',
|
||||||
|
// 'name',
|
||||||
|
// ], $oauth2Keys)), ['roles' => []]));
|
||||||
|
}
|
||||||
|
);
|
3
docs/services/functions.md
Normal file
3
docs/services/functions.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
The Functions service allows you to create custom behaviour that can be triggered by any supported Appwrite system events or by a predefined schedule.
|
||||||
|
|
||||||
|
Appwrite Cloud Functions lets you automatically run backend code in response to events triggered by Appwrite or by setting it to be executed in a predefined schedule. Your code is stored in a secure and encrypted way on your Appwrite instance and is executed in an isolated enviornment.
|
|
@ -35,6 +35,22 @@ class Database
|
||||||
// Storage
|
// Storage
|
||||||
const SYSTEM_COLLECTION_FILES = 'files';
|
const SYSTEM_COLLECTION_FILES = 'files';
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
const SYSTEM_COLLECTION_FUNCTIONS = 'functions';
|
||||||
|
const SYSTEM_COLLECTION_PACKAGES = 'packages';
|
||||||
|
const SYSTEM_COLLECTION_EXECUTIONS = 'executions';
|
||||||
|
|
||||||
|
// Var Types
|
||||||
|
const SYSTEM_VAR_TYPE_TEXT = 'text';
|
||||||
|
const SYSTEM_VAR_TYPE_NUMERIC = 'numeric';
|
||||||
|
const SYSTEM_VAR_TYPE_BOOLEAN = 'boolean';
|
||||||
|
const SYSTEM_VAR_TYPE_DOCUMENT = 'document';
|
||||||
|
const SYSTEM_VAR_TYPE_WILDCARD = 'wildcard';
|
||||||
|
const SYSTEM_VAR_TYPE_EMAIL = 'email';
|
||||||
|
const SYSTEM_VAR_TYPE_IP = 'ip';
|
||||||
|
const SYSTEM_VAR_TYPE_URL = 'url';
|
||||||
|
const SYSTEM_VAR_TYPE_KEY = 'key';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue