Updated SDKs
This commit is contained in:
parent
ed468a3273
commit
c2975c9177
|
@ -6,6 +6,8 @@ global $utopia, $response, $request, $layout;
|
||||||
|
|
||||||
use Utopia\View;
|
use Utopia\View;
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
|
use Utopia\Validator\WhiteList;
|
||||||
|
use Utopia\Validator\Range;
|
||||||
|
|
||||||
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
|
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
|
||||||
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
|
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
|
||||||
|
@ -155,3 +157,410 @@ $utopia->get('/error/:code')
|
||||||
->setParam('title', 'Error'.' - '.APP_NAME)
|
->setParam('title', 'Error'.' - '.APP_NAME)
|
||||||
->setParam('body', $page);
|
->setParam('body', $page);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$utopia->get('/open-api-2.json')
|
||||||
|
->label('scope', 'public')
|
||||||
|
->label('docs', false)
|
||||||
|
->param('platform', APP_PLATFORM_CLIENT, function () {return new WhiteList([APP_PLATFORM_CLIENT, APP_PLATFORM_SERVER, APP_PLATFORM_CONSOLE]);}, 'Choose target platform.', true)
|
||||||
|
->param('extensions', 0, function () {return new Range(0, 1);}, 'Show extra data.', true)
|
||||||
|
->param('tests', 0, function () {return new Range(0, 1);}, 'Include only test services.', true)
|
||||||
|
->action(
|
||||||
|
function ($platform, $extensions, $tests) use ($response, $request, $utopia, $services) {
|
||||||
|
function fromCamelCase($input)
|
||||||
|
{
|
||||||
|
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||||
|
$ret = $matches[0];
|
||||||
|
foreach ($ret as &$match) {
|
||||||
|
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode('_', $ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fromCamelCaseToDash($input)
|
||||||
|
{
|
||||||
|
return str_replace([' ', '_'], '-', strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $input)));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($services as $service) { /* @noinspection PhpIncludeInspection */
|
||||||
|
if($tests && !isset($service['tests'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($tests && !$service['tests']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$tests && !$service['sdk']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
include_once realpath(__DIR__.'/../../'.$service['controller']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$security = [
|
||||||
|
APP_PLATFORM_CLIENT => ['Project' => []],
|
||||||
|
APP_PLATFORM_SERVER => ['Project' => [], 'Key' => []],
|
||||||
|
APP_PLATFORM_CONSOLE => ['Project' => [], 'Key' => []],
|
||||||
|
];
|
||||||
|
|
||||||
|
$platforms = [
|
||||||
|
'client' => APP_PLATFORM_CLIENT,
|
||||||
|
'server' => APP_PLATFORM_SERVER,
|
||||||
|
'all' => APP_PLATFORM_CONSOLE,
|
||||||
|
];
|
||||||
|
|
||||||
|
$keys = [
|
||||||
|
APP_PLATFORM_CLIENT => [
|
||||||
|
'Project' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Project',
|
||||||
|
'description' => 'Your project ID',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Locale' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Locale',
|
||||||
|
'description' => '',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
APP_PLATFORM_SERVER => [
|
||||||
|
'Project' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Project',
|
||||||
|
'description' => 'Your project ID',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Key' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Key',
|
||||||
|
'description' => 'Your secret API key',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Locale' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Locale',
|
||||||
|
'description' => '',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
APP_PLATFORM_CONSOLE => [
|
||||||
|
'Project' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Project',
|
||||||
|
'description' => 'Your project ID',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Key' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Key',
|
||||||
|
'description' => 'Your secret API key',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Locale' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Locale',
|
||||||
|
'description' => '',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
'Mode' => [
|
||||||
|
'type' => 'apiKey',
|
||||||
|
'name' => 'X-Appwrite-Mode',
|
||||||
|
'description' => '',
|
||||||
|
'in' => 'header',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specifications (v3.0.0):
|
||||||
|
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md
|
||||||
|
*/
|
||||||
|
$output = [
|
||||||
|
'swagger' => '2.0',
|
||||||
|
'info' => [
|
||||||
|
'version' => APP_VERSION_STABLE,
|
||||||
|
'title' => APP_NAME,
|
||||||
|
'description' => 'Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)',
|
||||||
|
'termsOfService' => 'https://appwrite.io/policy/terms',
|
||||||
|
'contact' => [
|
||||||
|
'name' => 'Appwrite Team',
|
||||||
|
'url' => 'https://appwrite.io/support',
|
||||||
|
'email' => $request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
|
||||||
|
],
|
||||||
|
'license' => [
|
||||||
|
'name' => 'BSD-3-Clause',
|
||||||
|
'url' => 'https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'host' => parse_url($request->getServer('_APP_HOME', Config::getParam('domain')), PHP_URL_HOST),
|
||||||
|
'basePath' => '/v1',
|
||||||
|
'schemes' => ['https'],
|
||||||
|
'consumes' => ['application/json', 'multipart/form-data'],
|
||||||
|
'produces' => ['application/json'],
|
||||||
|
'securityDefinitions' => $keys[$platform],
|
||||||
|
'paths' => [],
|
||||||
|
'definitions' => [
|
||||||
|
// 'Pet' => [
|
||||||
|
// 'required' => ['id', 'name'],
|
||||||
|
// 'properties' => [
|
||||||
|
// 'id' => [
|
||||||
|
// 'type' => 'integer',
|
||||||
|
// 'format' => 'int64',
|
||||||
|
// ],
|
||||||
|
// 'name' => [
|
||||||
|
// 'type' => 'string',
|
||||||
|
// ],
|
||||||
|
// 'tag' => [
|
||||||
|
// 'type' => 'string',
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// 'Pets' => array(
|
||||||
|
// 'type' => 'array',
|
||||||
|
// 'items' => array(
|
||||||
|
// '$ref' => '#/definitions/Pet',
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
'Error' => array(
|
||||||
|
'required' => array(
|
||||||
|
0 => 'code',
|
||||||
|
1 => 'message',
|
||||||
|
),
|
||||||
|
'properties' => array(
|
||||||
|
'code' => array(
|
||||||
|
'type' => 'integer',
|
||||||
|
'format' => 'int32',
|
||||||
|
),
|
||||||
|
'message' => array(
|
||||||
|
'type' => 'string',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
'externalDocs' => [
|
||||||
|
'description' => 'Full API docs, specs and tutorials',
|
||||||
|
'url' => Config::getParam('protocol').'://'.Config::getParam('domain').'/docs',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($extensions) {
|
||||||
|
if(isset($output['securityDefinitions']['Project'])) {
|
||||||
|
$output['securityDefinitions']['Project']['extensions'] = ['demo' => '5df5acd0d48c2'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($output['securityDefinitions']['Key'])) {
|
||||||
|
$output['securityDefinitions']['Key']['extensions'] = ['demo' => '919c2d18fb5d4...a2ae413da83346ad2'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($output['securityDefinitions']['Locale'])) {
|
||||||
|
$output['securityDefinitions']['Locale']['extensions'] = ['demo' => 'en'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($output['securityDefinitions']['Mode'])) {
|
||||||
|
$output['securityDefinitions']['Mode']['extensions'] = ['demo' => ''];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($utopia->getRoutes() as $key => $method) {
|
||||||
|
foreach ($method as $route) { /* @var $route \Utopia\Route */
|
||||||
|
if (!$route->getLabel('docs', true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($route->getLabel('sdk.namespace', null))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($platform !== APP_PLATFORM_CONSOLE && !in_array($platforms[$platform], $route->getLabel('sdk.platform', []))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = str_replace('/v1', '', $route->getURL());
|
||||||
|
$scope = $route->getLabel('scope', '');
|
||||||
|
$hide = $route->getLabel('sdk.hide', false);
|
||||||
|
$consumes = ['application/json'];
|
||||||
|
|
||||||
|
if ($hide) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$desc = (!empty($route->getLabel('sdk.description', ''))) ? realpath('../'.$route->getLabel('sdk.description', '')) : null;
|
||||||
|
|
||||||
|
$temp = [
|
||||||
|
'summary' => $route->getDesc(),
|
||||||
|
'operationId' => $route->getLabel('sdk.method', uniqid()),
|
||||||
|
'consumes' => [],
|
||||||
|
'tags' => [$route->getLabel('sdk.namespace', 'default')],
|
||||||
|
'description' => ($desc) ? file_get_contents($desc) : '',
|
||||||
|
|
||||||
|
// 'responses' => [
|
||||||
|
// 200 => [
|
||||||
|
// 'description' => 'An paged array of pets',
|
||||||
|
// 'schema' => [
|
||||||
|
// '$ref' => '#/definitions/Pet',
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($extensions) {
|
||||||
|
$platformList = $route->getLabel('sdk.platform', []);
|
||||||
|
|
||||||
|
if(in_array(APP_PLATFORM_CLIENT, $platformList)) {
|
||||||
|
$platformList = array_merge($platformList, [
|
||||||
|
APP_PLATFORM_WEB,
|
||||||
|
APP_PLATFORM_IOS,
|
||||||
|
APP_PLATFORM_ANDROID,
|
||||||
|
APP_PLATFORM_FLUTTER,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp['extensions'] = [
|
||||||
|
'weight' => $route->getOrder(),
|
||||||
|
'cookies' => $route->getLabel('sdk.cookies', false),
|
||||||
|
'type' => $route->getLabel('sdk.methodType', ''),
|
||||||
|
'demo' => 'docs/examples/'.fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.fromCamelCaseToDash($temp['operationId']).'.md',
|
||||||
|
'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''),
|
||||||
|
'rate-limit' => $route->getLabel('abuse-limit', 0),
|
||||||
|
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||||
|
'scope' => $route->getLabel('scope', ''),
|
||||||
|
'platforms' => $platformList,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!empty($scope))) { // && 'public' != $scope
|
||||||
|
$temp['security'][] = $route->getLabel('sdk.security', $security[$platform]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$requestBody = [
|
||||||
|
'content' => [
|
||||||
|
'application/x-www-form-urlencoded' => [
|
||||||
|
'schema' => [
|
||||||
|
'type' => 'object',
|
||||||
|
'properties' => [],
|
||||||
|
],
|
||||||
|
'required' => [],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($route->getParams() as $name => $param) {
|
||||||
|
$validator = (is_callable($param['validator'])) ? $param['validator']() : $param['validator']; /* @var $validator \Utopia\Validator */
|
||||||
|
|
||||||
|
$node = [
|
||||||
|
'name' => $name,
|
||||||
|
'description' => $param['description'],
|
||||||
|
'required' => !$param['optional'],
|
||||||
|
];
|
||||||
|
|
||||||
|
switch ((!empty($validator)) ? get_class($validator) : '') {
|
||||||
|
case 'Utopia\Validator\Text':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||||
|
break;
|
||||||
|
case 'Appwrite\Database\Validator\UID':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\Email':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['format'] = 'email';
|
||||||
|
$node['x-example'] = 'email@example.com';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\URL':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['format'] = 'url';
|
||||||
|
$node['x-example'] = 'https://example.com';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\JSON':
|
||||||
|
case 'Utopia\Validator\Mock':
|
||||||
|
case 'Utopia\Validator\Assoc':
|
||||||
|
$node['type'] = 'object';
|
||||||
|
$node['type'] = 'object';
|
||||||
|
$node['x-example'] = '{}';
|
||||||
|
//$node['format'] = 'json';
|
||||||
|
break;
|
||||||
|
case 'Appwrite\Storage\Validators\File':
|
||||||
|
$consumes = ['multipart/form-data'];
|
||||||
|
$node['type'] = 'file';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\ArrayList':
|
||||||
|
$node['type'] = 'array';
|
||||||
|
$node['collectionFormat'] = 'multi';
|
||||||
|
$node['items'] = [
|
||||||
|
'type' => 'string',
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'Appwrite\Auth\Validator\Password':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['format'] = 'format';
|
||||||
|
$node['x-example'] = 'password';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\Range': /* @var $validator \Utopia\Validator\Range */
|
||||||
|
$node['type'] = 'integer';
|
||||||
|
$node['format'] = 'int32';
|
||||||
|
$node['x-example'] = $validator->getMin();
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\Numeric':
|
||||||
|
$node['type'] = 'integer';
|
||||||
|
$node['format'] = 'int32';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\Length':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\Host':
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['format'] = 'url';
|
||||||
|
$node['x-example'] = 'https://example.com';
|
||||||
|
break;
|
||||||
|
case 'Utopia\Validator\WhiteList': /* @var $validator \Utopia\Validator\WhiteList */
|
||||||
|
$node['type'] = 'string';
|
||||||
|
$node['x-example'] = $validator->getList()[0];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$node['type'] = 'string';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($param['optional'] && !is_null($param['default'])) { // Param has default value
|
||||||
|
$node['default'] = $param['default'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false !== strpos($url, ':'.$name)) { // Param is in URL path
|
||||||
|
$node['in'] = 'path';
|
||||||
|
$temp['parameters'][] = $node;
|
||||||
|
} elseif ($key == 'GET') { // Param is in query
|
||||||
|
$node['in'] = 'query';
|
||||||
|
$temp['parameters'][] = $node;
|
||||||
|
} else { // Param is in payload
|
||||||
|
$node['in'] = 'formData';
|
||||||
|
$temp['parameters'][] = $node;
|
||||||
|
$requestBody['content']['application/x-www-form-urlencoded']['schema']['properties'][] = $node;
|
||||||
|
|
||||||
|
if (!$param['optional']) {
|
||||||
|
$requestBody['content']['application/x-www-form-urlencoded']['required'][] = $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = str_replace(':'.$name, '{'.$name.'}', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp['consumes'] = $consumes;
|
||||||
|
|
||||||
|
$output['paths'][$url][strtolower($route->getMethod())] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*foreach ($consoleDB->getMocks() as $mock) {
|
||||||
|
var_dump($mock['name']);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
ksort($output['paths']);
|
||||||
|
|
||||||
|
$response
|
||||||
|
->json($output);
|
||||||
|
}
|
||||||
|
);
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.createExecution('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.createTag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.create('[NAME]', {}, 'event', [], '', 1);
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.deleteTag('[FUNCTION_ID]', '[TAG_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.delete('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.getTag('[FUNCTION_ID]', '[TAG_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
14
app/sdks/console-javascript/docs/examples/functions/get.md
Normal file
14
app/sdks/console-javascript/docs/examples/functions/get.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.get('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.listExecutions('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.listTags('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
14
app/sdks/console-javascript/docs/examples/functions/list.md
Normal file
14
app/sdks/console-javascript/docs/examples/functions/list.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.list();
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.updateActive('[FUNCTION_ID]', '[ACTIVE]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', [], '', 1);
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
let sdk = new Appwrite();
|
||||||
|
|
||||||
|
sdk
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = sdk.health.getQueueFunctions();
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response); // Success
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error); // Failure
|
||||||
|
});
|
|
@ -748,7 +748,7 @@
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
createOAuth2Session: function(provider, success = 'https://localhost:2444/auth/oauth2/success', failure = 'https://localhost:2444/auth/oauth2/failure') {
|
createOAuth2Session: function(provider, success = 'https://localhost/auth/oauth2/success', failure = 'https://localhost/auth/oauth2/failure') {
|
||||||
if(provider === undefined) {
|
if(provider === undefined) {
|
||||||
throw new Error('Missing required parameter: "provider"');
|
throw new Error('Missing required parameter: "provider"');
|
||||||
}
|
}
|
||||||
|
@ -1606,6 +1606,522 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let functions = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Functions
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
list: function(search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
let path = '/functions';
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(search) {
|
||||||
|
payload['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(limit) {
|
||||||
|
payload['limit'] = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(offset) {
|
||||||
|
payload['offset'] = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(orderType) {
|
||||||
|
payload['orderType'] = orderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} name
|
||||||
|
* @param {object} vars
|
||||||
|
* @param {string} trigger
|
||||||
|
* @param {string[]} events
|
||||||
|
* @param {string} schedule
|
||||||
|
* @param {number} timeout
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
create: function(name, vars, trigger, events, schedule, timeout) {
|
||||||
|
if(name === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "name"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vars === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "vars"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trigger === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "trigger"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(events === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "events"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "schedule"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(timeout === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "timeout"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions';
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(name) {
|
||||||
|
payload['name'] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vars) {
|
||||||
|
payload['vars'] = vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trigger) {
|
||||||
|
payload['trigger'] = trigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(events) {
|
||||||
|
payload['events'] = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule) {
|
||||||
|
payload['schedule'] = schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(timeout) {
|
||||||
|
payload['timeout'] = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.post(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
get: function(functionId) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} name
|
||||||
|
* @param {object} vars
|
||||||
|
* @param {string} trigger
|
||||||
|
* @param {string[]} events
|
||||||
|
* @param {string} schedule
|
||||||
|
* @param {number} timeout
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
update: function(functionId, name, vars, trigger, events, schedule, timeout) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(name === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "name"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vars === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "vars"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trigger === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "trigger"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(events === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "events"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "schedule"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(timeout === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "timeout"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(name) {
|
||||||
|
payload['name'] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vars) {
|
||||||
|
payload['vars'] = vars;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trigger) {
|
||||||
|
payload['trigger'] = trigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(events) {
|
||||||
|
payload['events'] = events;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule) {
|
||||||
|
payload['schedule'] = schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(timeout) {
|
||||||
|
payload['timeout'] = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.put(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
delete: function(functionId) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.delete(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function Active Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} active
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
updateActive: function(functionId, active) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(active === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "active"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/active'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(active) {
|
||||||
|
payload['active'] = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.patch(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Executions
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
listExecutions: function(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(search) {
|
||||||
|
payload['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(limit) {
|
||||||
|
payload['limit'] = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(offset) {
|
||||||
|
payload['offset'] = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(orderType) {
|
||||||
|
payload['orderType'] = orderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Execution
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {number} async
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
createExecution: function(functionId, async = 1) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(async) {
|
||||||
|
payload['async'] = async;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.post(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Execution
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} executionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getExecution: function(functionId, executionId) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(executionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "executionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{executionId}', 'g'), executionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Tags
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
listTags: function(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(search) {
|
||||||
|
payload['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(limit) {
|
||||||
|
payload['limit'] = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(offset) {
|
||||||
|
payload['offset'] = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(orderType) {
|
||||||
|
payload['orderType'] = orderType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} env
|
||||||
|
* @param {string} command
|
||||||
|
* @param {string} code
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
createTag: function(functionId, env, command, code) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(env === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "env"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(command === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "command"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(code === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "code"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
if(env) {
|
||||||
|
payload['env'] = env;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(command) {
|
||||||
|
payload['command'] = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(code) {
|
||||||
|
payload['code'] = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return http
|
||||||
|
.post(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} tagId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getTag: function(functionId, tagId) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tagId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "tagId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} tagId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
deleteTag: function(functionId, tagId) {
|
||||||
|
if(functionId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "functionId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tagId === undefined) {
|
||||||
|
throw new Error('Missing required parameter: "tagId"');
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId);
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.delete(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let health = {
|
let health = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1687,6 +2203,24 @@
|
||||||
}, payload);
|
}, payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the number of pending functions messages
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getQueueFunctions: function() {
|
||||||
|
let path = '/health/queue/functions';
|
||||||
|
|
||||||
|
let payload = {};
|
||||||
|
|
||||||
|
return http
|
||||||
|
.get(path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, payload);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the number of pending log messages
|
* Check the number of pending log messages
|
||||||
*
|
*
|
||||||
|
@ -4194,6 +4728,7 @@
|
||||||
account: account,
|
account: account,
|
||||||
avatars: avatars,
|
avatars: avatars,
|
||||||
database: database,
|
database: database,
|
||||||
|
functions: functions,
|
||||||
health: health,
|
health: health,
|
||||||
locale: locale,
|
locale: locale,
|
||||||
projects: projects,
|
projects: projects,
|
||||||
|
|
65
app/sdks/console-javascript/src/sdk.min.js
vendored
65
app/sdks/console-javascript/src/sdk.min.js
vendored
|
@ -45,7 +45,7 @@ return http.put(path,{'content-type':'application/json',},payload)},getSessions:
|
||||||
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
||||||
let path='/account/sessions';let payload={};if(email){payload.email=email}
|
let path='/account/sessions';let payload={};if(email){payload.email=email}
|
||||||
if(password){payload.password=password}
|
if(password){payload.password=password}
|
||||||
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://localhost:2444/auth/oauth2/success',failure='https://localhost:2444/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://localhost/auth/oauth2/success',failure='https://localhost/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
||||||
let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success}
|
let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success}
|
||||||
if(failure){payload.failure=failure}
|
if(failure){payload.failure=failure}
|
||||||
payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')}
|
payload.project=config.project;payload.key=config.key;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')}
|
||||||
|
@ -133,7 +133,66 @@ if(write){payload.write=write}
|
||||||
return http.patch(path,{'content-type':'application/json',},payload)},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
return http.patch(path,{'content-type':'application/json',},payload)},deleteDocument:function(collectionId,documentId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||||
if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')}
|
if(documentId===undefined){throw new Error('Missing required parameter: "documentId"')}
|
||||||
let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getCollectionLogs:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
let path='/database/collections/{collectionId}/documents/{documentId}'.replace(new RegExp('{collectionId}','g'),collectionId).replace(new RegExp('{documentId}','g'),documentId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},getCollectionLogs:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"')}
|
||||||
let path='/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let health={get:function(){let path='/health';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCache:function(){let path='/health/cache';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getDB:function(){let path='/health/db';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueCertificates:function(){let path='/health/queue/certificates';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueLogs:function(){let path='/health/queue/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueTasks:function(){let path='/health/queue/tasks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueUsage:function(){let path='/health/queue/usage';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueWebhooks:function(){let path='/health/queue/webhooks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getStorageAntiVirus:function(){let path='/health/storage/anti-virus';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getStorageLocal:function(){let path='/health/storage/local';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getTime:function(){let path='/health/time';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let projects={list:function(){let path='/projects';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
let path='/database/collections/{collectionId}/logs'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let functions={list:function(search='',limit=25,offset=0,orderType='ASC'){let path='/functions';let payload={};if(search){payload.search=search}
|
||||||
|
if(limit){payload.limit=limit}
|
||||||
|
if(offset){payload.offset=offset}
|
||||||
|
if(orderType){payload.orderType=orderType}
|
||||||
|
return http.get(path,{'content-type':'application/json',},payload)},create:function(name,vars,trigger,events,schedule,timeout){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||||
|
if(vars===undefined){throw new Error('Missing required parameter: "vars"')}
|
||||||
|
if(trigger===undefined){throw new Error('Missing required parameter: "trigger"')}
|
||||||
|
if(events===undefined){throw new Error('Missing required parameter: "events"')}
|
||||||
|
if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')}
|
||||||
|
if(timeout===undefined){throw new Error('Missing required parameter: "timeout"')}
|
||||||
|
let path='/functions';let payload={};if(name){payload.name=name}
|
||||||
|
if(vars){payload.vars=vars}
|
||||||
|
if(trigger){payload.trigger=trigger}
|
||||||
|
if(events){payload.events=events}
|
||||||
|
if(schedule){payload.schedule=schedule}
|
||||||
|
if(timeout){payload.timeout=timeout}
|
||||||
|
return http.post(path,{'content-type':'application/json',},payload)},get:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},update:function(functionId,name,vars,trigger,events,schedule,timeout){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||||
|
if(vars===undefined){throw new Error('Missing required parameter: "vars"')}
|
||||||
|
if(trigger===undefined){throw new Error('Missing required parameter: "trigger"')}
|
||||||
|
if(events===undefined){throw new Error('Missing required parameter: "events"')}
|
||||||
|
if(schedule===undefined){throw new Error('Missing required parameter: "schedule"')}
|
||||||
|
if(timeout===undefined){throw new Error('Missing required parameter: "timeout"')}
|
||||||
|
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(name){payload.name=name}
|
||||||
|
if(vars){payload.vars=vars}
|
||||||
|
if(trigger){payload.trigger=trigger}
|
||||||
|
if(events){payload.events=events}
|
||||||
|
if(schedule){payload.schedule=schedule}
|
||||||
|
if(timeout){payload.timeout=timeout}
|
||||||
|
return http.put(path,{'content-type':'application/json',},payload)},delete:function(functionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
let path='/functions/{functionId}'.replace(new RegExp('{functionId}','g'),functionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateActive:function(functionId,active){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(active===undefined){throw new Error('Missing required parameter: "active"')}
|
||||||
|
let path='/functions/{functionId}/active'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(active){payload.active=active}
|
||||||
|
return http.patch(path,{'content-type':'application/json',},payload)},listExecutions:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload.search=search}
|
||||||
|
if(limit){payload.limit=limit}
|
||||||
|
if(offset){payload.offset=offset}
|
||||||
|
if(orderType){payload.orderType=orderType}
|
||||||
|
return http.get(path,{'content-type':'application/json',},payload)},createExecution:function(functionId,async=1){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
let path='/functions/{functionId}/executions'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(async){payload.async=async}
|
||||||
|
return http.post(path,{'content-type':'application/json',},payload)},getExecution:function(functionId,executionId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(executionId===undefined){throw new Error('Missing required parameter: "executionId"')}
|
||||||
|
let path='/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{executionId}','g'),executionId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},listTags:function(functionId,search='',limit=25,offset=0,orderType='ASC'){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(search){payload.search=search}
|
||||||
|
if(limit){payload.limit=limit}
|
||||||
|
if(offset){payload.offset=offset}
|
||||||
|
if(orderType){payload.orderType=orderType}
|
||||||
|
return http.get(path,{'content-type':'application/json',},payload)},createTag:function(functionId,env,command,code){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(env===undefined){throw new Error('Missing required parameter: "env"')}
|
||||||
|
if(command===undefined){throw new Error('Missing required parameter: "command"')}
|
||||||
|
if(code===undefined){throw new Error('Missing required parameter: "code"')}
|
||||||
|
let path='/functions/{functionId}/tags'.replace(new RegExp('{functionId}','g'),functionId);let payload={};if(env){payload.env=env}
|
||||||
|
if(command){payload.command=command}
|
||||||
|
if(code){payload.code=code}
|
||||||
|
return http.post(path,{'content-type':'application/json',},payload)},getTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(tagId===undefined){throw new Error('Missing required parameter: "tagId"')}
|
||||||
|
let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.get(path,{'content-type':'application/json',},payload)},deleteTag:function(functionId,tagId){if(functionId===undefined){throw new Error('Missing required parameter: "functionId"')}
|
||||||
|
if(tagId===undefined){throw new Error('Missing required parameter: "tagId"')}
|
||||||
|
let path='/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}','g'),functionId).replace(new RegExp('{tagId}','g'),tagId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)}};let health={get:function(){let path='/health';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCache:function(){let path='/health/cache';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getDB:function(){let path='/health/db';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueCertificates:function(){let path='/health/queue/certificates';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueFunctions:function(){let path='/health/queue/functions';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueLogs:function(){let path='/health/queue/logs';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueTasks:function(){let path='/health/queue/tasks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueUsage:function(){let path='/health/queue/usage';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getQueueWebhooks:function(){let path='/health/queue/webhooks';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getStorageAntiVirus:function(){let path='/health/storage/anti-virus';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getStorageLocal:function(){let path='/health/storage/local';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getTime:function(){let path='/health/time';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let locale={get:function(){let path='/locale';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getContinents:function(){let path='/locale/continents';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountries:function(){let path='/locale/countries';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesEU:function(){let path='/locale/countries/eu';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCountriesPhones:function(){let path='/locale/countries/phones';let payload={};return http.get(path,{'content-type':'application/json',},payload)},getCurrencies:function(){let path='/locale/currencies';let payload={};return http.get(path,{'content-type':'application/json',},payload)}};let projects={list:function(){let path='/projects';let payload={};return http.get(path,{'content-type':'application/json',},payload)},create:function(name,teamId,description='',logo='',url='',legalName='',legalCountry='',legalState='',legalCity='',legalAddress='',legalTaxId=''){if(name===undefined){throw new Error('Missing required parameter: "name"')}
|
||||||
if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')}
|
if(teamId===undefined){throw new Error('Missing required parameter: "teamId"')}
|
||||||
let path='/projects';let payload={};if(name){payload.name=name}
|
let path='/projects';let payload={};if(name){payload.name=name}
|
||||||
if(teamId){payload.teamId=teamId}
|
if(teamId){payload.teamId=teamId}
|
||||||
|
@ -358,4 +417,4 @@ if(sessionId===undefined){throw new Error('Missing required parameter: "sessionI
|
||||||
let path='/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}','g'),userId).replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
let path='/users/{userId}/sessions/{sessionId}'.replace(new RegExp('{userId}','g'),userId).replace(new RegExp('{sessionId}','g'),sessionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload)},updateStatus:function(userId,status){if(userId===undefined){throw new Error('Missing required parameter: "userId"')}
|
||||||
if(status===undefined){throw new Error('Missing required parameter: "status"')}
|
if(status===undefined){throw new Error('Missing required parameter: "status"')}
|
||||||
let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);let payload={};if(status){payload.status=status}
|
let path='/users/{userId}/status'.replace(new RegExp('{userId}','g'),userId);let payload={};if(status){payload.status=status}
|
||||||
return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,health:health,locale:locale,projects:projects,storage:storage,teams:teams,users:users}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{})
|
return http.patch(path,{'content-type':'application/json',},payload)}};return{setEndpoint:setEndpoint,setProject:setProject,setKey:setKey,setLocale:setLocale,setMode:setMode,account:account,avatars:avatars,database:database,functions:functions,health:health,locale:locale,projects:projects,storage:storage,teams:teams,users:users}};if(typeof module!=="undefined"){module.exports=window.Appwrite}})((typeof window!=="undefined")?window:{})
|
174
app/sdks/console-javascript/types/index.d.ts
vendored
174
app/sdks/console-javascript/types/index.d.ts
vendored
|
@ -57,6 +57,7 @@ declare class Appwrite {
|
||||||
account:Appwrite.Account;
|
account:Appwrite.Account;
|
||||||
avatars:Appwrite.Avatars;
|
avatars:Appwrite.Avatars;
|
||||||
database:Appwrite.Database;
|
database:Appwrite.Database;
|
||||||
|
functions:Appwrite.Functions;
|
||||||
health:Appwrite.Health;
|
health:Appwrite.Health;
|
||||||
locale:Appwrite.Locale;
|
locale:Appwrite.Locale;
|
||||||
projects:Appwrite.Projects;
|
projects:Appwrite.Projects;
|
||||||
|
@ -589,6 +590,170 @@ declare namespace Appwrite {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Functions {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Functions
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
list(search: string, limit: number, offset: number, orderType: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} name
|
||||||
|
* @param {object} vars
|
||||||
|
* @param {string} trigger
|
||||||
|
* @param {string[]} events
|
||||||
|
* @param {string} schedule
|
||||||
|
* @param {number} timeout
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
create(name: string, vars: object, trigger: string, events: string[], schedule: string, timeout: number): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
get(functionId: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} name
|
||||||
|
* @param {object} vars
|
||||||
|
* @param {string} trigger
|
||||||
|
* @param {string[]} events
|
||||||
|
* @param {string} schedule
|
||||||
|
* @param {number} timeout
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
update(functionId: string, name: string, vars: object, trigger: string, events: string[], schedule: string, timeout: number): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Function
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
delete(functionId: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function Active Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} active
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
updateActive(functionId: string, active: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Executions
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
listExecutions(functionId: string, search: string, limit: number, offset: number, orderType: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Execution
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {number} async
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
createExecution(functionId: string, async: number): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Execution
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} executionId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getExecution(functionId: string, executionId: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Tags
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} search
|
||||||
|
* @param {number} limit
|
||||||
|
* @param {number} offset
|
||||||
|
* @param {string} orderType
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
listTags(functionId: string, search: string, limit: number, offset: number, orderType: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} env
|
||||||
|
* @param {string} command
|
||||||
|
* @param {string} code
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
createTag(functionId: string, env: string, command: string, code: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} tagId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getTag(functionId: string, tagId: string): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Tag
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} functionId
|
||||||
|
* @param {string} tagId
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
deleteTag(functionId: string, tagId: string): Promise<object>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export interface Health {
|
export interface Health {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -634,6 +799,15 @@ declare namespace Appwrite {
|
||||||
*/
|
*/
|
||||||
getQueueCertificates(): Promise<object>;
|
getQueueCertificates(): Promise<object>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the number of pending functions messages
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws {Error}
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
getQueueFunctions(): Promise<object>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the number of pending log messages
|
* Check the number of pending log messages
|
||||||
*
|
*
|
||||||
|
|
|
@ -305,7 +305,7 @@ class Account extends Service {
|
||||||
/// first. Use the success and failure arguments to provide a redirect URL's
|
/// first. Use the success and failure arguments to provide a redirect URL's
|
||||||
/// back to your app when login is completed.
|
/// back to your app when login is completed.
|
||||||
///
|
///
|
||||||
Future createOAuth2Session({@required String provider, String success = 'https://localhost:2444/auth/oauth2/success', String failure = 'https://localhost:2444/auth/oauth2/failure'}) {
|
Future createOAuth2Session({@required String provider, String success = 'https://localhost/auth/oauth2/success', String failure = 'https://localhost/auth/oauth2/failure'}) {
|
||||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||||
|
|
||||||
final Map<String, dynamic> params = {
|
final Map<String, dynamic> params = {
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.CreateExecution("[FUNCTION_ID]", 0)
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/create-tag.md
Normal file
25
app/sdks/server-go/docs/examples/functions/create-tag.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.CreateTag("[FUNCTION_ID]", "node-14", "[COMMAND]", "[CODE]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/create.md
Normal file
25
app/sdks/server-go/docs/examples/functions/create.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.Create("[NAME]", , "event", [], "", 1)
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/delete-tag.md
Normal file
25
app/sdks/server-go/docs/examples/functions/delete-tag.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.DeleteTag("[FUNCTION_ID]", "[TAG_ID]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/delete.md
Normal file
25
app/sdks/server-go/docs/examples/functions/delete.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.Delete("[FUNCTION_ID]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/get-execution.md
Normal file
25
app/sdks/server-go/docs/examples/functions/get-execution.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.GetExecution("[FUNCTION_ID]", "[EXECUTION_ID]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/get-tag.md
Normal file
25
app/sdks/server-go/docs/examples/functions/get-tag.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.GetTag("[FUNCTION_ID]", "[TAG_ID]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/get.md
Normal file
25
app/sdks/server-go/docs/examples/functions/get.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.Get("[FUNCTION_ID]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.ListExecutions("[FUNCTION_ID]", "[SEARCH]", 0, 0, "ASC")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/list-tags.md
Normal file
25
app/sdks/server-go/docs/examples/functions/list-tags.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.ListTags("[FUNCTION_ID]", "[SEARCH]", 0, 0, "ASC")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/list.md
Normal file
25
app/sdks/server-go/docs/examples/functions/list.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.List("[SEARCH]", 0, 0, "ASC")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/update-active.md
Normal file
25
app/sdks/server-go/docs/examples/functions/update-active.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.UpdateActive("[FUNCTION_ID]", "[ACTIVE]")
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
25
app/sdks/server-go/docs/examples/functions/update.md
Normal file
25
app/sdks/server-go/docs/examples/functions/update.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Functions{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.Update("[FUNCTION_ID]", "[NAME]", , "event", [], "", 1)
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/appwrite/sdk-for-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var client := appwrite.Client{}
|
||||||
|
|
||||||
|
client.SetProject("5df5acd0d48c2") // Your project ID
|
||||||
|
client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
|
||||||
|
|
||||||
|
var service := appwrite.Health{
|
||||||
|
client: &client
|
||||||
|
}
|
||||||
|
|
||||||
|
var response, error := service.GetQueueFunctions()
|
||||||
|
|
||||||
|
if error != nil {
|
||||||
|
panic(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(response)
|
||||||
|
}
|
188
app/sdks/server-go/functions.go
Normal file
188
app/sdks/server-go/functions.go
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
package appwrite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Functions service
|
||||||
|
type Functions struct {
|
||||||
|
client Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFunctions(clt Client) Functions {
|
||||||
|
service := Functions{
|
||||||
|
client: clt,
|
||||||
|
}
|
||||||
|
|
||||||
|
return service
|
||||||
|
}
|
||||||
|
|
||||||
|
// List
|
||||||
|
func (srv *Functions) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) {
|
||||||
|
path := "/functions"
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"search": Search,
|
||||||
|
"limit": Limit,
|
||||||
|
"offset": Offset,
|
||||||
|
"orderType": OrderType,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create
|
||||||
|
func (srv *Functions) Create(Name string, Vars object, Trigger string, Events []interface{}, Schedule string, Timeout int) (map[string]interface{}, error) {
|
||||||
|
path := "/functions"
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"name": Name,
|
||||||
|
"vars": Vars,
|
||||||
|
"trigger": Trigger,
|
||||||
|
"events": Events,
|
||||||
|
"schedule": Schedule,
|
||||||
|
"timeout": Timeout,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("POST", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get
|
||||||
|
func (srv *Functions) Get(FunctionId string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
func (srv *Functions) Update(FunctionId string, Name string, Vars object, Trigger string, Events []interface{}, Schedule string, Timeout int) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"name": Name,
|
||||||
|
"vars": Vars,
|
||||||
|
"trigger": Trigger,
|
||||||
|
"events": Events,
|
||||||
|
"schedule": Schedule,
|
||||||
|
"timeout": Timeout,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("PUT", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
func (srv *Functions) Delete(FunctionId string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("DELETE", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateActive
|
||||||
|
func (srv *Functions) UpdateActive(FunctionId string, Active string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/active")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"active": Active,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("PATCH", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListExecutions
|
||||||
|
func (srv *Functions) ListExecutions(FunctionId string, Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/executions")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"search": Search,
|
||||||
|
"limit": Limit,
|
||||||
|
"offset": Offset,
|
||||||
|
"orderType": OrderType,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateExecution
|
||||||
|
func (srv *Functions) CreateExecution(FunctionId string, Async int) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/executions")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"async": Async,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("POST", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetExecution
|
||||||
|
func (srv *Functions) GetExecution(FunctionId string, ExecutionId string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId, "{executionId}", ExecutionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/executions/{executionId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTags
|
||||||
|
func (srv *Functions) ListTags(FunctionId string, Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/tags")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"search": Search,
|
||||||
|
"limit": Limit,
|
||||||
|
"offset": Offset,
|
||||||
|
"orderType": OrderType,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTag
|
||||||
|
func (srv *Functions) CreateTag(FunctionId string, Env string, Command string, Code string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId)
|
||||||
|
path := r.Replace("/functions/{functionId}/tags")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"env": Env,
|
||||||
|
"command": Command,
|
||||||
|
"code": Code,
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("POST", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTag
|
||||||
|
func (srv *Functions) GetTag(FunctionId string, TagId string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId, "{tagId}", TagId)
|
||||||
|
path := r.Replace("/functions/{functionId}/tags/{tagId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteTag
|
||||||
|
func (srv *Functions) DeleteTag(FunctionId string, TagId string) (map[string]interface{}, error) {
|
||||||
|
r := strings.NewReplacer("{functionId}", FunctionId, "{tagId}", TagId)
|
||||||
|
path := r.Replace("/functions/{functionId}/tags/{tagId}")
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("DELETE", path, nil, params)
|
||||||
|
}
|
|
@ -60,6 +60,16 @@ func (srv *Health) GetQueueCertificates() (map[string]interface{}, error) {
|
||||||
return srv.client.Call("GET", path, nil, params)
|
return srv.client.Call("GET", path, nil, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetQueueFunctions
|
||||||
|
func (srv *Health) GetQueueFunctions() (map[string]interface{}, error) {
|
||||||
|
path := "/health/queue/functions"
|
||||||
|
|
||||||
|
params := map[string]interface{}{
|
||||||
|
}
|
||||||
|
|
||||||
|
return srv.client.Call("GET", path, nil, params)
|
||||||
|
}
|
||||||
|
|
||||||
// GetQueueLogs get the number of logs that are waiting to be processed in the
|
// GetQueueLogs get the number of logs that are waiting to be processed in the
|
||||||
// Appwrite internal queue server.
|
// Appwrite internal queue server.
|
||||||
func (srv *Health) GetQueueLogs() (map[string]interface{}, error) {
|
func (srv *Health) GetQueueLogs() (map[string]interface{}, error) {
|
||||||
|
|
257
app/sdks/server-java/src/main/java/services/Functions.java
Normal file
257
app/sdks/server-java/src/main/java/services/Functions.java
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
package .services;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import okhttp3.Call;
|
||||||
|
import .Client;
|
||||||
|
import .enums.OrderType;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
|
public class Functions extends Service {
|
||||||
|
public Functions(Client client){
|
||||||
|
super(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List Functions
|
||||||
|
public Call list(String search, int limit, int offset, OrderType orderType) {
|
||||||
|
final String path = "/functions";
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("search", search),
|
||||||
|
entry("limit", limit),
|
||||||
|
entry("offset", offset),
|
||||||
|
entry("orderType", orderType.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create Function
|
||||||
|
public Call create(String name, Object vars, String trigger, List events, String schedule, int timeout) {
|
||||||
|
final String path = "/functions";
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("name", name),
|
||||||
|
entry("vars", vars),
|
||||||
|
entry("trigger", trigger),
|
||||||
|
entry("events", events),
|
||||||
|
entry("schedule", schedule),
|
||||||
|
entry("timeout", timeout)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("POST", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get Function
|
||||||
|
public Call get(String functionId) {
|
||||||
|
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update Function
|
||||||
|
public Call update(String functionId, String name, Object vars, String trigger, List events, String schedule, int timeout) {
|
||||||
|
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("name", name),
|
||||||
|
entry("vars", vars),
|
||||||
|
entry("trigger", trigger),
|
||||||
|
entry("events", events),
|
||||||
|
entry("schedule", schedule),
|
||||||
|
entry("timeout", timeout)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("PUT", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delete Function
|
||||||
|
public Call delete(String functionId) {
|
||||||
|
final String path = "/functions/{functionId}".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("DELETE", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Update Function Active Tag
|
||||||
|
public Call updateActive(String functionId, String active) {
|
||||||
|
final String path = "/functions/{functionId}/active".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("active", active)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("PATCH", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List Executions
|
||||||
|
public Call listExecutions(String functionId, String search, int limit, int offset, OrderType orderType) {
|
||||||
|
final String path = "/functions/{functionId}/executions".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("search", search),
|
||||||
|
entry("limit", limit),
|
||||||
|
entry("offset", offset),
|
||||||
|
entry("orderType", orderType.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create Execution
|
||||||
|
public Call createExecution(String functionId, int async) {
|
||||||
|
final String path = "/functions/{functionId}/executions".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("async", async)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("POST", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get Execution
|
||||||
|
public Call getExecution(String functionId, String executionId) {
|
||||||
|
final String path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// List Tags
|
||||||
|
public Call listTags(String functionId, String search, int limit, int offset, OrderType orderType) {
|
||||||
|
final String path = "/functions/{functionId}/tags".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("search", search),
|
||||||
|
entry("limit", limit),
|
||||||
|
entry("offset", offset),
|
||||||
|
entry("orderType", orderType.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create Tag
|
||||||
|
public Call createTag(String functionId, String env, String command, String code) {
|
||||||
|
final String path = "/functions/{functionId}/tags".replace("{functionId}", functionId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
entry("env", env),
|
||||||
|
entry("command", command),
|
||||||
|
entry("code", code)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("POST", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get Tag
|
||||||
|
public Call getTag(String functionId, String tagId) {
|
||||||
|
final String path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delete Tag
|
||||||
|
public Call deleteTag(String functionId, String tagId) {
|
||||||
|
final String path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId);
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("DELETE", path, headers, params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -90,6 +90,22 @@ public class Health extends Service {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
|
entry("content-type", "application/json")
|
||||||
|
);
|
||||||
|
|
||||||
|
return client.call("GET", path, headers, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check the number of pending functions messages
|
||||||
|
public Call getQueueFunctions() {
|
||||||
|
final String path = "/health/queue/functions";
|
||||||
|
|
||||||
|
final Map<String, Object> params = Map.ofEntries(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final Map<String, String> headers = Map.ofEntries(
|
final Map<String, String> headers = Map.ofEntries(
|
||||||
entry("content-type", "application/json")
|
entry("content-type", "application/json")
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.createExecution('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/create-tag.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/create-tag.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.createTag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/create.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/create.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.create('[NAME]', {}, 'event', [], '', 1);
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/delete-tag.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/delete-tag.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.deleteTag('[FUNCTION_ID]', '[TAG_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/delete.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/delete.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.delete('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/get-tag.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/get-tag.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.getTag('[FUNCTION_ID]', '[TAG_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/get.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/get.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.get('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.listExecutions('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/list-tags.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/list-tags.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.listTags('[FUNCTION_ID]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/list.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/list.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.list();
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.updateActive('[FUNCTION_ID]', '[ACTIVE]');
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
19
app/sdks/server-nodejs/docs/examples/functions/update.md
Normal file
19
app/sdks/server-nodejs/docs/examples/functions/update.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let functions = new sdk.Functions(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', [], '', 1);
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
|
@ -0,0 +1,19 @@
|
||||||
|
const sdk = require('node-appwrite');
|
||||||
|
|
||||||
|
// Init SDK
|
||||||
|
let client = new sdk.Client();
|
||||||
|
|
||||||
|
let health = new sdk.Health(client);
|
||||||
|
|
||||||
|
client
|
||||||
|
.setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
let promise = health.getQueueFunctions();
|
||||||
|
|
||||||
|
promise.then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}, function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
|
@ -1,6 +1,7 @@
|
||||||
const Client = require('./lib/client.js');
|
const Client = require('./lib/client.js');
|
||||||
const Avatars = require('./lib/services/avatars.js');
|
const Avatars = require('./lib/services/avatars.js');
|
||||||
const Database = require('./lib/services/database.js');
|
const Database = require('./lib/services/database.js');
|
||||||
|
const Functions = require('./lib/services/functions.js');
|
||||||
const Health = require('./lib/services/health.js');
|
const Health = require('./lib/services/health.js');
|
||||||
const Locale = require('./lib/services/locale.js');
|
const Locale = require('./lib/services/locale.js');
|
||||||
const Storage = require('./lib/services/storage.js');
|
const Storage = require('./lib/services/storage.js');
|
||||||
|
@ -11,6 +12,7 @@ module.exports = {
|
||||||
Client,
|
Client,
|
||||||
Avatars,
|
Avatars,
|
||||||
Database,
|
Database,
|
||||||
|
Functions,
|
||||||
Health,
|
Health,
|
||||||
Locale,
|
Locale,
|
||||||
Storage,
|
Storage,
|
||||||
|
|
286
app/sdks/server-nodejs/lib/services/functions.js
Normal file
286
app/sdks/server-nodejs/lib/services/functions.js
Normal file
|
@ -0,0 +1,286 @@
|
||||||
|
const Service = require('../service.js');
|
||||||
|
|
||||||
|
class Functions extends Service {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Functions
|
||||||
|
*
|
||||||
|
* @param string search
|
||||||
|
* @param number limit
|
||||||
|
* @param number offset
|
||||||
|
* @param string orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async list(search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
let path = '/functions';
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': orderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Function
|
||||||
|
*
|
||||||
|
* @param string name
|
||||||
|
* @param object vars
|
||||||
|
* @param string trigger
|
||||||
|
* @param string[] events
|
||||||
|
* @param string schedule
|
||||||
|
* @param number timeout
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async create(name, vars, trigger, events, schedule, timeout) {
|
||||||
|
let path = '/functions';
|
||||||
|
|
||||||
|
return await this.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': name,
|
||||||
|
'vars': vars,
|
||||||
|
'trigger': trigger,
|
||||||
|
'events': events,
|
||||||
|
'schedule': schedule,
|
||||||
|
'timeout': timeout
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Function
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async get(functionId) {
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string name
|
||||||
|
* @param object vars
|
||||||
|
* @param string trigger
|
||||||
|
* @param string[] events
|
||||||
|
* @param string schedule
|
||||||
|
* @param number timeout
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async update(functionId, name, vars, trigger, events, schedule, timeout) {
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('put', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': name,
|
||||||
|
'vars': vars,
|
||||||
|
'trigger': trigger,
|
||||||
|
'events': events,
|
||||||
|
'schedule': schedule,
|
||||||
|
'timeout': timeout
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Function
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async delete(functionId) {
|
||||||
|
let path = '/functions/{functionId}'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('delete', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function Active Tag
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string active
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async updateActive(functionId, active) {
|
||||||
|
let path = '/functions/{functionId}/active'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('patch', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'active': active
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Executions
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string search
|
||||||
|
* @param number limit
|
||||||
|
* @param number offset
|
||||||
|
* @param string orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async listExecutions(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': orderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Execution
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param number async
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async createExecution(functionId, async = 1) {
|
||||||
|
let path = '/functions/{functionId}/executions'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'async': async
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Execution
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string executionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async getExecution(functionId, executionId) {
|
||||||
|
let path = '/functions/{functionId}/executions/{executionId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{executionId}', 'g'), executionId);
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Tags
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string search
|
||||||
|
* @param number limit
|
||||||
|
* @param number offset
|
||||||
|
* @param string orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async listTags(functionId, search = '', limit = 25, offset = 0, orderType = 'ASC') {
|
||||||
|
let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': orderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Tag
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string env
|
||||||
|
* @param string command
|
||||||
|
* @param string code
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async createTag(functionId, env, command, code) {
|
||||||
|
let path = '/functions/{functionId}/tags'.replace(new RegExp('{functionId}', 'g'), functionId);
|
||||||
|
|
||||||
|
return await this.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'env': env,
|
||||||
|
'command': command,
|
||||||
|
'code': code
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Tag
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string tagId
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async getTag(functionId, tagId) {
|
||||||
|
let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId);
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Tag
|
||||||
|
*
|
||||||
|
* @param string functionId
|
||||||
|
* @param string tagId
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async deleteTag(functionId, tagId) {
|
||||||
|
let path = '/functions/{functionId}/tags/{tagId}'.replace(new RegExp('{functionId}', 'g'), functionId).replace(new RegExp('{tagId}', 'g'), tagId);
|
||||||
|
|
||||||
|
return await this.client.call('delete', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Functions;
|
|
@ -77,6 +77,22 @@ class Health extends Service {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the number of pending functions messages
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* @return {}
|
||||||
|
*/
|
||||||
|
async getQueueFunctions() {
|
||||||
|
let path = '/health/queue/functions';
|
||||||
|
|
||||||
|
return await this.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the number of pending log messages
|
* Check the number of pending log messages
|
||||||
*
|
*
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"support": {
|
"support": {
|
||||||
"url": "https://appwrite.io/support",
|
"url": "https://appwrite.io/support",
|
||||||
"email": "team@appwrite.io"
|
"email": "team@localhost.test"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->createExecution('[FUNCTION_ID]');
|
15
app/sdks/server-php/docs/examples/functions/create-tag.md
Normal file
15
app/sdks/server-php/docs/examples/functions/create-tag.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->createTag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]');
|
15
app/sdks/server-php/docs/examples/functions/create.md
Normal file
15
app/sdks/server-php/docs/examples/functions/create.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->create('[NAME]', [], 'event', [], '', 1);
|
15
app/sdks/server-php/docs/examples/functions/delete-tag.md
Normal file
15
app/sdks/server-php/docs/examples/functions/delete-tag.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->deleteTag('[FUNCTION_ID]', '[TAG_ID]');
|
15
app/sdks/server-php/docs/examples/functions/delete.md
Normal file
15
app/sdks/server-php/docs/examples/functions/delete.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->delete('[FUNCTION_ID]');
|
15
app/sdks/server-php/docs/examples/functions/get-execution.md
Normal file
15
app/sdks/server-php/docs/examples/functions/get-execution.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->getExecution('[FUNCTION_ID]', '[EXECUTION_ID]');
|
15
app/sdks/server-php/docs/examples/functions/get-tag.md
Normal file
15
app/sdks/server-php/docs/examples/functions/get-tag.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->getTag('[FUNCTION_ID]', '[TAG_ID]');
|
15
app/sdks/server-php/docs/examples/functions/get.md
Normal file
15
app/sdks/server-php/docs/examples/functions/get.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->get('[FUNCTION_ID]');
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->listExecutions('[FUNCTION_ID]');
|
15
app/sdks/server-php/docs/examples/functions/list-tags.md
Normal file
15
app/sdks/server-php/docs/examples/functions/list-tags.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->listTags('[FUNCTION_ID]');
|
15
app/sdks/server-php/docs/examples/functions/list.md
Normal file
15
app/sdks/server-php/docs/examples/functions/list.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->list();
|
15
app/sdks/server-php/docs/examples/functions/update-active.md
Normal file
15
app/sdks/server-php/docs/examples/functions/update-active.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->updateActive('[FUNCTION_ID]', '[ACTIVE]');
|
15
app/sdks/server-php/docs/examples/functions/update.md
Normal file
15
app/sdks/server-php/docs/examples/functions/update.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Functions;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$functions = new Functions($client);
|
||||||
|
|
||||||
|
$result = $functions->update('[FUNCTION_ID]', '[NAME]', [], 'event', [], '', 1);
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Services\Health;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
$client
|
||||||
|
->setProject('5df5acd0d48c2') // Your project ID
|
||||||
|
->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
|
||||||
|
;
|
||||||
|
|
||||||
|
$health = new Health($client);
|
||||||
|
|
||||||
|
$result = $health->getQueueFunctions();
|
188
app/sdks/server-php/docs/functions.md
Normal file
188
app/sdks/server-php/docs/functions.md
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
# Functions Service
|
||||||
|
|
||||||
|
## List Functions
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| search | string | Search term to filter your list results. | |
|
||||||
|
| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 |
|
||||||
|
| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 |
|
||||||
|
| orderType | string | Order result by ASC or DESC order. | ASC |
|
||||||
|
|
||||||
|
## Create Function
|
||||||
|
|
||||||
|
```http request
|
||||||
|
POST https://appwrite.io/v1/functions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| name | string | Function name. | |
|
||||||
|
| vars | object | Key-value JSON object. | |
|
||||||
|
| trigger | string | Function trigger type. | |
|
||||||
|
| events | array | Events list. | |
|
||||||
|
| schedule | string | Schedule CRON syntax. | |
|
||||||
|
| timeout | integer | Function maximum execution time in seconds. | |
|
||||||
|
|
||||||
|
## Get Function
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions/{functionId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
|
||||||
|
## Update Function
|
||||||
|
|
||||||
|
```http request
|
||||||
|
PUT https://appwrite.io/v1/functions/{functionId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| name | string | Function name. | |
|
||||||
|
| vars | object | Key-value JSON object. | |
|
||||||
|
| trigger | string | Function trigger type. | |
|
||||||
|
| events | array | Events list. | |
|
||||||
|
| schedule | string | Schedule CRON syntax. | |
|
||||||
|
| timeout | integer | Function maximum execution time in seconds. | |
|
||||||
|
|
||||||
|
## Delete Function
|
||||||
|
|
||||||
|
```http request
|
||||||
|
DELETE https://appwrite.io/v1/functions/{functionId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
|
||||||
|
## Update Function Active Tag
|
||||||
|
|
||||||
|
```http request
|
||||||
|
PATCH https://appwrite.io/v1/functions/{functionId}/active
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| active | string | Active tag unique ID. | |
|
||||||
|
|
||||||
|
## List Executions
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions/{functionId}/executions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| search | string | Search term to filter your list results. | |
|
||||||
|
| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 |
|
||||||
|
| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 |
|
||||||
|
| orderType | string | Order result by ASC or DESC order. | ASC |
|
||||||
|
|
||||||
|
## Create Execution
|
||||||
|
|
||||||
|
```http request
|
||||||
|
POST https://appwrite.io/v1/functions/{functionId}/executions
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| async | integer | Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1. | 1 |
|
||||||
|
|
||||||
|
## Get Execution
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions/{functionId}/executions/{executionId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| executionId | string | **Required** Execution unique ID. | |
|
||||||
|
|
||||||
|
## List Tags
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions/{functionId}/tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| search | string | Search term to filter your list results. | |
|
||||||
|
| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 |
|
||||||
|
| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 |
|
||||||
|
| orderType | string | Order result by ASC or DESC order. | ASC |
|
||||||
|
|
||||||
|
## Create Tag
|
||||||
|
|
||||||
|
```http request
|
||||||
|
POST https://appwrite.io/v1/functions/{functionId}/tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| env | string | Execution enviornment. | |
|
||||||
|
| command | string | Code execution command. | |
|
||||||
|
| code | string | Code package. Use the Appwrite code packager to create a deployable package file. | |
|
||||||
|
|
||||||
|
## Get Tag
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/functions/{functionId}/tags/{tagId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| tagId | string | **Required** Tag unique ID. | |
|
||||||
|
|
||||||
|
## Delete Tag
|
||||||
|
|
||||||
|
```http request
|
||||||
|
DELETE https://appwrite.io/v1/functions/{functionId}/tags/{tagId}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Field Name | Type | Description | Default |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| functionId | string | **Required** Function unique ID. | |
|
||||||
|
| tagId | string | **Required** Tag unique ID. | |
|
||||||
|
|
|
@ -32,6 +32,12 @@ GET https://appwrite.io/v1/health/queue/certificates
|
||||||
|
|
||||||
** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. **
|
** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. **
|
||||||
|
|
||||||
|
## Check the number of pending functions messages
|
||||||
|
|
||||||
|
```http request
|
||||||
|
GET https://appwrite.io/v1/health/queue/functions
|
||||||
|
```
|
||||||
|
|
||||||
## Check the number of pending log messages
|
## Check the number of pending log messages
|
||||||
|
|
||||||
```http request
|
```http request
|
||||||
|
|
304
app/sdks/server-php/src/Appwrite/Services/Functions.php
Normal file
304
app/sdks/server-php/src/Appwrite/Services/Functions.php
Normal file
|
@ -0,0 +1,304 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Services;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Appwrite\Client;
|
||||||
|
use Appwrite\Service;
|
||||||
|
|
||||||
|
class Functions extends Service
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* List Functions
|
||||||
|
*
|
||||||
|
* @param string $search
|
||||||
|
* @param int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @param string $orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function list(string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array
|
||||||
|
{
|
||||||
|
$path = str_replace([], [], '/functions');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['search'] = $search;
|
||||||
|
$params['limit'] = $limit;
|
||||||
|
$params['offset'] = $offset;
|
||||||
|
$params['orderType'] = $orderType;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Function
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param array $vars
|
||||||
|
* @param string $trigger
|
||||||
|
* @param array $events
|
||||||
|
* @param string $schedule
|
||||||
|
* @param int $timeout
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function create(string $name, array $vars, string $trigger, array $events, string $schedule, int $timeout):array
|
||||||
|
{
|
||||||
|
$path = str_replace([], [], '/functions');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['name'] = $name;
|
||||||
|
$params['vars'] = $vars;
|
||||||
|
$params['trigger'] = $trigger;
|
||||||
|
$params['events'] = $events;
|
||||||
|
$params['schedule'] = $schedule;
|
||||||
|
$params['timeout'] = $timeout;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_POST, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Function
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get(string $functionId):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $name
|
||||||
|
* @param array $vars
|
||||||
|
* @param string $trigger
|
||||||
|
* @param array $events
|
||||||
|
* @param string $schedule
|
||||||
|
* @param int $timeout
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function update(string $functionId, string $name, array $vars, string $trigger, array $events, string $schedule, int $timeout):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['name'] = $name;
|
||||||
|
$params['vars'] = $vars;
|
||||||
|
$params['trigger'] = $trigger;
|
||||||
|
$params['events'] = $events;
|
||||||
|
$params['schedule'] = $schedule;
|
||||||
|
$params['timeout'] = $timeout;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_PUT, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Function
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function delete(string $functionId):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_DELETE, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Function Active Tag
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $active
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function updateActive(string $functionId, string $active):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/active');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['active'] = $active;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_PATCH, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Executions
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $search
|
||||||
|
* @param int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @param string $orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function listExecutions(string $functionId, string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['search'] = $search;
|
||||||
|
$params['limit'] = $limit;
|
||||||
|
$params['offset'] = $offset;
|
||||||
|
$params['orderType'] = $orderType;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Execution
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param int $async
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function createExecution(string $functionId, int $async = 1):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/executions');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['async'] = $async;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_POST, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Execution
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $executionId
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getExecution(string $functionId, string $executionId):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}', '{executionId}'], [$functionId, $executionId], '/functions/{functionId}/executions/{executionId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List Tags
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $search
|
||||||
|
* @param int $limit
|
||||||
|
* @param int $offset
|
||||||
|
* @param string $orderType
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function listTags(string $functionId, string $search = '', int $limit = 25, int $offset = 0, string $orderType = 'ASC'):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/tags');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['search'] = $search;
|
||||||
|
$params['limit'] = $limit;
|
||||||
|
$params['offset'] = $offset;
|
||||||
|
$params['orderType'] = $orderType;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Tag
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $env
|
||||||
|
* @param string $command
|
||||||
|
* @param string $code
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function createTag(string $functionId, string $env, string $command, string $code):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}'], [$functionId], '/functions/{functionId}/tags');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
$params['env'] = $env;
|
||||||
|
$params['command'] = $command;
|
||||||
|
$params['code'] = $code;
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_POST, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Tag
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $tagId
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTag(string $functionId, string $tagId):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}', '{tagId}'], [$functionId, $tagId], '/functions/{functionId}/tags/{tagId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Tag
|
||||||
|
*
|
||||||
|
* @param string $functionId
|
||||||
|
* @param string $tagId
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function deleteTag(string $functionId, string $tagId):array
|
||||||
|
{
|
||||||
|
$path = str_replace(['{functionId}', '{tagId}'], [$functionId, $tagId], '/functions/{functionId}/tags/{tagId}');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_DELETE, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -87,6 +87,23 @@ class Health extends Service
|
||||||
], $params);
|
], $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the number of pending functions messages
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getQueueFunctions():array
|
||||||
|
{
|
||||||
|
$path = str_replace([], [], '/health/queue/functions');
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
|
||||||
|
return $this->client->call(Client::METHOD_GET, $path, [
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
], $params);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the number of pending log messages
|
* Check the number of pending log messages
|
||||||
*
|
*
|
||||||
|
|
180
app/sdks/server-python/appwrite/services/functions.py
Normal file
180
app/sdks/server-python/appwrite/services/functions.py
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
from ..service import Service
|
||||||
|
|
||||||
|
|
||||||
|
class Functions(Service):
|
||||||
|
|
||||||
|
def __init__(self, client):
|
||||||
|
super(Functions, self).__init__(client)
|
||||||
|
|
||||||
|
def list(self, search='', limit=25, offset=0, order_type='ASC'):
|
||||||
|
"""List Functions"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions'
|
||||||
|
params['search'] = search
|
||||||
|
params['limit'] = limit
|
||||||
|
params['offset'] = offset
|
||||||
|
params['orderType'] = order_type
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def create(self, name, vars, trigger, events, schedule, timeout):
|
||||||
|
"""Create Function"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions'
|
||||||
|
params['name'] = name
|
||||||
|
params['vars'] = vars
|
||||||
|
params['trigger'] = trigger
|
||||||
|
params['events'] = events
|
||||||
|
params['schedule'] = schedule
|
||||||
|
params['timeout'] = timeout
|
||||||
|
|
||||||
|
return self.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def get(self, function_id):
|
||||||
|
"""Get Function"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def update(self, function_id, name, vars, trigger, events, schedule, timeout):
|
||||||
|
"""Update Function"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['name'] = name
|
||||||
|
params['vars'] = vars
|
||||||
|
params['trigger'] = trigger
|
||||||
|
params['events'] = events
|
||||||
|
params['schedule'] = schedule
|
||||||
|
params['timeout'] = timeout
|
||||||
|
|
||||||
|
return self.client.call('put', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def delete(self, function_id):
|
||||||
|
"""Delete Function"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
|
||||||
|
return self.client.call('delete', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def update_active(self, function_id, active):
|
||||||
|
"""Update Function Active Tag"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/active'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['active'] = active
|
||||||
|
|
||||||
|
return self.client.call('patch', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def list_executions(self, function_id, search='', limit=25, offset=0, order_type='ASC'):
|
||||||
|
"""List Executions"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/executions'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['search'] = search
|
||||||
|
params['limit'] = limit
|
||||||
|
params['offset'] = offset
|
||||||
|
params['orderType'] = order_type
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def create_execution(self, function_id, async=1):
|
||||||
|
"""Create Execution"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/executions'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['async'] = async
|
||||||
|
|
||||||
|
return self.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def get_execution(self, function_id, execution_id):
|
||||||
|
"""Get Execution"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/executions/{executionId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
path = path.replace('{executionId}', execution_id)
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def list_tags(self, function_id, search='', limit=25, offset=0, order_type='ASC'):
|
||||||
|
"""List Tags"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/tags'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['search'] = search
|
||||||
|
params['limit'] = limit
|
||||||
|
params['offset'] = offset
|
||||||
|
params['orderType'] = order_type
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def create_tag(self, function_id, env, command, code):
|
||||||
|
"""Create Tag"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/tags'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
params['env'] = env
|
||||||
|
params['command'] = command
|
||||||
|
params['code'] = code
|
||||||
|
|
||||||
|
return self.client.call('post', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def get_tag(self, function_id, tag_id):
|
||||||
|
"""Get Tag"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/tags/{tagId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
path = path.replace('{tagId}', tag_id)
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
|
def delete_tag(self, function_id, tag_id):
|
||||||
|
"""Delete Tag"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/functions/{functionId}/tags/{tagId}'
|
||||||
|
path = path.replace('{functionId}', function_id)
|
||||||
|
path = path.replace('{tagId}', tag_id)
|
||||||
|
|
||||||
|
return self.client.call('delete', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
|
@ -46,6 +46,16 @@ class Health(Service):
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
}, params)
|
}, params)
|
||||||
|
|
||||||
|
def get_queue_functions(self):
|
||||||
|
"""Check the number of pending functions messages"""
|
||||||
|
|
||||||
|
params = {}
|
||||||
|
path = '/health/queue/functions'
|
||||||
|
|
||||||
|
return self.client.call('get', path, {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
}, params)
|
||||||
|
|
||||||
def get_queue_logs(self):
|
def get_queue_logs(self):
|
||||||
"""Check the number of pending log messages"""
|
"""Check the number of pending log messages"""
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.create_execution('[FUNCTION_ID]')
|
13
app/sdks/server-python/docs/examples/functions/create-tag.md
Normal file
13
app/sdks/server-python/docs/examples/functions/create-tag.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.create_tag('[FUNCTION_ID]', 'node-14', '[COMMAND]', '[CODE]')
|
13
app/sdks/server-python/docs/examples/functions/create.md
Normal file
13
app/sdks/server-python/docs/examples/functions/create.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.create('[NAME]', {}, 'event', {}, '', 1)
|
13
app/sdks/server-python/docs/examples/functions/delete-tag.md
Normal file
13
app/sdks/server-python/docs/examples/functions/delete-tag.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.delete_tag('[FUNCTION_ID]', '[TAG_ID]')
|
13
app/sdks/server-python/docs/examples/functions/delete.md
Normal file
13
app/sdks/server-python/docs/examples/functions/delete.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.delete('[FUNCTION_ID]')
|
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.get_execution('[FUNCTION_ID]', '[EXECUTION_ID]')
|
13
app/sdks/server-python/docs/examples/functions/get-tag.md
Normal file
13
app/sdks/server-python/docs/examples/functions/get-tag.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.get_tag('[FUNCTION_ID]', '[TAG_ID]')
|
13
app/sdks/server-python/docs/examples/functions/get.md
Normal file
13
app/sdks/server-python/docs/examples/functions/get.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.get('[FUNCTION_ID]')
|
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.list_executions('[FUNCTION_ID]')
|
13
app/sdks/server-python/docs/examples/functions/list-tags.md
Normal file
13
app/sdks/server-python/docs/examples/functions/list-tags.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.list_tags('[FUNCTION_ID]')
|
13
app/sdks/server-python/docs/examples/functions/list.md
Normal file
13
app/sdks/server-python/docs/examples/functions/list.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.list()
|
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.update_active('[FUNCTION_ID]', '[ACTIVE]')
|
13
app/sdks/server-python/docs/examples/functions/update.md
Normal file
13
app/sdks/server-python/docs/examples/functions/update.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.functions import Functions
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
functions = Functions(client)
|
||||||
|
|
||||||
|
result = functions.update('[FUNCTION_ID]', '[NAME]', {}, 'event', {}, '', 1)
|
|
@ -0,0 +1,13 @@
|
||||||
|
from appwrite.client import Client
|
||||||
|
from appwrite.services.health import Health
|
||||||
|
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
(client
|
||||||
|
.set_project('5df5acd0d48c2') # Your project ID
|
||||||
|
.set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
|
||||||
|
)
|
||||||
|
|
||||||
|
health = Health(client)
|
||||||
|
|
||||||
|
result = health.get_queue_functions()
|
|
@ -7,9 +7,9 @@ setuptools.setup(
|
||||||
license='BSD-3-Clause',
|
license='BSD-3-Clause',
|
||||||
description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API',
|
description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API',
|
||||||
author = 'Appwrite Team',
|
author = 'Appwrite Team',
|
||||||
author_email = 'team@appwrite.io',
|
author_email = 'team@localhost.test',
|
||||||
maintainer = 'Appwrite Team',
|
maintainer = 'Appwrite Team',
|
||||||
maintainer_email = 'team@appwrite.io',
|
maintainer_email = 'team@localhost.test',
|
||||||
url = 'https://appwrite.io/support',
|
url = 'https://appwrite.io/support',
|
||||||
download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.4.tar.gz',
|
download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.4.tar.gz',
|
||||||
# keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'],
|
# keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'],
|
||||||
|
|
|
@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
||||||
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)"
|
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)"
|
||||||
s.author = 'Appwrite Team'
|
s.author = 'Appwrite Team'
|
||||||
s.homepage = 'https://appwrite.io/support'
|
s.homepage = 'https://appwrite.io/support'
|
||||||
s.email = 'team@appwrite.io'
|
s.email = 'team@localhost.test'
|
||||||
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
||||||
|
|
||||||
end
|
end
|
|
@ -5,6 +5,7 @@ require_relative 'appwrite/client'
|
||||||
require_relative 'appwrite/service'
|
require_relative 'appwrite/service'
|
||||||
require_relative 'appwrite/services/avatars'
|
require_relative 'appwrite/services/avatars'
|
||||||
require_relative 'appwrite/services/database'
|
require_relative 'appwrite/services/database'
|
||||||
|
require_relative 'appwrite/services/functions'
|
||||||
require_relative 'appwrite/services/health'
|
require_relative 'appwrite/services/health'
|
||||||
require_relative 'appwrite/services/locale'
|
require_relative 'appwrite/services/locale'
|
||||||
require_relative 'appwrite/services/storage'
|
require_relative 'appwrite/services/storage'
|
||||||
|
|
195
app/sdks/server-ruby/lib/appwrite/services/functions.rb
Normal file
195
app/sdks/server-ruby/lib/appwrite/services/functions.rb
Normal file
|
@ -0,0 +1,195 @@
|
||||||
|
module Appwrite
|
||||||
|
class Functions < Service
|
||||||
|
|
||||||
|
def list(search: '', limit: 25, offset: 0, order_type: 'ASC')
|
||||||
|
path = '/functions'
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': order_type
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(name:, vars:, trigger:, events:, schedule:, timeout:)
|
||||||
|
path = '/functions'
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'name': name,
|
||||||
|
'vars': vars,
|
||||||
|
'trigger': trigger,
|
||||||
|
'events': events,
|
||||||
|
'schedule': schedule,
|
||||||
|
'timeout': timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('post', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(function_id:)
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(function_id:, name:, vars:, trigger:, events:, schedule:, timeout:)
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'name': name,
|
||||||
|
'vars': vars,
|
||||||
|
'trigger': trigger,
|
||||||
|
'events': events,
|
||||||
|
'schedule': schedule,
|
||||||
|
'timeout': timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('put', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(function_id:)
|
||||||
|
path = '/functions/{functionId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('delete', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_active(function_id:, active:)
|
||||||
|
path = '/functions/{functionId}/active'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'active': active
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('patch', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def list_executions(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC')
|
||||||
|
path = '/functions/{functionId}/executions'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': order_type
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_execution(function_id:, async: 1)
|
||||||
|
path = '/functions/{functionId}/executions'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'async': async
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('post', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_execution(function_id:, execution_id:)
|
||||||
|
path = '/functions/{functionId}/executions/{executionId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
.gsub('{execution_id}', execution_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def list_tags(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC')
|
||||||
|
path = '/functions/{functionId}/tags'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'search': search,
|
||||||
|
'limit': limit,
|
||||||
|
'offset': offset,
|
||||||
|
'orderType': order_type
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_tag(function_id:, env:, command:, code:)
|
||||||
|
path = '/functions/{functionId}/tags'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'env': env,
|
||||||
|
'command': command,
|
||||||
|
'code': code
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('post', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_tag(function_id:, tag_id:)
|
||||||
|
path = '/functions/{functionId}/tags/{tagId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
.gsub('{tag_id}', tag_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_tag(function_id:, tag_id:)
|
||||||
|
path = '/functions/{functionId}/tags/{tagId}'
|
||||||
|
.gsub('{function_id}', function_id)
|
||||||
|
.gsub('{tag_id}', tag_id)
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('delete', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
private
|
||||||
|
end
|
||||||
|
end
|
|
@ -45,6 +45,17 @@ module Appwrite
|
||||||
}, params);
|
}, params);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_queue_functions()
|
||||||
|
path = '/health/queue/functions'
|
||||||
|
|
||||||
|
params = {
|
||||||
|
}
|
||||||
|
|
||||||
|
return @client.call('get', path, {
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
}, params);
|
||||||
|
end
|
||||||
|
|
||||||
def get_queue_logs()
|
def get_queue_logs()
|
||||||
path = '/health/queue/logs'
|
path = '/health/queue/logs'
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,7 @@
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
createOAuth2Session: function(provider, success = 'https://localhost:2444/auth/oauth2/success', failure = 'https://localhost:2444/auth/oauth2/failure') {
|
createOAuth2Session: function(provider, success = 'https://localhost/auth/oauth2/success', failure = 'https://localhost/auth/oauth2/failure') {
|
||||||
if(provider === undefined) {
|
if(provider === undefined) {
|
||||||
throw new Error('Missing required parameter: "provider"');
|
throw new Error('Missing required parameter: "provider"');
|
||||||
}
|
}
|
||||||
|
|
2
app/sdks/web-javascript/src/sdk.min.js
vendored
2
app/sdks/web-javascript/src/sdk.min.js
vendored
|
@ -45,7 +45,7 @@ return http.put(path,{'content-type':'application/json',},payload)},getSessions:
|
||||||
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
if(password===undefined){throw new Error('Missing required parameter: "password"')}
|
||||||
let path='/account/sessions';let payload={};if(email){payload.email=email}
|
let path='/account/sessions';let payload={};if(email){payload.email=email}
|
||||||
if(password){payload.password=password}
|
if(password){payload.password=password}
|
||||||
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://localhost:2444/auth/oauth2/success',failure='https://localhost:2444/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
return http.post(path,{'content-type':'application/json',},payload)},deleteSessions:function(){let path='/account/sessions';let payload={};return http.delete(path,{'content-type':'application/json',},payload)},createOAuth2Session:function(provider,success='https://localhost/auth/oauth2/success',failure='https://localhost/auth/oauth2/failure'){if(provider===undefined){throw new Error('Missing required parameter: "provider"')}
|
||||||
let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success}
|
let path='/account/sessions/oauth2/{provider}'.replace(new RegExp('{provider}','g'),provider);let payload={};if(success){payload.success=success}
|
||||||
if(failure){payload.failure=failure}
|
if(failure){payload.failure=failure}
|
||||||
payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')}
|
payload.project=config.project;let query=Object.keys(payload).map(key=>key+'='+encodeURIComponent(payload[key])).join('&');window.location=config.endpoint+path+((query)?'?'+query:'')},deleteSession:function(sessionId){if(sessionId===undefined){throw new Error('Missing required parameter: "sessionId"')}
|
||||||
|
|
|
@ -55,8 +55,8 @@ $cli
|
||||||
Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name']);
|
Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name']);
|
||||||
|
|
||||||
//$spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']);
|
//$spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']);
|
||||||
$spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform='.$language['family']);
|
$spec = getSSLPage('https://appwrite.io/open-api-2.json?extensions=1&platform='.$language['family']);
|
||||||
$spec = getSSLPage('https://localhost:2444/v1/open-api-2.json?extensions=1&platform='.$language['family']);
|
$spec = getSSLPage('https://localhost/open-api-2.json?extensions=1&platform='.$language['family']);
|
||||||
|
|
||||||
$result = realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key'];
|
$result = realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key'];
|
||||||
$target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/';
|
$target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/';
|
||||||
|
|
Loading…
Reference in a new issue