From c2975c91776f4bd1dbf79703faa3290e7270b7e7 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 10 May 2020 23:13:51 +0300 Subject: [PATCH] Updated SDKs --- app/controllers/web/home.php | 409 +++++++++++++ .../examples/functions/create-execution.md | 14 + .../docs/examples/functions/create-tag.md | 14 + .../docs/examples/functions/create.md | 14 + .../docs/examples/functions/delete-tag.md | 14 + .../docs/examples/functions/delete.md | 14 + .../docs/examples/functions/get-execution.md | 14 + .../docs/examples/functions/get-tag.md | 14 + .../docs/examples/functions/get.md | 14 + .../examples/functions/list-executions.md | 14 + .../docs/examples/functions/list-tags.md | 14 + .../docs/examples/functions/list.md | 14 + .../docs/examples/functions/update-active.md | 14 + .../docs/examples/functions/update.md | 14 + .../examples/health/get-queue-functions.md | 14 + app/sdks/console-javascript/src/sdk.js | 537 +++++++++++++++++- app/sdks/console-javascript/src/sdk.min.js | 65 ++- app/sdks/console-javascript/types/index.d.ts | 174 ++++++ .../flutter-dart/lib/services/account.dart | 2 +- .../examples/functions/create-execution.md | 25 + .../docs/examples/functions/create-tag.md | 25 + .../docs/examples/functions/create.md | 25 + .../docs/examples/functions/delete-tag.md | 25 + .../docs/examples/functions/delete.md | 25 + .../docs/examples/functions/get-execution.md | 25 + .../docs/examples/functions/get-tag.md | 25 + .../server-go/docs/examples/functions/get.md | 25 + .../examples/functions/list-executions.md | 25 + .../docs/examples/functions/list-tags.md | 25 + .../server-go/docs/examples/functions/list.md | 25 + .../docs/examples/functions/update-active.md | 25 + .../docs/examples/functions/update.md | 25 + .../examples/health/get-queue-functions.md | 25 + app/sdks/server-go/functions.go | 188 ++++++ app/sdks/server-go/health.go | 10 + .../src/main/java/services/Functions.java | 257 +++++++++ .../src/main/java/services/Health.java | 16 + .../examples/functions/create-execution.md | 19 + .../docs/examples/functions/create-tag.md | 19 + .../docs/examples/functions/create.md | 19 + .../docs/examples/functions/delete-tag.md | 19 + .../docs/examples/functions/delete.md | 19 + .../docs/examples/functions/get-execution.md | 19 + .../docs/examples/functions/get-tag.md | 19 + .../docs/examples/functions/get.md | 19 + .../examples/functions/list-executions.md | 19 + .../docs/examples/functions/list-tags.md | 19 + .../docs/examples/functions/list.md | 19 + .../docs/examples/functions/update-active.md | 19 + .../docs/examples/functions/update.md | 19 + .../examples/health/get-queue-functions.md | 19 + app/sdks/server-nodejs/index.js | 2 + .../server-nodejs/lib/services/functions.js | 286 ++++++++++ app/sdks/server-nodejs/lib/services/health.js | 16 + app/sdks/server-php/composer.json | 2 +- .../examples/functions/create-execution.md | 15 + .../docs/examples/functions/create-tag.md | 15 + .../docs/examples/functions/create.md | 15 + .../docs/examples/functions/delete-tag.md | 15 + .../docs/examples/functions/delete.md | 15 + .../docs/examples/functions/get-execution.md | 15 + .../docs/examples/functions/get-tag.md | 15 + .../server-php/docs/examples/functions/get.md | 15 + .../examples/functions/list-executions.md | 15 + .../docs/examples/functions/list-tags.md | 15 + .../docs/examples/functions/list.md | 15 + .../docs/examples/functions/update-active.md | 15 + .../docs/examples/functions/update.md | 15 + .../examples/health/get-queue-functions.md | 15 + app/sdks/server-php/docs/functions.md | 188 ++++++ app/sdks/server-php/docs/health.md | 6 + .../src/Appwrite/Services/Functions.php | 304 ++++++++++ .../src/Appwrite/Services/Health.php | 17 + .../appwrite/services/functions.py | 180 ++++++ .../server-python/appwrite/services/health.py | 10 + .../examples/functions/create-execution.md | 13 + .../docs/examples/functions/create-tag.md | 13 + .../docs/examples/functions/create.md | 13 + .../docs/examples/functions/delete-tag.md | 13 + .../docs/examples/functions/delete.md | 13 + .../docs/examples/functions/get-execution.md | 13 + .../docs/examples/functions/get-tag.md | 13 + .../docs/examples/functions/get.md | 13 + .../examples/functions/list-executions.md | 13 + .../docs/examples/functions/list-tags.md | 13 + .../docs/examples/functions/list.md | 13 + .../docs/examples/functions/update-active.md | 13 + .../docs/examples/functions/update.md | 13 + .../examples/health/get-queue-functions.md | 13 + app/sdks/server-python/setup.py | 4 +- app/sdks/server-ruby/appwrite.gemspec | 2 +- app/sdks/server-ruby/lib/appwrite.rb | 1 + .../lib/appwrite/services/functions.rb | 195 +++++++ .../lib/appwrite/services/health.rb | 11 + app/sdks/web-javascript/src/sdk.js | 2 +- app/sdks/web-javascript/src/sdk.min.js | 2 +- app/tasks/sdks.php | 4 +- 97 files changed, 4081 insertions(+), 13 deletions(-) create mode 100644 app/sdks/console-javascript/docs/examples/functions/create-execution.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/create-tag.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/create.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/delete-tag.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/delete.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/get-execution.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/get-tag.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/get.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/list-executions.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/list-tags.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/list.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/update-active.md create mode 100644 app/sdks/console-javascript/docs/examples/functions/update.md create mode 100644 app/sdks/console-javascript/docs/examples/health/get-queue-functions.md create mode 100644 app/sdks/server-go/docs/examples/functions/create-execution.md create mode 100644 app/sdks/server-go/docs/examples/functions/create-tag.md create mode 100644 app/sdks/server-go/docs/examples/functions/create.md create mode 100644 app/sdks/server-go/docs/examples/functions/delete-tag.md create mode 100644 app/sdks/server-go/docs/examples/functions/delete.md create mode 100644 app/sdks/server-go/docs/examples/functions/get-execution.md create mode 100644 app/sdks/server-go/docs/examples/functions/get-tag.md create mode 100644 app/sdks/server-go/docs/examples/functions/get.md create mode 100644 app/sdks/server-go/docs/examples/functions/list-executions.md create mode 100644 app/sdks/server-go/docs/examples/functions/list-tags.md create mode 100644 app/sdks/server-go/docs/examples/functions/list.md create mode 100644 app/sdks/server-go/docs/examples/functions/update-active.md create mode 100644 app/sdks/server-go/docs/examples/functions/update.md create mode 100644 app/sdks/server-go/docs/examples/health/get-queue-functions.md create mode 100644 app/sdks/server-go/functions.go create mode 100644 app/sdks/server-java/src/main/java/services/Functions.java create mode 100644 app/sdks/server-nodejs/docs/examples/functions/create-execution.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/create-tag.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/create.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/delete-tag.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/delete.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/get-execution.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/get-tag.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/get.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/list-executions.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/list-tags.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/list.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/update-active.md create mode 100644 app/sdks/server-nodejs/docs/examples/functions/update.md create mode 100644 app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md create mode 100644 app/sdks/server-nodejs/lib/services/functions.js create mode 100644 app/sdks/server-php/docs/examples/functions/create-execution.md create mode 100644 app/sdks/server-php/docs/examples/functions/create-tag.md create mode 100644 app/sdks/server-php/docs/examples/functions/create.md create mode 100644 app/sdks/server-php/docs/examples/functions/delete-tag.md create mode 100644 app/sdks/server-php/docs/examples/functions/delete.md create mode 100644 app/sdks/server-php/docs/examples/functions/get-execution.md create mode 100644 app/sdks/server-php/docs/examples/functions/get-tag.md create mode 100644 app/sdks/server-php/docs/examples/functions/get.md create mode 100644 app/sdks/server-php/docs/examples/functions/list-executions.md create mode 100644 app/sdks/server-php/docs/examples/functions/list-tags.md create mode 100644 app/sdks/server-php/docs/examples/functions/list.md create mode 100644 app/sdks/server-php/docs/examples/functions/update-active.md create mode 100644 app/sdks/server-php/docs/examples/functions/update.md create mode 100644 app/sdks/server-php/docs/examples/health/get-queue-functions.md create mode 100644 app/sdks/server-php/docs/functions.md create mode 100644 app/sdks/server-php/src/Appwrite/Services/Functions.php create mode 100644 app/sdks/server-python/appwrite/services/functions.py create mode 100644 app/sdks/server-python/docs/examples/functions/create-execution.md create mode 100644 app/sdks/server-python/docs/examples/functions/create-tag.md create mode 100644 app/sdks/server-python/docs/examples/functions/create.md create mode 100644 app/sdks/server-python/docs/examples/functions/delete-tag.md create mode 100644 app/sdks/server-python/docs/examples/functions/delete.md create mode 100644 app/sdks/server-python/docs/examples/functions/get-execution.md create mode 100644 app/sdks/server-python/docs/examples/functions/get-tag.md create mode 100644 app/sdks/server-python/docs/examples/functions/get.md create mode 100644 app/sdks/server-python/docs/examples/functions/list-executions.md create mode 100644 app/sdks/server-python/docs/examples/functions/list-tags.md create mode 100644 app/sdks/server-python/docs/examples/functions/list.md create mode 100644 app/sdks/server-python/docs/examples/functions/update-active.md create mode 100644 app/sdks/server-python/docs/examples/functions/update.md create mode 100644 app/sdks/server-python/docs/examples/health/get-queue-functions.md create mode 100644 app/sdks/server-ruby/lib/appwrite/services/functions.rb diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 0871e8c25..5ea8178be 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -6,6 +6,8 @@ global $utopia, $response, $request, $layout; use Utopia\View; use Utopia\Config\Config; +use Utopia\Validator\WhiteList; +use Utopia\Validator\Range; $header = new View(__DIR__.'/../../views/home/comps/header.phtml'); $footer = new View(__DIR__.'/../../views/home/comps/footer.phtml'); @@ -155,3 +157,410 @@ $utopia->get('/error/:code') ->setParam('title', 'Error'.' - '.APP_NAME) ->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); + } + ); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/create-execution.md b/app/sdks/console-javascript/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..24e0107f5 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/create-execution.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/create-tag.md b/app/sdks/console-javascript/docs/examples/functions/create-tag.md new file mode 100644 index 000000000..ec3697a29 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/create-tag.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/create.md b/app/sdks/console-javascript/docs/examples/functions/create.md new file mode 100644 index 000000000..b653b756f --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/create.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/delete-tag.md b/app/sdks/console-javascript/docs/examples/functions/delete-tag.md new file mode 100644 index 000000000..abd070deb --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/delete-tag.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/delete.md b/app/sdks/console-javascript/docs/examples/functions/delete.md new file mode 100644 index 000000000..9184c2bdd --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/delete.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/get-execution.md b/app/sdks/console-javascript/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..e192dbdae --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/get-execution.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/get-tag.md b/app/sdks/console-javascript/docs/examples/functions/get-tag.md new file mode 100644 index 000000000..b4632b6c8 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/get-tag.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/get.md b/app/sdks/console-javascript/docs/examples/functions/get.md new file mode 100644 index 000000000..f2ac11f0a --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/get.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/list-executions.md b/app/sdks/console-javascript/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..0ff49f737 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/list-executions.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/list-tags.md b/app/sdks/console-javascript/docs/examples/functions/list-tags.md new file mode 100644 index 000000000..2123a5251 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/list-tags.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/list.md b/app/sdks/console-javascript/docs/examples/functions/list.md new file mode 100644 index 000000000..a225c1541 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/list.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/update-active.md b/app/sdks/console-javascript/docs/examples/functions/update-active.md new file mode 100644 index 000000000..eed2be885 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/update-active.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/functions/update.md b/app/sdks/console-javascript/docs/examples/functions/update.md new file mode 100644 index 000000000..0dc7359b6 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/functions/update.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/docs/examples/health/get-queue-functions.md b/app/sdks/console-javascript/docs/examples/health/get-queue-functions.md new file mode 100644 index 000000000..6cbfbc342 --- /dev/null +++ b/app/sdks/console-javascript/docs/examples/health/get-queue-functions.md @@ -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 +}); \ No newline at end of file diff --git a/app/sdks/console-javascript/src/sdk.js b/app/sdks/console-javascript/src/sdk.js index 1379f8ced..a9785ee7f 100644 --- a/app/sdks/console-javascript/src/sdk.js +++ b/app/sdks/console-javascript/src/sdk.js @@ -748,7 +748,7 @@ * @throws {Error} * @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) { 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 = { /** @@ -1687,6 +2203,24 @@ }, 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 * @@ -4194,6 +4728,7 @@ account: account, avatars: avatars, database: database, + functions: functions, health: health, locale: locale, projects: projects, diff --git a/app/sdks/console-javascript/src/sdk.min.js b/app/sdks/console-javascript/src/sdk.min.js index 0023277bf..a031def76 100644 --- a/app/sdks/console-javascript/src/sdk.min.js +++ b/app/sdks/console-javascript/src/sdk.min.js @@ -45,7 +45,7 @@ return http.put(path,{'content-type':'application/json',},payload)},getSessions: if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account/sessions';let payload={};if(email){payload.email=email} 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} 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"')} @@ -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"')} 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}/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"')} let path='/projects';let payload={};if(name){payload.name=name} 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"')} 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} -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:{}) \ No newline at end of file +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:{}) \ No newline at end of file diff --git a/app/sdks/console-javascript/types/index.d.ts b/app/sdks/console-javascript/types/index.d.ts index 5416bcd5a..6d4c8cedf 100644 --- a/app/sdks/console-javascript/types/index.d.ts +++ b/app/sdks/console-javascript/types/index.d.ts @@ -57,6 +57,7 @@ declare class Appwrite { account:Appwrite.Account; avatars:Appwrite.Avatars; database:Appwrite.Database; + functions:Appwrite.Functions; health:Appwrite.Health; locale:Appwrite.Locale; 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; + + /** + * 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; + + /** + * Get Function + * + * + * @param {string} functionId + * @throws {Error} + * @return {Promise} + */ + get(functionId: string): Promise; + + /** + * 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; + + /** + * Delete Function + * + * + * @param {string} functionId + * @throws {Error} + * @return {Promise} + */ + delete(functionId: string): Promise; + + /** + * Update Function Active Tag + * + * + * @param {string} functionId + * @param {string} active + * @throws {Error} + * @return {Promise} + */ + updateActive(functionId: string, active: string): Promise; + + /** + * 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; + + /** + * Create Execution + * + * + * @param {string} functionId + * @param {number} async + * @throws {Error} + * @return {Promise} + */ + createExecution(functionId: string, async: number): Promise; + + /** + * Get Execution + * + * + * @param {string} functionId + * @param {string} executionId + * @throws {Error} + * @return {Promise} + */ + getExecution(functionId: string, executionId: string): Promise; + + /** + * 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; + + /** + * 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; + + /** + * Get Tag + * + * + * @param {string} functionId + * @param {string} tagId + * @throws {Error} + * @return {Promise} + */ + getTag(functionId: string, tagId: string): Promise; + + /** + * Delete Tag + * + * + * @param {string} functionId + * @param {string} tagId + * @throws {Error} + * @return {Promise} + */ + deleteTag(functionId: string, tagId: string): Promise; + + } + export interface Health { /** @@ -634,6 +799,15 @@ declare namespace Appwrite { */ getQueueCertificates(): Promise; + /** + * Check the number of pending functions messages + * + * + * @throws {Error} + * @return {Promise} + */ + getQueueFunctions(): Promise; + /** * Check the number of pending log messages * diff --git a/app/sdks/flutter-dart/lib/services/account.dart b/app/sdks/flutter-dart/lib/services/account.dart index 92951ce5c..21401240e 100644 --- a/app/sdks/flutter-dart/lib/services/account.dart +++ b/app/sdks/flutter-dart/lib/services/account.dart @@ -305,7 +305,7 @@ class Account extends Service { /// first. Use the success and failure arguments to provide a redirect URL's /// 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 Map params = { diff --git a/app/sdks/server-go/docs/examples/functions/create-execution.md b/app/sdks/server-go/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..ea060d6f7 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/create-execution.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/create-tag.md b/app/sdks/server-go/docs/examples/functions/create-tag.md new file mode 100644 index 000000000..84d5e8078 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/create-tag.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/create.md b/app/sdks/server-go/docs/examples/functions/create.md new file mode 100644 index 000000000..0700566d7 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/create.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/delete-tag.md b/app/sdks/server-go/docs/examples/functions/delete-tag.md new file mode 100644 index 000000000..caf36146d --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/delete-tag.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/delete.md b/app/sdks/server-go/docs/examples/functions/delete.md new file mode 100644 index 000000000..e49addb2b --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/delete.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/get-execution.md b/app/sdks/server-go/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..13a3ad468 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/get-execution.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/get-tag.md b/app/sdks/server-go/docs/examples/functions/get-tag.md new file mode 100644 index 000000000..640543d94 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/get-tag.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/get.md b/app/sdks/server-go/docs/examples/functions/get.md new file mode 100644 index 000000000..2bba5028c --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/get.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/list-executions.md b/app/sdks/server-go/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..5115928c2 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/list-executions.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/list-tags.md b/app/sdks/server-go/docs/examples/functions/list-tags.md new file mode 100644 index 000000000..b6e495988 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/list-tags.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/list.md b/app/sdks/server-go/docs/examples/functions/list.md new file mode 100644 index 000000000..0a208e367 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/list.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/update-active.md b/app/sdks/server-go/docs/examples/functions/update-active.md new file mode 100644 index 000000000..da3b0f122 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/update-active.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/functions/update.md b/app/sdks/server-go/docs/examples/functions/update.md new file mode 100644 index 000000000..eaa7e4bf4 --- /dev/null +++ b/app/sdks/server-go/docs/examples/functions/update.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/docs/examples/health/get-queue-functions.md b/app/sdks/server-go/docs/examples/health/get-queue-functions.md new file mode 100644 index 000000000..5df453068 --- /dev/null +++ b/app/sdks/server-go/docs/examples/health/get-queue-functions.md @@ -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) +} \ No newline at end of file diff --git a/app/sdks/server-go/functions.go b/app/sdks/server-go/functions.go new file mode 100644 index 000000000..621953696 --- /dev/null +++ b/app/sdks/server-go/functions.go @@ -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) +} diff --git a/app/sdks/server-go/health.go b/app/sdks/server-go/health.go index eb4832ceb..709bea58a 100644 --- a/app/sdks/server-go/health.go +++ b/app/sdks/server-go/health.go @@ -60,6 +60,16 @@ func (srv *Health) GetQueueCertificates() (map[string]interface{}, error) { 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 // Appwrite internal queue server. func (srv *Health) GetQueueLogs() (map[string]interface{}, error) { diff --git a/app/sdks/server-java/src/main/java/services/Functions.java b/app/sdks/server-java/src/main/java/services/Functions.java new file mode 100644 index 000000000..4916d10a7 --- /dev/null +++ b/app/sdks/server-java/src/main/java/services/Functions.java @@ -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 params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map 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 params = Map.ofEntries( + entry("name", name), + entry("vars", vars), + entry("trigger", trigger), + entry("events", events), + entry("schedule", schedule), + entry("timeout", timeout) + ); + + + + final Map 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 params = Map.ofEntries( + ); + + + + final Map 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 params = Map.ofEntries( + entry("name", name), + entry("vars", vars), + entry("trigger", trigger), + entry("events", events), + entry("schedule", schedule), + entry("timeout", timeout) + ); + + + + final Map 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 params = Map.ofEntries( + ); + + + + final Map 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 params = Map.ofEntries( + entry("active", active) + ); + + + + final Map 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 params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map 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 params = Map.ofEntries( + entry("async", async) + ); + + + + final Map 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 params = Map.ofEntries( + ); + + + + final Map 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 params = Map.ofEntries( + entry("search", search), + entry("limit", limit), + entry("offset", offset), + entry("orderType", orderType.name()) + ); + + + + final Map 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 params = Map.ofEntries( + entry("env", env), + entry("command", command), + entry("code", code) + ); + + + + final Map 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 params = Map.ofEntries( + ); + + + + final Map 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 params = Map.ofEntries( + ); + + + + final Map headers = Map.ofEntries( + entry("content-type", "application/json") + ); + + return client.call("DELETE", path, headers, params); + } +} \ No newline at end of file diff --git a/app/sdks/server-java/src/main/java/services/Health.java b/app/sdks/server-java/src/main/java/services/Health.java index 2d9ff9d36..449e2bfd2 100644 --- a/app/sdks/server-java/src/main/java/services/Health.java +++ b/app/sdks/server-java/src/main/java/services/Health.java @@ -90,6 +90,22 @@ public class Health extends Service { + final Map 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 params = Map.ofEntries( + ); + + + final Map headers = Map.ofEntries( entry("content-type", "application/json") ); diff --git a/app/sdks/server-nodejs/docs/examples/functions/create-execution.md b/app/sdks/server-nodejs/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..9ed33ae50 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/create-execution.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/create-tag.md b/app/sdks/server-nodejs/docs/examples/functions/create-tag.md new file mode 100644 index 000000000..5048701d0 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/create-tag.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/create.md b/app/sdks/server-nodejs/docs/examples/functions/create.md new file mode 100644 index 000000000..0e07478aa --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/create.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/delete-tag.md b/app/sdks/server-nodejs/docs/examples/functions/delete-tag.md new file mode 100644 index 000000000..fc2fe8a53 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/delete-tag.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/delete.md b/app/sdks/server-nodejs/docs/examples/functions/delete.md new file mode 100644 index 000000000..048c96d99 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/delete.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/get-execution.md b/app/sdks/server-nodejs/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..482f7ee71 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/get-execution.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/get-tag.md b/app/sdks/server-nodejs/docs/examples/functions/get-tag.md new file mode 100644 index 000000000..5caa2134b --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/get-tag.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/get.md b/app/sdks/server-nodejs/docs/examples/functions/get.md new file mode 100644 index 000000000..cfc2d0fae --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/get.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/list-executions.md b/app/sdks/server-nodejs/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..ceecf677a --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/list-executions.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/list-tags.md b/app/sdks/server-nodejs/docs/examples/functions/list-tags.md new file mode 100644 index 000000000..147d65afe --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/list-tags.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/list.md b/app/sdks/server-nodejs/docs/examples/functions/list.md new file mode 100644 index 000000000..3cb999c51 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/list.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/update-active.md b/app/sdks/server-nodejs/docs/examples/functions/update-active.md new file mode 100644 index 000000000..1c2f0da2e --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/update-active.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/functions/update.md b/app/sdks/server-nodejs/docs/examples/functions/update.md new file mode 100644 index 000000000..f475c4a08 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/functions/update.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md b/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md new file mode 100644 index 000000000..a799c2980 --- /dev/null +++ b/app/sdks/server-nodejs/docs/examples/health/get-queue-functions.md @@ -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); +}); \ No newline at end of file diff --git a/app/sdks/server-nodejs/index.js b/app/sdks/server-nodejs/index.js index f5259f59d..deb571190 100644 --- a/app/sdks/server-nodejs/index.js +++ b/app/sdks/server-nodejs/index.js @@ -1,6 +1,7 @@ const Client = require('./lib/client.js'); const Avatars = require('./lib/services/avatars.js'); const Database = require('./lib/services/database.js'); +const Functions = require('./lib/services/functions.js'); const Health = require('./lib/services/health.js'); const Locale = require('./lib/services/locale.js'); const Storage = require('./lib/services/storage.js'); @@ -11,6 +12,7 @@ module.exports = { Client, Avatars, Database, + Functions, Health, Locale, Storage, diff --git a/app/sdks/server-nodejs/lib/services/functions.js b/app/sdks/server-nodejs/lib/services/functions.js new file mode 100644 index 000000000..d9898d342 --- /dev/null +++ b/app/sdks/server-nodejs/lib/services/functions.js @@ -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; \ No newline at end of file diff --git a/app/sdks/server-nodejs/lib/services/health.js b/app/sdks/server-nodejs/lib/services/health.js index a77e07eb6..159a27cc6 100644 --- a/app/sdks/server-nodejs/lib/services/health.js +++ b/app/sdks/server-nodejs/lib/services/health.js @@ -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 * diff --git a/app/sdks/server-php/composer.json b/app/sdks/server-php/composer.json index fc13cb3be..64d2e1746 100644 --- a/app/sdks/server-php/composer.json +++ b/app/sdks/server-php/composer.json @@ -7,7 +7,7 @@ "license": "BSD-3-Clause", "support": { "url": "https://appwrite.io/support", - "email": "team@appwrite.io" + "email": "team@localhost.test" }, "autoload": { "psr-4": { diff --git a/app/sdks/server-php/docs/examples/functions/create-execution.md b/app/sdks/server-php/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..ca232c877 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/create-execution.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->createExecution('[FUNCTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/create-tag.md b/app/sdks/server-php/docs/examples/functions/create-tag.md new file mode 100644 index 000000000..cc4ff73e9 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/create-tag.md @@ -0,0 +1,15 @@ +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]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/create.md b/app/sdks/server-php/docs/examples/functions/create.md new file mode 100644 index 000000000..4e6c888f0 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/create.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->create('[NAME]', [], 'event', [], '', 1); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/delete-tag.md b/app/sdks/server-php/docs/examples/functions/delete-tag.md new file mode 100644 index 000000000..681c9c3aa --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/delete-tag.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->deleteTag('[FUNCTION_ID]', '[TAG_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/delete.md b/app/sdks/server-php/docs/examples/functions/delete.md new file mode 100644 index 000000000..12476f1d6 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/delete.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->delete('[FUNCTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/get-execution.md b/app/sdks/server-php/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..774c7ecc3 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/get-execution.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->getExecution('[FUNCTION_ID]', '[EXECUTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/get-tag.md b/app/sdks/server-php/docs/examples/functions/get-tag.md new file mode 100644 index 000000000..b1c2f23dc --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/get-tag.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->getTag('[FUNCTION_ID]', '[TAG_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/get.md b/app/sdks/server-php/docs/examples/functions/get.md new file mode 100644 index 000000000..0b6b438c6 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/get.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->get('[FUNCTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/list-executions.md b/app/sdks/server-php/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..a0403c653 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/list-executions.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->listExecutions('[FUNCTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/list-tags.md b/app/sdks/server-php/docs/examples/functions/list-tags.md new file mode 100644 index 000000000..3c2e6b6e8 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/list-tags.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->listTags('[FUNCTION_ID]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/list.md b/app/sdks/server-php/docs/examples/functions/list.md new file mode 100644 index 000000000..bfbfde406 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/list.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->list(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/update-active.md b/app/sdks/server-php/docs/examples/functions/update-active.md new file mode 100644 index 000000000..18b7316f3 --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/update-active.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->updateActive('[FUNCTION_ID]', '[ACTIVE]'); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/functions/update.md b/app/sdks/server-php/docs/examples/functions/update.md new file mode 100644 index 000000000..1727ae92c --- /dev/null +++ b/app/sdks/server-php/docs/examples/functions/update.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$functions = new Functions($client); + +$result = $functions->update('[FUNCTION_ID]', '[NAME]', [], 'event', [], '', 1); \ No newline at end of file diff --git a/app/sdks/server-php/docs/examples/health/get-queue-functions.md b/app/sdks/server-php/docs/examples/health/get-queue-functions.md new file mode 100644 index 000000000..b8df53024 --- /dev/null +++ b/app/sdks/server-php/docs/examples/health/get-queue-functions.md @@ -0,0 +1,15 @@ +setProject('5df5acd0d48c2') // Your project ID + ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key +; + +$health = new Health($client); + +$result = $health->getQueueFunctions(); \ No newline at end of file diff --git a/app/sdks/server-php/docs/functions.md b/app/sdks/server-php/docs/functions.md new file mode 100644 index 000000000..103bf501e --- /dev/null +++ b/app/sdks/server-php/docs/functions.md @@ -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. | | + diff --git a/app/sdks/server-php/docs/health.md b/app/sdks/server-php/docs/health.md index 0161105d1..df7da5033 100644 --- a/app/sdks/server-php/docs/health.md +++ b/app/sdks/server-php/docs/health.md @@ -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. ** +## Check the number of pending functions messages + +```http request +GET https://appwrite.io/v1/health/queue/functions +``` + ## Check the number of pending log messages ```http request diff --git a/app/sdks/server-php/src/Appwrite/Services/Functions.php b/app/sdks/server-php/src/Appwrite/Services/Functions.php new file mode 100644 index 000000000..2a2633d47 --- /dev/null +++ b/app/sdks/server-php/src/Appwrite/Services/Functions.php @@ -0,0 +1,304 @@ +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); + } + +} \ No newline at end of file diff --git a/app/sdks/server-php/src/Appwrite/Services/Health.php b/app/sdks/server-php/src/Appwrite/Services/Health.php index a8423aa18..6b51c1732 100644 --- a/app/sdks/server-php/src/Appwrite/Services/Health.php +++ b/app/sdks/server-php/src/Appwrite/Services/Health.php @@ -87,6 +87,23 @@ class Health extends Service ], $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 * diff --git a/app/sdks/server-python/appwrite/services/functions.py b/app/sdks/server-python/appwrite/services/functions.py new file mode 100644 index 000000000..9664d6303 --- /dev/null +++ b/app/sdks/server-python/appwrite/services/functions.py @@ -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) diff --git a/app/sdks/server-python/appwrite/services/health.py b/app/sdks/server-python/appwrite/services/health.py index aa2a3fe37..9d7680bec 100644 --- a/app/sdks/server-python/appwrite/services/health.py +++ b/app/sdks/server-python/appwrite/services/health.py @@ -46,6 +46,16 @@ class Health(Service): 'content-type': 'application/json', }, 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): """Check the number of pending log messages""" diff --git a/app/sdks/server-python/docs/examples/functions/create-execution.md b/app/sdks/server-python/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..aa8e95575 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/create-execution.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/create-tag.md b/app/sdks/server-python/docs/examples/functions/create-tag.md new file mode 100644 index 000000000..533f3095c --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/create-tag.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/create.md b/app/sdks/server-python/docs/examples/functions/create.md new file mode 100644 index 000000000..a6551dba9 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/create.md @@ -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) diff --git a/app/sdks/server-python/docs/examples/functions/delete-tag.md b/app/sdks/server-python/docs/examples/functions/delete-tag.md new file mode 100644 index 000000000..554817cf5 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/delete-tag.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/delete.md b/app/sdks/server-python/docs/examples/functions/delete.md new file mode 100644 index 000000000..9c1575c1e --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/delete.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/get-execution.md b/app/sdks/server-python/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..b97924198 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/get-execution.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/get-tag.md b/app/sdks/server-python/docs/examples/functions/get-tag.md new file mode 100644 index 000000000..b5c3f2305 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/get-tag.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/get.md b/app/sdks/server-python/docs/examples/functions/get.md new file mode 100644 index 000000000..0e4036db4 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/get.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/list-executions.md b/app/sdks/server-python/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..75f5260b4 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/list-executions.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/list-tags.md b/app/sdks/server-python/docs/examples/functions/list-tags.md new file mode 100644 index 000000000..a99241664 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/list-tags.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/list.md b/app/sdks/server-python/docs/examples/functions/list.md new file mode 100644 index 000000000..a2b1e7d3d --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/list.md @@ -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() diff --git a/app/sdks/server-python/docs/examples/functions/update-active.md b/app/sdks/server-python/docs/examples/functions/update-active.md new file mode 100644 index 000000000..72f831405 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/update-active.md @@ -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]') diff --git a/app/sdks/server-python/docs/examples/functions/update.md b/app/sdks/server-python/docs/examples/functions/update.md new file mode 100644 index 000000000..c2482c5c2 --- /dev/null +++ b/app/sdks/server-python/docs/examples/functions/update.md @@ -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) diff --git a/app/sdks/server-python/docs/examples/health/get-queue-functions.md b/app/sdks/server-python/docs/examples/health/get-queue-functions.md new file mode 100644 index 000000000..c282ba796 --- /dev/null +++ b/app/sdks/server-python/docs/examples/health/get-queue-functions.md @@ -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() diff --git a/app/sdks/server-python/setup.py b/app/sdks/server-python/setup.py index 6446e4cb4..85c64b9c2 100644 --- a/app/sdks/server-python/setup.py +++ b/app/sdks/server-python/setup.py @@ -7,9 +7,9 @@ setuptools.setup( 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', author = 'Appwrite Team', - author_email = 'team@appwrite.io', + author_email = 'team@localhost.test', maintainer = 'Appwrite Team', - maintainer_email = 'team@appwrite.io', + maintainer_email = 'team@localhost.test', url = 'https://appwrite.io/support', download_url='https://github.com/appwrite/sdk-for-python/archive/0.0.4.tar.gz', # keywords = ['SOME', 'MEANINGFULL', 'KEYWORDS'], diff --git a/app/sdks/server-ruby/appwrite.gemspec b/app/sdks/server-ruby/appwrite.gemspec index 99fa047a9..aba1f9094 100644 --- a/app/sdks/server-ruby/appwrite.gemspec +++ b/app/sdks/server-ruby/appwrite.gemspec @@ -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)" s.author = 'Appwrite Team' 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) end \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite.rb b/app/sdks/server-ruby/lib/appwrite.rb index 8e8884278..1b4f38bea 100644 --- a/app/sdks/server-ruby/lib/appwrite.rb +++ b/app/sdks/server-ruby/lib/appwrite.rb @@ -5,6 +5,7 @@ require_relative 'appwrite/client' require_relative 'appwrite/service' require_relative 'appwrite/services/avatars' require_relative 'appwrite/services/database' +require_relative 'appwrite/services/functions' require_relative 'appwrite/services/health' require_relative 'appwrite/services/locale' require_relative 'appwrite/services/storage' diff --git a/app/sdks/server-ruby/lib/appwrite/services/functions.rb b/app/sdks/server-ruby/lib/appwrite/services/functions.rb new file mode 100644 index 000000000..dbab5af10 --- /dev/null +++ b/app/sdks/server-ruby/lib/appwrite/services/functions.rb @@ -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 \ No newline at end of file diff --git a/app/sdks/server-ruby/lib/appwrite/services/health.rb b/app/sdks/server-ruby/lib/appwrite/services/health.rb index f48069ff2..8b259d640 100644 --- a/app/sdks/server-ruby/lib/appwrite/services/health.rb +++ b/app/sdks/server-ruby/lib/appwrite/services/health.rb @@ -45,6 +45,17 @@ module Appwrite }, params); 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() path = '/health/queue/logs' diff --git a/app/sdks/web-javascript/src/sdk.js b/app/sdks/web-javascript/src/sdk.js index 4e8f1b019..64f05ee03 100644 --- a/app/sdks/web-javascript/src/sdk.js +++ b/app/sdks/web-javascript/src/sdk.js @@ -712,7 +712,7 @@ * @throws {Error} * @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) { throw new Error('Missing required parameter: "provider"'); } diff --git a/app/sdks/web-javascript/src/sdk.min.js b/app/sdks/web-javascript/src/sdk.min.js index b2af28282..334f3b2fd 100644 --- a/app/sdks/web-javascript/src/sdk.min.js +++ b/app/sdks/web-javascript/src/sdk.min.js @@ -45,7 +45,7 @@ return http.put(path,{'content-type':'application/json',},payload)},getSessions: if(password===undefined){throw new Error('Missing required parameter: "password"')} let path='/account/sessions';let payload={};if(email){payload.email=email} 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} 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"')} diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 588efe1d0..2ee25ed1c 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -55,8 +55,8 @@ $cli 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('https://appwrite.io/v1/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://appwrite.io/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']; $target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/';