1
0
Fork 0
mirror of synced 2024-06-24 01:00:35 +12:00
appwrite/app/controllers/api/functions.php

45 lines
1.5 KiB
PHP
Raw Normal View History

2020-05-05 02:35:01 +12:00
<?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' => []]));
}
);